Hallo,
wie kann ich den Inhalt unter "AllowanceOrCharge_Header_002/Amount" summieren und anschließend das "_002" entfernen? Es darf dann das Element "AllowanceOrCharge_Header_002" nicht mehr im XML ausgegeben werden.
Ist:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<OrderResponse>
<Interchange>
<CreationDate>2021-03-02T12:28:34</CreationDate>
</Interchange>
<HeaderInformation>
<AllowanceOrCharge_Header_002>
<CalculationLevel>1</CalculationLevel>
<Qualifier>C</Qualifier>
<Code>FI</Code>
<Amount>319.29</Amount>
</AllowanceOrCharge_Header_002>
<AllowanceOrCharge_Header_002>
<CalculationLevel>1</CalculationLevel>
<Qualifier>C</Qualifier>
<Code>FI</Code>
<Amount>327.69</Amount>
</AllowanceOrCharge_Header_002>
<AllowanceOrCharge_Header_002>
<CalculationLevel>1</CalculationLevel>
<Qualifier>C</Qualifier>
<Code>FI</Code>
<Amount>327.00</Amount>
</AllowanceOrCharge_Header_002>
</HeaderInformation>
<LineInformation>
<Item>
<LineNum>1</LineNum>
</Item>
</OrderResponse>
Soll:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<OrderResponse>
<Interchange>
<CreationDate>2021-03-02T12:28:34</CreationDate>
</Interchange>
<HeaderInformation>
<AllowanceOrCharge_Header>
<CalculationLevel>1</CalculationLevel>
<Qualifier>C</Qualifier>
<Code>FI</Code>
<Amount>973.98</Amount>
</AllowanceOrCharge_Header>
</HeaderInformation>
<LineInformation>
<Item>
<LineNum>1</LineNum>
</Item>
</OrderResponse>
Hatte folgenden Ansatz:
<xsl:template match="AllowanceOrCharge_Header">
<xsl:copy>
<!--copy all other nodes-->
<xsl:apply-templates select="@* | node()"/>
<Amount>
<xsl:value-of select="format-number(sum(//AllowanceOrCharge_Header_002[Code = 'FI']/Amount), '#.0000')"/>
</Amount>
</xsl:copy>
</xsl:template>
Danke & LG Julian