Thursday, October 2, 2008

XSLT

XSL stands for EXtensible Stylesheet Language. The World Wide Web Consortium (W3C) started to develop XSL because there was a need for an XML-based style sheet language. XSLT stands for XSL Transformations. We can use XSLT to transform XML documents into other formats, like XHTML.
http://www.w3schools.com/xsl/default.asp
In my project i used it to transform xml document to csv file.
TransformBillingXmlToCsv.xml

xsl:template name="amount"
xsl:text " /xsl:text
xsl:value-of select="currencySymbol"/
xsl:text /xsl:text
xsl:choose
xsl:when test="currencySymbol = 'JPY'"
xsl:value-of select='format-number(value, "#.")'/
/xsl:when
xsl:otherwise
xsl:value-of select='format-number(value, "#.00")'/
/xsl:otherwise
/xsl:choose
xsl:text " /xsl:text
/xsl:template

(tag characters are removed from above sample code)
Here i had to use XSLT format-number() Function and XSLT Element.

http://www.w3schools.com/XSL/func_formatnumber.asp
http://www.w3schools.com/xsl/el_when.asp

No comments: