开发者

XSLT Attribute Matching With Namespaces

I can not find a good explanation for why the second example here works but the first does not:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xsd"
    version="2.0">

  <xsl:template match="/">

    <xsl:value-of select="/wsdl:definitions/wsdl:message[@name = $messageName]"/>
    <xsl:value-of select="/wsdl:definitions/wsdl:message/@name[. = $messageName]"/>

  </xsl:template>

</xsl:stylesheet>

The context is finding a specific named message in a WSDL document. I suspect it has something to do with namespacing just about everything that trips me up badly with XSLT is but I do not understand why?

could someone shine a light on this for me I don't like experimenting to get a solution as it does not lead to understan开发者_开发问答ding.

the relevent sections of the WSDL are:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/">

   <message name="retrieveCustomerYtdResponse">
      <part name="parameter"/>
   </message>
   <message name="retrieveCustomerYtdRequest"/>

</definitions>


There is no any issue about namespaces. Both expressions are correct and produce the expected result.

Assuming (at least) a context template for the instructions, with the first instruction you are trying to print the text nodes descendant of wsdl:message with given @name. Nothing will be printed out as no text inside that element.

The second instruction will print the value of @name. That's correct.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜