How a Stylesheet Is Processed
Now that we’re giddy with the excitement of having transformed an XML document, let’s discuss the stylesheet and how it works. A big part of the XSLT learning curve is figuring out how stylesheets are processed. To make this clear, we’ll go through the steps taken by the stylesheet processor to create the HTML document we want.
Parsing the Stylesheet
Before the XSLT processor can process your stylesheet, it has to read it. Conceptually, it doesn’t matter how the XSLT processor stores the information from your stylesheet. For our purposes, we’ll just assume that the XSLT processor can magically find anything it needs in our stylesheet. (If you really must know, Xalan uses an optimized table structure to represent the stylesheet; other processors may use that approach or something else.)
Our stylesheet contains three items: an <xsl:output>
element that specifies HTML as the output format and two <xsl:template>
elements that specify how parts of our XML document should be transformed.
Parsing the Transformee
Now that the XSLT processor has processed the stylesheet, it needs to read the document it’s supposed to transform. The XSLT processor builds a tree view from the XML source. This tree view is what we’ll keep in mind when we build our stylesheets.
Lather, Rinse, Repeat
Finally, we’re ready to begin the actual work of transforming the XML document. The XSLT processor may set some properties based on your stylesheet (in the previous example, it would ...
Get XSLT now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.