XPath over DOM with CDATA section and text node sibling
Martin Honnen <[email protected]> Sun, 27 May 2007 18:37:43 +0200
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
The DOM data model and the XPath data model differ for the number of child nodes the test element in this XML document has: <root><test><![CDATA[cdata text.]]>normal text.</test></root> In the XPath data model the test element has a single text child node, in the DOM data model the test element has two child nodes, a CDATA section node and a text node. Mozilla (both Firefox 2.0 release as well as a 3.0a nightly) with this test case <http://home.arcor.de/martin.honnen/mozillaBugs/domLevel3/mappingProblem1.html> show the following output: Number of nodes: 2 nodeType: 4; nodeValue: cdata text. nodeType: 3; nodeValue: normal text. Is that in compliance with <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#TextNodes>? That says "Instead of returning multiple nodes where XPath sees a single logical text node, only the first non-empty DOM Text or CDATASection node of any logical XPath text will be returned in the node set." so it seems Mozilla should only return one child node, the CDATA section node. -- Martin Honnen http://JavaScript.FAQTs.com/