【发布时间】:2014-03-20 09:10:05
【问题描述】:
我有点卡在我想对 xml 文件进行的转换上。
基本上我正在尝试复制所有的 xml,但更改一些标签,这些标签只能这样开始
XML 代码:
<test alt="foo" title="bar"/>
通过 xsl 后我想得到什么:
<test alt="foo"/>
或者
<change alt="foo" title=""/>
问题是,有时我的标签有很多属性,所以我不想进行模板匹配,然后手动更改每个属性。
其实我就是这样做的:
<xsl:template match="test">
<change><xsl:apply-templates select="@*|node()"/></change>
</xsl:template>
<xsl:template match="test/@title">
<xsl:attribute name="title">
<xsl:value-of select=""/>
</xsl:attribute>
</xsl:template>
但它不会改变输出中标题的内容。
【问题讨论】:
标签: xml xslt transformation