XML transformation output

The XSLT processor does not have to produce an XML document that conforms to the Formatting Object namespace, or to any other formatting language. The output can instead be another XML document. The pattern-matching and resequencing capabilities described in later chapters can be used to manipulate the document into other forms, perhaps omitting or repositioning information. In the following source document, the name precedes the telephone number:

<employee>
  <name>J Smith</name>
  <number>123</number>
</employee>

A single template can rearrange the embedded elements and give the elements new names:

<xsl:template match="employee">
  <PERSON>
					<NUM><xsl:apply-templates select="number"/></NUM>
					<NM><xsl:apply-templates select="name"/> ...

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.