Bharadwaj, Anand (ELS-OXF) wrote:
Hi All,

We are having an issue with XSLT parser sample (SimpleXPathAPI.exe).

It's an XPath _processor_, not an XPath _parser_.


When the XPath query (count(/*[1]/*[7]/*[5]/*[1]/*[3]/*[2]/node()))is made on the document containing the XML node snippet:

"<para id="para13">
<italic>Expand one&apos;s cultural knowledge</italic>


...


The parser is considering the leading 'whitespace' characters as one node and the total node count as 5 which are,

1.    *whitespace before <italic>*,

2.    <italic>

3.    text between <italic> and <anchor>

4.    <anchor>

5.    text after <anchor> till end.
This is correct, since that's what the XML recommendation, the XPath data model, and XML Information Set recommendation require.


As per our requirement the count should be 4 (excluding the (1) above).

We request to kindly let us know how to ignore these 'whitespace' nodes which are

actually children of 'Text node' types, through Xpath queries since we do not have the freedom to reload the document in any other configuration.
The only thing you can do is to build the document and strip the whitespace-only text nodes before they get to the XPath processor. You would need to write your own code to do that, or you could write a stylesheet to remove them, transform the original document using the XSLT processor, then use the transformed document with SimpleXPathAPI.exe.

Dave

Reply via email to