Jump to content

XSL required


srivatsahg

Recommended Posts

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_USI 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 <xsl:value-of select='format-number('Details/Price','Details/Format')' />and i get the output based on the format present in the XMLThanks Srivatsa

Link to comment
Share on other sites

Hello MartinThanks for the snippetProbably you read it wrong or most probably i didnt ask my question properly.I know that i have to use the <xsl:value-of select="format-number(12345.6789, '#.##0,00', 'de-DE')"/>to get the output. But i have to incorporate a condition based checking based on my tags de_DE or en_USi.eif (de_DE) use the format - #.##0,00else if (en_US) use the format - #,##0.00 i hope i have made clear this time RegardsSrivatsa

Example:
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">    <xsl:decimal-format	name="de-DE"	decimal-separator=","	grouping-separator="."/>	  <xsl:template match="/">	<xsl:value-of select="format-number(12345.6789, '#.##0,00', 'de-DE')"/>  </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...