Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] CDATA section serialization

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Noam Tamim <noamtm AT gmail.com>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] CDATA section serialization
  • Date: Fri, 22 Jul 2005 19:59:35 +0300

[Sorry, sent it only to Elliotte]

Remind me again, why do you think keeping the original
(Text-CDATA-Text-CDATA-Text) is wrong?
That is, why can't I use XOM to change some input XML that has Text and
CDATA nodes, and have the CDATA sections preserved when serialized back into
XML?

On 7/22/05, Elliotte Harold <elharo AT metalab.unc.edu> wrote:
>
> A thought has occurred to me while experimenting with Wolfgang's latest
> optimizations. This isn't an optimization one way or the other, really.
> It just happened to come up when I was looking at that code. Consider
> this unusual case:
>
> <element>Text<[![CDATA[data]]>Text<[![CDATA[data]]>Text</element>
>
> A slightly more common variation might be:
>
> <element>
> <[![CDATA[data]]>
> </element>
>
> However it's basically a text node that contains one or more CDATA
> sections as well as some text outside CDATA sections. Currently when XOM
> encounters this it represents it as plain text. That is,
>
> <element>TextdataTextdataText</element>
>
> That is, it uses a regular text node and throws away the CDATA sections.
> There's no way XOM can preserve the multiple plain texts and CDATA
> sections because it accumulates all text nodes into a single node on
> parsing. However, instead of using a single Text object here it could
> use a single CDATASection object. That is, it could instead produce this:
>
> <element><[![CDATA[TextdataTextdataText]]></element>
>
> Because the CDATASection class is hidden in the non-public API, this
> really only affects output from toXML and the Serializer. Would this be
> preferable? Or is it better to just output plain text with appropriate
> escapes when mixing CDATA sections with content in non-CDATA sections?
>
> The semantic effect here is (or should be) nil. It's really just a
> question of aesthetic preference.
>
> --
> 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