简体   繁体   English

如何使用XSLT在XML节点之间移动数据

[英]How to use an XSLT to move data between XML nodes

I don't know a lot about xslt but I need to fix a bug in someone else's code. 我对xslt不太了解,但是我需要修复其他人代码中的错误。 The issue is that some data is not being outputted correctly in an XML file so I need to use an XSLT to move the data to the correct node. 问题是某些数据未在XML文件中正确输出,因此我需要使用XSLT将数据移至正确的节点。 An example is shown below: 一个例子如下所示:

Incorrect XML: 不正确的XML:

<record name="recordname" value="Text(AAxxxx)">
<field name="recordID" value=""/>
</record>

Correct XML: 正确的XML:

<record name="recordname" value="Text(AAxxxx)">
    <field name="recordID" value="Text(AAxxxx)"/> 
    </record>

So I need to copy the value of the value field from the record name node to value in the field name node. 因此,我需要将值字段的值从记录名称节点复制到字段名称节点中的value。 Can anyone help me with this? 谁能帮我这个?

Thanks in advance 提前致谢

Extract "value" in XSLT is: 在XSLT中提取“值”为:

<xsl:value-of select="record/field/@value" />

Extract atribbute is "@" after of element. 提取占位符为元素后的“ @”。

this is a possibility. 这是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM