[jdom-interest] xsi:nil

Scott Ellis scotey at pacbell.net
Sat Oct 30 12:06:15 PDT 2004


Hi,

I'm not sure if I'll get replies to this, so please send me an responses.

I am one step away from using schema to validate my xml, xml that is generated by JDOM, but I have one last problem.  I cannot for the life of me figure out how to specify xsi:nil="true" as an element attribute.  I NEED this so that my incoming xml can specify to nullify the data in my text node, because if I don't allow nulls, then types that are specified as xs:dateTime for instance are rejected by the parser because it assumes a date is there and won't accept empty values.  I do not find it acceptable to change this to xs:string.

So, here is my sample code.  I am no guru, and am one step removed from the apes as far as my knowledge goes, so go easy on me.

org.jdom.Element elem = new Element( "SampleElement" );
elem.setAttribute( "xsi:nil", "true" );

That's what I'd like to do.  This throws an exception because I'm not allowed to have a colon in the attribute name.  So I fooled around with setting the Namespace to xsi, and I won't bother telling you what the exception was.  I'm not even sure if "xsi" is a namespace, or is a publicId or a systemId.  Don't know.  Maybe you can help.  But whatever it is, I need to know how to get it done with JDOM.

Can anybody help?

Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20041030/657dea8b/attachment.htm


More information about the jdom-interest mailing list