XSLT Elements

Much of XSLT’s functionality is exercised in the form of elements that perform functions and tasks. In fact, the whole language is XML-based and describing its features is already the subject of several books. This section presents some of the XSLT elements and fundamentals so you can begin using it in your daily work.

The Stylesheet Element

The xsl:stylesheet element is always the root element of standalone stylesheets, and is also used for embedded stylesheets. The stylesheet element contains some optional and mandatory attributes that provide more details about the stylesheet to the XSLT processor. The specification defines a second root element in the XSLT namespace, called xsl:transform. This element is identical to xsl:stylesheet in every way but name, and can be used in place of xsl:stylesheet with no change in meaning.

The id attribute is optional. However, an identifier would certainly come in handy if this stylesheet were part of a larger XML document (as would be the case for an embedded stylesheet). The XML specification states that any attribute of type ID (not necessarily named id, but of the data type ID declared in the DTD) must be unique within any XML document. Use of an ID attribute on a stylesheet is powerful if you are dynamically generating several stylesheets collected together in a larger composite document.

The version attribute is required as it indicates which version of XSLT is being used. All xsl:stylesheet elements must have the version ...

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.