XML: TransformationXSLT or XSL Transformation, is once again a <a href="http://www.w3.org/TR/xslt">W3C standard</a> External link to transform XML document from one format to the other. Using XSLT you can transform source XML documents to another XML documents, to HTML documents (for browsers) or to text format.What does it mean when I say using XSLT? It means that you'll have to learn a declarative language (as contrast to regular procedure language using which you write C++/Javasctipt code), and write stylesheets. The stylesheets are once again XML documents with rules (templates) and actions. And like XML parsers, there are <a href="http://www.perfectxml.com//toolsoft.asp?softcat=2">stylesheet processors</a> available, which you can readily use in your application. The XSL processors load the source XML document as tree, read the stylesheet and apply templates, to generate the result output document. XSLT makes use of another standard, <a href="http://www.perfectxml.com//glossary4.asp#xpath">XPath</a>. So, I wrote two XSLT stylesheets and applied them to XML documents returned from bank/credit union Web sites and here I am with to deal with single structure XML document. Here is an example XSLT stylesheet for above bank account XML document. Following sample stylesheet transforms source XML to HTML format. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="4.0" indent="yes" /> <xsl:template match="/"> <HTML> <BODY> <TABLE BORDER="1" bgcolor="#EEEEEE"> <xsl:apply-templates select="BankAccount" /> </TABLE> </BODY> </HTML> </xsl:template> <xsl:template match="BankAccount"> <TR> <xsl:apply-templates select="Number" /> <xsl:apply-templates select="Name" /> <xsl:apply-templates select="Type" /> <xsl:apply-templates select="OpenDate" /> <xsl:apply-templates select="Balance" /> </TR> </xsl:template> <xsl:template match="Number"> <TD STYLE="font-size:12pt font-family:serif"> <xsl:apply-templates /> </TD> </xsl:template> <xsl:template match="Name"> <TD STYLE="font-size:12pt font-family:serif"> <xsl:apply-templates /> </TD> </xsl:template> <xsl:template match="Type"> <TD STYLE="font-size:12pt font-family:serif"> <xsl:apply-templates /> </TD> </xsl:template> <xsl:template match="OpenDate"> <TD STYLE="font-size:12pt font-family:serif"> <xsl:apply-templates /> </TD> </xsl:template> <xsl:template match="Balance"> <TD STYLE="font-size:12pt font-family:serif"> <xsl:apply-templates /> </TD> </xsl:template> </xsl:stylesheet> |