[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CDATA sections in W3C XML Infoset
- From: David Carlisle <firstname.lastname@example.org>
- To: email@example.com
- Date: Sat, 31 Mar 2001 16:20:09 +0100
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 <a> 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 <a/> to the parser it fails.
The text node will have the string <a> if you are seeing <a>
then you have walked over the string replacing < by > But you
don't want to linearise the string as XML you don't want > 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