We have an xml document with invoices / [asst. elements], using the xslt call pattern, we need to summarize InvoiceAmounts to match InvoiceNumbers.
Enter the xml file:
<Invoices>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>137.50</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>362.50</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351511</InvoiceNumber>
<InvoiceAmount>239.50</InvoiceAmount>
</Invoice>
</Invoices>
I found a select statement that returns the total amount of InvoiceAmounts for the entire document, but I need to filter it to the amount based on InvoiceNumber, since there can be more than one invoice with the same InvoiceNumber in the invoice document.
This returns the total amount:
<xsl:value-of select="sum(/*[local-name()='Invoices']/*[local-name()='Invoice']/*[local-name()='InvoiceAmount'])" />
, -, . , p1, . , InvoiceNumbers = $p1? , . $p1 ?
<xsl:value-of select="sum(/*[local-name()='Invoices']/*[local-name()='Invoice'][local-name()='InvoiceAmount' = $p1]/*[local-name()='InvoiceAmount'])" />
:
<Invoices>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>500.00</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>500.00</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351511</InvoiceNumber>
<InvoiceAmount>239.50</InvoiceAmount>
</Invoice>
</Invoices>
.