Getting attribute value using namespace and xslt
<Product xmlns:fish="urn:fish.com:international">
&l开发者_JS百科t;Assets fish:relativePath="013\7614500010013">
</Assets>
</Product>
I need to be able to get at the asset attribute fish:relativePath with an xslt. How do I do this?
I've already put the fish namespace into the xslt header.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asp="remove"
xmlns:fish="urn:fish.com:international">
Thanks in advance.
Create a template for the Assets node that accesses the attribute using @
, then apply that template:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asp="remove"
xmlns:fish="urn:fish.com:international">
<xsl:template match="/">
<xsl:apply-templates select="/Product/Assets"/>
</xsl:template>
<xsl:template match="Assets">
<xsl:value-of select="@fish:relativePath"/>
</xsl:template>
</xsl:stylesheet>
精彩评论