Defining Stylesheets
If you are familiar with the Cascading Style Sheets (CSS) specification often used on the Web, you are probably aware that CSS stylesheets can be stored in a separate file, or embedded as a special element within an HTML document. Also, specific styling information can be attached to individual attributes within the document. In this section, we examine the corresponding approaches to using XSLT.
Each of the three ways of using CSS have an analogous technique using XSLT, but the XSLT stylesheets are substantially more powerful. While this discussion refers to some specific XSLT elements and shows several in the examples, it does not expect that you know anything about them. These elements are described in more detail later in this chapter; this section simply introduces you to the ways stylesheets can be written and how that relates to the documents being processed.
Simplified Stylesheets
Simplified stylesheets are more like using the STYLE attribute in HTML
documents than anything else, but the similarity is minimal. This
approach is somewhat less powerful than using embedded or standalone
stylesheets; the xsl:stylesheet
element is not allowed since the entire stylesheet is interpreted as
the body of an xsl:template
element. Many features of XSLT require using additional “top-level”
elements (peers of the xsl:template
element), so they are not allowed in this context. This kind of stylesheet is more difficult to use when the basic structure of the source document ...
Get Python & XML 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.