[jdom-interest] CDATA sections?

Kevin Regan kevinr at valicert.com
Fri Jun 2 14:53:23 PDT 2000


For well-formed XML, you could get away with this.  But for many
applications (such as digital signatures or anything that uses
a DTD/Schema), you need to do validation. JDOM will parse an HTML block
into a tree as XML (without validation).  It won't give you the HTML as a
string (which is what was desired in my example).

--Kevin

> 
> 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
> 
> <MyFragment>
> 	<b>some well-formed, but <i>fairly ignored</i> xml-ish stuff</b>
> </MyFragment>
> 
> 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
> DocumentFragment...)
> 
> 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.  
> 
> 		-bob
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
> rhost.com
> 




More information about the jdom-interest mailing list