我正在使用XSLT来复制文件,我想复制某个节点的所有属性,但我想用新的属性替换一些属性。例如,我可能会这样:是否有一种简单的方法来复制元素及其属性,同时只替换一些属性?
<Library>
<Book author="someone" pub-date="atime" color="black" pages="900">
</Book>
</Library>
我怎么能复制这个,但用新值替换pub-date和color?有没有类似的东西?
<xsl:template match="/Library/Book">
<xsl:copy>
<xsl:attribute name="pub-date">1-1-1976</xsl:attribute>
<xsl:attribute name="color">blue</xsl:attribute>
<xsl:apply-templates select="*@[not pub-date or color] | node()"/>
</xsl:copy>
</xsl:template>
但是,这不是有效的,当然...
请不要在你的问题的标题包括“XSLT”。这是标签系统的用途。谢谢! –