【发布时间】:2021-08-18 22:47:32
【问题描述】:
我正在尝试创建 XSLT 以向下面的每个 Quantity 元素添加 10
<Lines>
<JournalLine>
<ItemCode>40006061</ItemCode>
<Quantity>90</Quantity>
</JournalLine>
<JournalLine>
<ItemCode>40006031</ItemCode>
<Quantity>120</Quantity>
</JournalLine>
<JournalLine>
<ItemCode>40008331</ItemCode>
<Quantity>2400</Quantity>
</JournalLine>
</Lines>
预期结果:-
<Lines>
<JournalLine>
<ItemCode>40006061</ItemCode>
<Quantity>100</Quantity>
</JournalLine>
<JournalLine>
<ItemCode>40006031</ItemCode>
<Quantity>130</Quantity>
</JournalLine>
<JournalLine>
<ItemCode>40008331</ItemCode>
<Quantity>2410</Quantity>
</JournalLine>
</Lines>
到目前为止,我所做的一切都导致在所有节点中重复相同的值,感谢任何帮助。
编辑:
我正在使用 XSLT-2.0,到目前为止,这是我的 XSLT 代码:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Quantity/text()">
<xsl:value-of select = "format-number(//Quantity, '###,###.00')"/>
</xsl:template>
<xsl:template match="Filename"></xsl:template>
</xsl:stylesheet>
【问题讨论】: