[jdom-interest] CDATA whitespace

Robertson, Jason Jason.Robertson at acs-inc.com
Wed Jul 10 07:06:38 PDT 2002

Ok, you sent me on the path to discovery. I have this line:


And when I set that to false (or remove it) it works like I would expect it
to. That's what happens when you copy/paste and don't really look at what
you're pasting! 

But it's still a little confusing to me, though, as I wouldn't consider a
CDATA section to be "text". My impression of CDATA (which could be totally
wrong) is that it's raw data, and thus any XML processor shouldn't make any
assumption on how it would be ok to reformat it in any scenario. I guess I
extended "don't interpret what's in here as XML" to be "don't interpret
what's in here at all".


-----Original Message-----
From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
Sent: Tuesday, July 09, 2002 7:57 PM
To: Robertson, Jason
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] CDATA whitespace 

What's the creation and use of XMLOutputter look like?


"Robertson, Jason" writes:

> I have this is document #1:
>   <something><![CDATA[
>      Some Multiline
>      Text.
>   ]]></something>
> And when I get the CDATA part and clone it into document #2 like this:
>   Element something = parent.getChild("something");
>   CDATA cdata = (CDATA) something.getContent().get(0);
>   doc2Root.addContent(new Element("elem").addContent((CDATA)
> cdata.clone()));
> I get this in document #2 (when output with XMLOutputter):
>   <elem><![CDATA[Some Multiline Text.]]></elem>
> Is this correct behavior with regards to the dropping of the whitespace?  
> Jason
To control your jdom-interest membership:

More information about the jdom-interest mailing list