开发者

Saxon Xpath namespace

Given the following xml:

<Document xmlns="urn:company.com:catalog.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <book>
        <author>Wells</author>
 开发者_JAVA百科   </book>
</Document>

With Xerces the following xpath query works:

//urn:company.com:catalog.01:author

When I use Saxon (v 8.7) I a StaticError with message 'Invalid QName local part {company.com:catalog....}'.

What should the Xpath query look like to get the value of author?


Xerces should not allow an XPath expression like

//urn:company.com:catalog.01:author 

XPath is XML Names compliant, so a : (colon) in a QName divides the prefix part from local name part of a QName.

There is no syntax in XPath to use the full expanded QName in name test:

You could use

//*[local-name()='author'][namespace-uri()='urn:company.com:catalog.01']


You didn't post your XSL file. I went through this recently, and the solution was to make sure the xsl file has a line like:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="urn:company.com:catalog.01">

Then your references to elements in the xml file are prefixed with "c:":

//c:author
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜