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"/></NM>
					</PERSON>
</xsl:template>

The result would be as follows:

<PERSON><NUM>123</NUM><NM>J Smith</NM></PERSON>

In this context, the name 'stylesheet' is a little misleading, as no actual styling is involved in the process. In fact, the name of the standard itself is equally misleading, as it incorrectly implies that XSLT can only be used to transform documents into the XSL format, when it can do so much more.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset