Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] CDATA sections

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "New, Cecil (GE Trans)" <cecil.new AT ae.ge.com>
  • To: "'Elliotte Harold'" <elharo AT metalab.unc.edu>, Arjan Huijzer <huijzer AT gmail.com>
  • Cc: XOM-interest AT lists.ibiblio.org
  • Subject: RE: [XOM-interest] CDATA sections
  • Date: Tue, 4 Jan 2005 11:17:57 -0500

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




Archive powered by MHonArc 2.6.24.

Top of Page