Hello
Am a beginner to XSL hardly know few commands.
I was trying out a sample where i have to format a number based on the entry in the XML.
I want to use the format-number function to achieve the same.
<Details>
<Order>Bulk Order</Order>
<OrderDate>1997-07-16T19:20:30+01:00</OrderDate>
<Quantity>100</Quantity>
<Price>99.45</Price>
<Format>de_DE</Format>
</Details>
<Details>
<Order>Bulk Order</Order>
<OrderDate>1997-07-16T19:20:30+01:00</OrderDate>
<Quantity>100</Quantity>
<Price>99.45</Price>
<Format>en_US</Format>
</Details>
However i can render the output if i use :
<xsl:value-of select='format-number(500100, "###,###.00")' />
But i want to use a certain condition
i.e if the Format is de_DE :
I want to pass the ###.###,00 to format-number method (note the decimal and thousand separators)
or if the Format is en_US
I want to pass the ###,###.00 to format-number method
I hopeless tried using choose statement ( but i really have no idea about the syntax of usage)
<xslt:choose>
<xslt:when test="$format = 'de_DE'">###,###.00</xslt:when>
<xslt:when test="$format = 'en_US'">###.###,00</xslt:when>
<xslt:otherwise>###.###,00</xslt:otherwise>
</xslt:choose>
Can anyone help me to put this onto a template or something so that i just call
and i get the output based on the format present in the XML
Thanks
Srivatsa
You could apply-templates and match on the value of the text node as follows:
This code for example, matches all Details nodes and for each match gets the total for the order. It then does an apply-template on the format passing in the total as a parameter. The match then occurs on the value of the format node.
I think the format ‘###.###.00’ is invalid as it seems that only one decimal point is allowed. ‘###,###.00’ is fine.