How can I match the xmlns:* attributes with XSLT?

一个人想着一个人 提交于 2020-02-02 07:26:04

问题


How can I match the xmlns:* attributes with XSLT 1.0 ? Using a RDF document I tried:

<xs:template match="rdf:RDF">
(...)
<xsl:for-each select="@*">
  <xsl:value-of select="."/>
</xsl:for-each>
(...)
</xsl:template>

but it doesn't seem to work for the xmlns attributes.

Thanks.


回答1:


The xmlns attributes aren't normal attributes, they are namespace declarations. You need to use the namespace axis to access them.

e.g.:

<xsl:for-each select="namespace::*">
   <xsl:value-of select="name()" />
</xsl:for-each>



回答2:


You can't directly, but have a look at the namespace axis:

<xsl:for-each select="namespace::*">
    <xsl:value-of select="."/>
</xsl:for-each>


来源:https://stackoverflow.com/questions/2094203/how-can-i-match-the-xmlns-attributes-with-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!