[XOM-interest] CDATA sections
New, Cecil (GE Trans)
cecil.new at ae.ge.com
Tue Jan 4 11:17:57 EST 2005
As long as there is no DTD, then a CDATA seems unecessary.
But if there is a DTD and it does not allow mixed content for <content>,
then a CDATA section would effectively sidestep validation issues...
I have taken advantage of this in one web application that allows an admin
to enter text that shows in a description area of a web page - the entire
page constructed from an XML document stored in a database. As originally
designed, it was intended only for plain text - a simple paragraph.
I discovered pretty quickly that by wrapping HTML in a CDATA section I would
improve the readability and presentation - with no DTD change needed. In
the general case, there are clearly reasons for why one should not do this.
But in my case, the descriptive text was purely for human consumption and is
not the target of xpath/xquery searches, etc.
-----Original Message-----
From: Elliotte Harold [mailto:elharo at metalab.unc.edu]
Sent: Tuesday, January 04, 2005 10:06 AM
To: Arjan Huijzer
Cc: XOM-interest at lists.ibiblio.org
Subject: Re: [XOM-interest] CDATA sections
Arjan Huijzer wrote:
> Hi,
>
> <article>
> <content>
> <![CDATA[
> <title>myTitle</title>
> <para>Some Text</para>
> ]]>
> </content>
> </article>
>
> I was wondering what the best way was to generate the CDATA section with
XOM.
>
It can't be done because you don't need to do it. Just make the text
nodes containing the content you want it to contain and XOM will
serialize it appropriately.
--
Elliotte Rusty Harold elharo at metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
More information about the XOM-interest
mailing list