[jdom-interest] don't validate comments

Bradley S. Huffman hip at a.cs.okstate.edu
Thu Dec 5 11:14:53 PST 2002

"Christian Peter" writes:

> I get a org.jdom.IllegalDataException telling me that "Comments 
> cannot contain double hyphens (--)", which doubtlessly is true
> (if you are interested, http://www.nasa.org causes the exception).
> However, I need to parse this document and since I'm not interested 
> in the comments, I would like JDOM to simply ignore the content of a 
>   comment. I thought I can achieve this by setting 
> DOMBuilder.setValidation to false, but I still get this Exception.
> Now I wonder, is it just me, who I have to set another option of 
> another component, or is it a bug, or do I have to change the 
> org.jdom.Verifyer class myself? Or is it done already on CVS? I use 
> the 0.7 beta-8 version.

Since DOM is suppose to represents well-formed XML, DOMBuilder shouldn't be
throwing any type of well-formness exception.  And if that's a typo and
SAXBuilder is really what's being used, then the SAX parser shouldn't be
reporting "--" through SAX's LexicalHandler.comment. Hopefully SAX is
throwing a SAXException and JDOM's SAXBuilder is just wrapping a
IllegalDataException around it.

Either way JDOM should *never* see a string with "--" in it as the text of
a comment from a SAX or DOM source, so there is really nothing JDOM can do.


More information about the jdom-interest mailing list