[jdom-interest] CDATA sections?

Brett McLaughlin brett.mclaughlin at lutris.com
Fri Jun 2 12:07:21 PDT 2000


Kevin Regan wrote:
> 
> >
> > > System.out.println( "<FOO><![CDATA[<BAR>This is CDATA</BAR>]]></FOO>"
> > );
> > >
> > > With JDOM, it makes alot of sense to build a JDOM tree to
> > > create the output document.  The above would not be possible
> > > with the current implementation.
> >
> > No. It would be easier.
> >
> > Element myElement = new Element("FOO");
> > myElement.setConent("<BAR>This is CDATA</BAR>");
> >
> > Why make them create a CDATA? Our Outputter takes care of this for you.
> >
> > -Brett
> >
> 
> I'm not sure if you are arguing seriously with me here. :-)
> My argument is for someone that wants to create a CDATA section.
> Your example does not do that.
> 
> Take the following (better) example:
> 
> -- Attempting to include the text "<Markup>" in
> a FOO element.
> 
> This can be output to "equivalent" ways:
> 
> <FOO>&lt;Markup&gt;</FOO>
> 
> and
> 
> <FOO><![CDATA[<Markup>]]></FOO>
> 
> The user really should have a choice as to which format
> he wants to use.  Example: For a large HTML segment, it will be

You're not getting it - JODM doesn't need CDATA to do this:

Element foo = new Element("foo");
foo.setContent("<Markup>");

Done. No need for CDATA. Why do I care? I don't. I just want the content
to be <Markup>, and that code does it. I'm not sure what is so hard
about this ;-)

Outputting handles escaping it, in any way we need to that /ensures/ the
content is unchanged. Period.

-Brett

> much more efficient, and much more aesthetically pleasing
> to use a CDATA section, rather than escaping the entire
> segment.
> 
> --Kevin

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list