2011-08-31 71 views
1
<Product xmlns:fish="urn:fish.com:international"> 
     <Assets fish:relativePath="013\7614500010013"> 
     </Assets> 
</Product> 

我需要能够获取asset属性fish:relativePath和xslt。我该怎么做呢?使用命名空间和xslt获取属性值

我已经把鱼名称空间放入xslt头文件中。

 <xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:asp="remove" 
xmlns:fish="urn:fish.com:international"> 

在此先感谢。

回答

3

创建访问使用@属性的资产节点模板,然后将其应用:

<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>