XSL is for XML what CSS is for HTML. It stands for EXtensible Stylesheet Language. It is a language designed to present XML data in a readable format. XSL actually consists of two parts:
XSLT stands for XSL Transformations and is the most important part of XSL.
XSLT transforms an XML document into another XML document, into XHTML output, or into simple text. This is usually done by transforming each XML element into an HTML element. XSL is required because XML tags are user-defined, therefore browsers do not know how to interpret or render each tag. Their meaning is designed to be understood by humans, not machines.
XSLT can also perform the following operations on an XML tree:
If you need to review the XML syntax, read the XML Syntax section of my previous article on XML.
As you might recall from XML Overview article, all XML documents start with an XML declaration. The same is true for XSL style sheets. The first line of any XSL document is actually an XML declaration:
<?xml version="1.0" encoding="ISO-8859-1"?>
Yes and no. Yes, because they observe the same syntax rules (with a few differences, which I will talk about next). No, because they have different goals: XML carries data, XSL formats it.
After the XML declaration, there is an XSL declaration, such as:
<xsl:stylesheet>
or
<xsl:transform>
However, in most real-world cases, the XSL declaration looks a bit more complex:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
This is because it also includes the namespace and the version of the XSL specification, according to the recommendations of the W3 Consortium.
Unlike the XML declaration, which is written on a single line and has no closing tag, the XSL declaration must have a closing tag, which marks the end of the XSL stylesheet:
</xsl:stylesheet>
Notice how this does not violate the XML syntax rules: an XSL stylesheet is a perfectly valid XML document, since it has a single root element, specified by the <xsl:stylesheet> tag.
XSL was designed with a few goals in mind, which make it the perfect solution for some development cases, while rendering it totally useless for others.