【问题标题】:How can I match the xmlns:* attributes with XSLT?如何将 xmlns:* 属性与 XSLT 匹配?
【发布时间】:2010-01-19 14:41:29
【问题描述】:
如何将 xmlns:* 属性与 XSLT 1.0 匹配?使用我尝试过的 RDF 文档:
<xs:template match="rdf:RDF">
(...)
<xsl:for-each select="@*">
<xsl:value-of select="."/>
</xsl:for-each>
(...)
</xsl:template>
但它似乎不适用于 xmlns 属性。
谢谢。
【问题讨论】:
标签:
xml
xslt
namespaces
xml-namespaces
【解决方案1】:
xmlns 属性不是普通属性,它们是命名空间声明。您需要使用命名空间轴来访问它们。
例如:
<xsl:for-each select="namespace::*">
<xsl:value-of select="name()" />
</xsl:for-each>
【解决方案2】:
你不能直接,但看看namespace轴:
<xsl:for-each select="namespace::*">
<xsl:value-of select="."/>
</xsl:for-each>