此代码应该打印数据中所有元素和属性的完整路径。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" expand-text="yes">
<xsl:output method="text"/>
<xsl:template match="text()"/>
<xsl:template match="*">
{ancestor-or-self::*/concat(node-name(),'/')}<xsl:apply-templates select="@*|*"/>
</xsl:template>
<xsl:template match="@*">{'@' || node-name() || ','}</xsl:template>
</xsl:stylesheet>
所以有了这个输入
<a:b xmlns:a="ans" xmlns:c="cns">
<c:x/>
</a:b>
我预计
{ans}b
{ans}b/ {cns}x
精确的间距无关紧要。
我得到的输出好像我使用了 name() 函数而不是 node-name 即
a:b
a:b / c:x
通过连接 local-name 和 namespace-uri 可能有一种解决方法,但我想知道为什么发布的内容没有按照我希望的那样做。