OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CDATA sections in W3C XML Infoset

   In this case "my software" is the Xerces DOM parser, and yes, I am
   saying that this software treats <![CDATA[<a/>]]> differently from

yes the parser might flag all sorts of stuff like line numbers in the
source, comments etc, as well as cdata sections but why does the
application you layer over that care about cdata?

    1. The DOM gives you a different node type for the former than
       it gives you for the latter.

But they both have the same string content. If you give it
<![CDATA[<a>]]> or &lt;a&gt; then in both cases the DOM will pass you a
string of length three "<a>" in one case a CDATA node in the other a
text, but that only matters if you are some kind of editor and want to
write the file back in a way similar to  the source markup.

    2. If you hand the value of the node you get back for the former
       to an XML parser you get a successfully parsed document;
       if you hand &lt;a/&gt; to the parser it fails.

The text node will have the string <a> if you are seeing &lt;a&gt;
then you have walked over the string replacing < by &gt; But you
don't want to linearise the string as XML you don't want &gt; and you
don't want <![CDATA you just want to take the string as XML markup as it
stands, and the string is the same whether or not it was originally
marked with CDATA.


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit