Overall XSLT stylesheet structure

Here is the overall structure of an XSLT stylesheet:

<xsl:stylesheet ...>
  top-level-only elements

The root element must be either xsl:stylesheet or xsl:transform; they are equivalent.

There are certain elements called top-level-only elements that must be just inside the root element. These are discussed below in the section on top-level elements.

The rest of the stylesheet consists of any mixture of these elements:

    Basic template elements are for defining templates and creating modular pieces of templates.

    Output elements are used to write things to the output.

    There are several branching elements that provide iteration and optional content.

    See the section on advanced elements for additional useful features.