[jdom-interest] CDATA sections?

K.C. Jones kjones at phoenix-pop.com
Fri Jun 2 11:49:24 PDT 2000

Jason Hunter wrote:
> Wesley Biggs wrote:
> > More control to the user.  More predictable output.
> But would you really want to add a whole CDATA class and
> make getMixedContent() less intuitive and change the
> document structure itself just so that the programmer can
> have control over whether text is output using < or
> CDATA when both are semantically equivalent?

Absolutely.  No doubt.

A few points:

The semantic equivalence argument that says
 "<![CDATA[<BAR>This is CDATA</BAR>]]>"
is the same as
 "&lt;BAR&gt;This is CDATA&lt;/BAR&gt;"
is only true for XML parsers.  It is not true for DOM or SAX
(or JDOM) clients in general.

In my exploratory cocoon usage, almost all of my XML files
use CDATA to contain HTML or WML fragments.  These files are
transformed via XSL into HTML or WML streams where "<" and
"&lt;" are absolutely not equivalent.

Applying an XMLOutputter hack, especially some smart "ugly"
eradicator, is not just problematic, it's irrelevant to
DOMOutputter or SAXOutputter clients.  My expected use case
goes from JDOM to DOM/SAX via the appropriate Outputter on
its way to WML, HTML, or XHTML.

Yes, you'd be right to argue that HTML cruft is just
polluting my XML publishing scheme, and that formatting
belongs in XSL.  But I seriously doubt I'm alone in my
usage.  And its not for JDOM to pass judgment over what is
good and bad XML.

It might be informative to conduct a quick inventory of
users' XML data.  How often do CDATA sections occur?  If
they are prevalent, as I suspect they are, then it tends to
put CDATA on the 80 side of the 80/20 razor.


Having said all that, I think it might be useful to step
back from this discussion.  THere seems to be a disconnect
in this thread.  Perhaps because there were earlier threads
that are fresh in some people's minds and not in others'.

I would appreciate someone taking a stab at a summary of the
debate and the design choices under consideration.  Once the
design question is properly framed, use cases can be applied
to evaluate the design choices.

KC Jones

More information about the jdom-interest mailing list