[jdom-interest] CDATA class inconsistencies

Bradley S. Huffman hip at a.cs.okstate.edu
Sat Feb 16 20:55:20 PST 2002


Elliotte Rusty Harold writes:

> At 10:24 PM -0500 2/16/02, Alex Rosen wrote:
> >>  2. Shouldn't CDATA be a subclass of Text? The JDOM methods are almost
> >>  all the same. I can imagine many aplications not caring about the
> >>  difference.
> >
> >I agree - or just have one Text class, with a switch to tell XMLOutputter
> >whether to output it as a CDATA section or a plain text node.
> >
> 
> That makes sense, and it sounds awfully familiar. I suspect it's been 
> suggested before and that the only reason we have two classes now is 
> that the CDATA class got added when we were still using Strings for 
> text nodes.

The archives seem to support you suspicion.  One idea would be to have
CDATA as a subclass of Text like you said, with Text having a flag for
whether it contains unescaped data. I think it would make merging Text/CDATA,
and outputting easy to keep correct.

Brad



More information about the jdom-interest mailing list