The good news however was, that we finally had an XML export of those quotes.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkTPgJtX7NjH-Z6RuewxqAArE0mNW_TmQxSYNNq1vDsnPwgCLrRKtshVhzoGkIG3tFk9cAiNNpJuiyyVHTfaev2R8qV-I3wofGm_F8WpGGs46LOPv895YfrKzbnmr07gpfKbWP/s320/xmlSum.png)
Quite frankly, it took me about 7 minutes to create the pure formatting XSLT and the remaining 23 minutes to figure out how to do sums in XSLT.
So, the two things I learned from this little exercise:
1. How to format a number using XSLT:
Use the format-number function as in:
<xsl:value-of select="format-number(amount, '#.00')"/>
2. How to add (sum) values (node-sets to be precise)
You have to use the sum function as in:
<xsl:value-of select="format-number(sum(//lineItem[@isSupportLine='true']/price), '#.00')"/>
For me this very line shows the power of XSLT:
It is adding all values of the "price" element of all "lineItems" that have an attribute "isSupportLine='true'".
In other words: build the sum of the price of all support lines in the quote.
Or in SQL: select sum(price) from lineitems where isSupportLine="true"
No comments:
Post a Comment