[jdom-interest] CDATA data (followup with more info)

Bradley S. Huffman hip at a.cs.okstate.edu
Sun Nov 10 20:36:18 PST 2002

Malachi de AElfweald writes:

> Ok, I am a little confused....
> The page you referred to says this:
> PIs are not part of the document's character data, but must be passed through
>  to the application. The 
> PI begins with a target (PITarget) used to identify the application to which 
> the instruction is 
> directed. The target names "XML", "xml", and so on are reserved for standardi
> zation in this or future 
> versions of this specification. The XML Notation mechanism may be used for fo
> rmal declaration of PI 
> targets. Parameter entity references are not recognized within processing ins
> tructions.
> So, according to the spec you sent me, it says that the
> XMLDecl is a reserved PI, using "XML"/"xml" as the target application.

No it just says "XML", "xml" and so on are reserved for the future, it doesn't
make the jump to the XML declaration being a special form of the PI.

The distinction between a XML declaration and a PI would be minor and really
wouldn't matter except for how the information they contain is reported. For
example, SAX 2.0 will never report a XML declaration through ContentHandler's 
processingInstruction.  However a previous version of XPP reported the
declaration as a PI (the lastest doesn't). JDOM and XOM don't allow "xml"
as a PI target. Xerces does, and looking at the source for dom4j seems to
allow it also, which means to me you can create a document in memory you
cann't roundtrip since both rely on SAX to build a document from a input

What it boils down to is if you treat the XML declaration as a PI you code
probably won't work correctly with the most widely used method for parsing


More information about the jdom-interest mailing list