[jdom-interest] Attribute vs text (fwd)

Jason Hunter jhunter at servlets.com
Fri Sep 1 11:16:34 PDT 2006

Hi Bjorn,

0x0 is a null character.  Somehow that snuck into your file, and it's 
illegal XML.  You could strip null characters wherever they appear in a 
file using a FilterInputStream during the read.  Or you could figure out 
how to keep nulls from getting into XML files.


Bjorn Roche wrote:
> Hey all,
> I recent got an error report from my app in the field that read, in part:
> org.jdom.IllegalDataException: The data "Celine Dion^@" is not legal for 
> a JDOM attribute: 0x0 is not a legal XML character.
> Yes, celine dion is an illegal character ;).
> Seriously, though, I know I can't put binary data into an attribute, and 
> I know that's what JDOM is complaining about. What confuses me is that 
> this data came off an iTunes xml file that I read with JDOM. Of course, 
> that field is user editable, and I might have missed a check somewhere 
> and let the user type in something crazy, but assuming that's not the 
> case, I have a few questions:
> - Is it possible that some text is allowed in the text of an XML 
> element, but not in an attribute? I can easily restructure my xml 
> document format to use the content of an XML object for this info rather 
> than attributes, but I need to know if it will work.
> - Is there an easy way to strip out illegal characters, so that I can 
> wrap calls like this up so that at least a best effort is made (at least 
> in cases where that makes sense)?
> Thanks for an unbelievably awesome library!
>     bjorn
> -------------
> Bjorn Roche
> XO Wave
> Audio Production and Post-Production Software for Mac OS X
> http://www.xowave.com
> http://www.myspace.com/xowave
> http://blog.bjornroche.com
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list