[XML-SIG] xpath (4xpath) and CDATA

Uche Ogbuji uche.ogbuji@fourthought.com
Thu, 05 Apr 2001 23:15:48 -0600


> xpath (which Martin has merged in from 4Xpath) doesn't recognize CDATA
> nodes.  According to the spec, http://www.w3.org/TR/xpath#NT-NodeType ,
> "a CDATA section is treated as if the <![CDATA[ and ]]> were removed and
> every occurrence of < and & were replaced by &lt; and &amp; respectively."

???  Do you mean when passing 4DOM nodes to 4XPath?  The Domlettes 
transparently turn CDATASections into contiguous text nodes.

If you do mean the situation with 4DOM, there is no easy fix for this.  There 
was some discussion on xsl-list about the problems of efficiently mapping DOM 
to XPath.  It seems some XPath implementors have simply declined DOM support 
except through complete export to a specialized format.

> I think the way to fix this is to add CDATA_SECTION_NODE next to every
> place that TEXT_NODE appears, but to do the above conversion whenever the
> *value* of the node is needed.

This could be a performance nightmare (you'll be amazed how often 
string-value() conversion is done in typical XSLT processing).  Besides, it 
just papers over the one problem, but what about adjacent text/CDATA nodes?  
What about entity reference nodes?

> Make sense?  I just want to double-check before I (ab)use my new status. :)

Nice to have you chipping in.


-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python