输入:
<soapenv:Envelope xmlns:ser="http://service.foo.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:com.foobar.to"
xmlns:wor="http://ffffff.aaa.com:443/AAA/services/Bar">
<soapenv:Body>
<ser:submit>
<urn:question>
<wor:item>1</wor:item>
</urn:question>
</ser:submit>
</soapenv:Body>
</soapenv:Envelope>
预期输出:
<soapenv:Envelope xmlns:ser="http://service.foo.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:com.foobar.to"
xmlns:wor="urn:com.foobar.to">
<soapenv:Body>
<ser:submit>
<urn:question>
<wor:item>1</wor:item>
</urn:question>
</ser:submit>
</soapenv:Body>
</soapenv:Envelope>
这目前用于将名称空间与特定的URI相匹配。
<xsl:template match="*[namespace-uri()='http://ffffff.aaa.com:443/AAA/services/Bar']">
<xsl:element name="{name()}" namespace="urn:com.foobar.to">
<xsl:copy-of select="namespace::*[name()]"/>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
我正在尝试修复以上问题,以匹配以/AAA/services/Bar
结束的任何内容
我原以为用2.0会有用,但事实并非如此。
<xsl:template match="*[ends-with(namespace-uri(), '/AAA/services/Bar')]">
如何在XSTL 1.0或/和XSTL 2.0中做到这一点?
感谢
您的尝试:
<xsl:template match="*[ends-with(namespace-uri(), '/AAA/services/Bar')]">
将在XSLT2.0中工作,如您所见:
https://xsltfiddle.liberty-development.net/aB9NKE
在XSLT1.0中,由于不支持ends-with()
函数,您需要执行以下操作:
<xsl:template match="*[substring(namespace-uri(), string-length(namespace-uri()) - 16) = '/AAA/services/Bar']">