In order to write XSLT code, you should have a basic understanding of HTML/XHTML, XML, XML Namespaces, XPath and XSL. XSLT is a style sheet that transforms XML into a new structure for use with various Internet parsers. The advancement of technology brought many different venues. The modern day Internet user has more opportunities than ever to surf the web, such as mobile phones, iPod, Xbox and various other devices all with distinctive browser systems. XSL Transformations (XSLT) takes well-formed XML code and transforms it into a useable format for these applications.
Beginning an XSLT Transformation
XSLT is part of an XSL style sheet. Since a style sheet uses XML syntax, you begin with an XML declaration statement.
<?xml version= "1.0" ?>- XML declaration
Add an XSL statement.
<xsl:stylesheet version= "1.0"- style sheet declaration
Define the XSLT namespace as part of the style sheet declaration.
<xsl:stylesheet version= "1.0"
XSLT compares the code to a template to determine how to transform the XML. A template is a set of rules established for the style sheet. The template element uses XPath to match or associate the code. Matching may specify a child element or the entire XML document.
<xsl:template match=" / ">- designates the entire document
<xsl:template match= "child::elementname">- this designates a child element in the document.
For example, if you have a child element called
<bat> the matching code would be:
When creating XSLT, you build an output stream that is stylized and viewed on an Internet page. XSLT incorporates a number of XSL elements to define this transformation process. The next few articles will examine XSL elements used for XSLT transformations and further break down XSLT coding.