【发布时间】:2014-07-18 08:38:33
【问题描述】:
假设我有一些 xml:
<a>
<b>something</b>
<c>something</c>
<d>something</d>
</a>
我希望<a> 的所有子级都以x 命名空间为前缀。目前我有以下实现这一目标:
<xsl:template match="a">
<a>
<xsl:apply-templates>
</a>
</xsl:template>
<xsl:template match="b">
<x:b><xsl:value-of select="." /></x:b>
</xsl:template>
<xsl:template match="c">
<x:c><xsl:value-of select="." /></x:c>
</xsl:template>
<xsl:template match="d">
<x:d><xsl:value-of select="." /></x:d>
</xsl:template>
这可行,但它很麻烦,我必须知道所有孩子的名字是什么。我知道match="*" 语法,但我不知道如何获取* 的名称,所以我可以在模板匹配中添加x。有什么想法吗?
明确地说,我希望将那些 xsl:template 节点替换为单个节点,该节点将在任何节点名称前加上包含 x 命名空间的节点。
【问题讨论】:
标签: xslt