CO.CC:Free Domain
Get Chitika Premium

Software Tutorials

HTML Tutorial Guide
CSS Tutorial Guide
CSS1 CSS2 Tutorial Guide
XHTML Tutorial Guide
XML Tutorial Guide
XSL Tutorial Guide
Getnaukrisoon

Custom Websites by AVCOdesign - Custom Websites, Site Management, Search Engine Optimization, Social Media Solutions, Hosting, Domain Registration.

XSL Introduction

XSL : EXtensible Stylesheet Language, a language for specifying style sheets for XML documents..

XSL Transformation (XSLT) is used with XSL to describe how an XML document is transformed into another document.

Similar to CSS, it defines the specification for an XML document's presentation and appearance. Both CSS and XSL provide a platform-independent method for specifying the document's presentation style.

With the XSL you can freely do modify any of the source text. Stylesheet 1 and the Stylesheet 2 produces the different output from a same source file.




XSL stylesheet 1

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >

<xsl:template match="/">
<H1><xsl:value-of select="//title"/></H1>
<H2><xsl:value-of select="//author"/></H2>
</xsl:template>
</xsl:stylesheet>


XSL stylesheet 2

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >

<xsl:template match="/">
<H2><xsl:value-of select="//author"/></H2>
<H1><xsl:value-of select="//title"/></H1>
</xsl:template>
</xsl:stylesheet>



An XML Syntax

An every XSL stylesheet should start with the xsl:stylesheet element. Atribute xmlns:xsl specifies the version of the XSL(T) specification. This example do show simplest possible stylesheet. As it do not contains any of the information, a default processing is been used.

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >

</xsl:stylesheet>



An XSL Processor

The XSL processors parses the XML source and tries to find out the matching template rule. If it do find it, then the instructions inside the matching template are been evaluated.

Contents of the original elements can be recovered from a original sources in two basic ways. A Stylesheet 1 uses the xsl:value-of a construct. In this case contents of the element is been used without any further processing. Construct an xsl:apply-templates in the Stylesheet 2 is different. The parser further processes the selected elements, for which the template is been defined..



XSL stylesheet 1

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="employee">
<B><xsl:value-of select="."/></B>
</xsl:template>
<xsl:template match="surname">
<i><xsl:value-of select="."/></i>
</xsl:template>
</xsl:stylesheet>


XSL stylesheet 2

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >

<xsl:template match="employee">
<B><xsl:apply-templates select="firstName"/></B>
<B><xsl:apply-templates select="surname"/></B>
</xsl:template>

<xsl:template match="surname">
<i> <xsl:value-of select="."/></i>
</xsl:template>
</xsl:stylesheet>