Section 18.2.  XSLT stylesheets

Prev don't be afraid of buying books Next

18.2. XSLT stylesheets

Most XSLT looks more or less like ordinary XML. Simple XSLT stylesheets are merely a specialized form of XML markup designed for specifying the transformation of other XML documents. You can think of XSLT as just another document type.

A stylesheet that transforms a document into another XML document might have a root element that looks like Example 18-1.

Example 18-1. XSLT stylesheet using XML output elements
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                 version="1.0"> <xsl:output method="xml"/>     <!-- template rules go here --> </xsl:stylesheet> 

The root element is xsl:stylesheet.[2] It must have a namespace declaration for XSLT. It makes sense to use the same declaration and xsl: prefix every time. You can also specify the output method to be used by the processor, choosing between XML, HTML and plain text.

[2] The space also allows the root element to be called xsl:transform, presumably for the benefit of people with no style sense!

The xsl:stylesheet element is usually filled with template rules. The template rules describe how to transform elements in the source document. Of course almost every element type could be processed differently from every other element type so there are many rules in an XSLT stylesheet. Particular elements could even be processed differently if they share a type but have different attributes or occur in a different context.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net