[jdom-interest] CDATA sections?

bob bob at werken.com
Fri Jun 2 12:53:22 PDT 2000

> 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.

If they are well-formed XML, can you not make that element
holding these fragments as taking 'any'?  No point in wrapping them
with a CDATA.  (Then again, I'm not especially good at DTDs...)

For your use-case

	<b>some well-formed, but <i>fairly ignored</i> xml-ish stuff</b>

If the stuff within <MyFragment> is well-formed, then jdom
can still parse it in absence of a dtd/schema, and give you
a tree.  

To output it as SAX events, take <MyFragment>, wrap in a
Document, and output it.  (Or, use the currently non-existent

But I also might be making an over-assumption that you have
well-formed XML as your fragments of HTML/WML.

But if they are well-formed, I don't think you need a CDATA.

> 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.

I personally avoid them, since they can't hold absolutely
any set of bytes (that pesky end-of-CDATA marker keeps you
from holding CDATA-containing XML in a CDATA section, without
some crufy escapage).

fwiw, if I find myself thinking 'hey, I need to use a CDATA',
I'll typically punt, and use a reference/link to yet-another
resource.  But I'm also dealing with binary data, and like
my bytes MIME wrapped.  


More information about the jdom-interest mailing list