Elements

The Element element is used to generate element tags. The name of the element to output is specified in the Name attribute:

<element
					name="OL">
  ...
  <!-- CONTENT OF OL ELEMENT -->
  ...
</element>


  <OL>...</OL>

At first sight, this appears to be a less elegant alternative to simply embedding output elements within the stylesheet. Indeed, most people would agree that the stylesheet is less readable when using it. This can be demonstrated by the following examples, which are functionally identical:

 <xsl:template match="book"> <DOC> <TITLE>Test</TITLE> <MAIN> <xsl:apply-templates/> </MAIN> </DOC> </xsl:template> <template match="book"> <element name="DOC"> <element name="TITLE">Test</element> <element name="MAIN"> <apply-templates/> </element> ...

Get XSL companion, The 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.