【问题标题】: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>
      

      【讨论】:

        猜你喜欢
        • 2019-01-10
        • 2010-11-11
        • 2011-11-08
        • 2019-07-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多