The visual presentation of a TEI encoded document requires the use of a style sheet or other conversion program. The extensible Stylesheet Language for Transformations (XSLT) was developed to transform XML (Extensible Markup Language) encoded documents into new forms. It is through the transformative capabilities of an XSLT stylesheet that XML documents can achieve their greatest potential.
Presenting XML with XSLT
An XML encoded document by itself is merely a data storage medium that is not intended for direct use. XML describes the document in just as little or much detail as needed, and a document in XML should only need to be encoded one time. Subsequent changes to the document should be accomplished with stylesheets. Simply put, XML tells the document what it is, but not what to do, while stylesheets contain instructions about how the XML document should be organized for display.
XSLT and XML
XSLT stylesheets tell the XML document how to function. They permit one to change the structure and appearance of XML data without the need for changing the XML encoding itself. XML documents can be radically altered for different purposes by changing the XSLT stylesheet or stylesheets — many of them can be attached to one XML document at once. They can also add new content to the original XML source document. XSLT stylesheets can complement CSS (Cascading Style Sheets).
Stylesheets permit the markup language to be suppressed from public view. With a stylesheet it is possible to view formatted text without viewing the XML encoding tags.
XSLT rules are similar to XML rules. XSLT stylesheets must themselves be well-formed XML documents, meaning that tags must be closed, case matters, etc.
The creation of XSLT stylsheets operates on the principle of "templates". Using a template the designer describes by example, or "matches", the sections of the XML document that are to be displayed and transformed.
XSLT Basic Steps
1. Identify root element
2. Enter the XSLT version number:
3. Enter the latest XSLT namespace:
XSLT Template Example
This is a simplified example of an XSLT template that is used to convert an XML file into an HTML file.
XSLT documents refer to a "namespace" which specifies the version of the XSLT rules to which the stylesheet conforms. The latest version of the XSLT namespace is:
An older version of the rules, now outdated, is:
XSLT stylesheets use another XML standard, Xpath, to describe the exact location of the source document that is to be displayed. Xpath is based on the idea that XML content is arranged like a "document tree" where there is a single root element off of which exist a few, or many, other "nodes".