Xml 重命名结果元素的副本
我需要的是更改的xsl:copy的结果元素的名称。 我现在正在做的是: 基本xml:Xml 重命名结果元素的副本,xml,xslt,Xml,Xslt,我需要的是更改的xsl:copy的结果元素的名称。 我现在正在做的是: 基本xml: <root> <element> <type>type</type> <value id="id"> <first>first value</first> <under id="id_under"/> </value> </ele
<root>
<element>
<type>type</type>
<value id="id">
<first>first value</first>
<under id="id_under"/>
</value>
</element>
</root>
类型
第一值
其中元素可以是集合,值也可以是元素的集合
我的xslt:
<xsl:for-each select="root/element">
<xsl:for-each select="value">
<xsl:copy-of select="current()" />
</xsl:for-each>
</xsl:for-each>
通过这个,我得到了以下结构:
..
<value id="id">
<first>first value</first>
<under id="id_under"/>
</value>
..
。。
第一值
..
这是一个值数组,没关系,这正是我需要的。这里我只需要转换“value”标记名,并为我已经存储的变量重命名它。我怎样才能做到这一点?如果无法重命名的副本的“output”元素,我想唯一的方法是在模板中使用xsl:element和带有标识的属性集来创建子元素?我说得对吗?
谢谢。如果您希望该元素被称为其他元素,您并不真的需要它的
副本,是吗
<xsl:for-each select="value">
<xsl:element name="$your-variable">
<xsl:copy-of select="@*" /> <!-- copy the attributes -->
<xsl:copy-of select="*" /> <!-- copy the child elements -->
</xsl:element>
</xsl:for-each>
mm太酷了,我不知道副本上的选择属性,非常感谢,这对我有用。