Transformation Process

In the domain of XSLT, the stylesheet contains a number of templates expressed as an <xsl:template> element with a match attribute. The value of the match attribute is a pattern, and the pattern determines which nodes in the source tree the template rule matches. For example:

 <xsl:template match="/"> 

Several events occur during a typical transformation. When an XSLT transformation is executed, a stylesheet is applied to evaluate and process a source document. As we discussed earlier in this chapter, the first event to take place is the remapping of the document to a tree that is contained in memory. This prepares the schema and content for the transformation process.

The next step is to find a template rule that matches the root node of the source tree. Then the XSLT processor initiates the contents of the template rule, which, within the stylesheet, is a sequence of elements and text nodes.

For example:

 <xsl:stylesheet id = id extension-element-prefixes = tokens exclude-result-prefixes = tokens version = number> <!  Content: (xsl:import*, top-level-elements)  > </xsl:stylesheet> <xsl:transform id = id extension-element-prefixes = tokens exclude-result-prefixes = tokens version = number> <!  Content: (xsl:import*, top-level-elements)  > </xsl:transform>[2] 

[2] W3CXSLT Specification; www.w3c.org.

A template rule has the following two parts:

  • A pattern that is matched against nodes in the source tree, and a template that can be initiated to form part of the result tree.

  • A template that is initiated for a particular source element to create part of the result tree.

A template can contain elements that specify literal result-element structure. A template can also contain elements from the XSLT namespace that are instructions for creating result-tree fragments. When a template is initiated, each instruction is executed and replaced by the result-tree fragment that it creates. Instructions can select and process descendant source elements. Processing a descendant element creates a result-tree fragment by finding the applicable template rule and instantiating its template. Note that elements are processed only when they have been selected by the execution of an instruction. The result tree is constructed by finding the template rule for the root node and initiating its template.



Next Generation Application Integration(c) From Simple Information to Web Services
Next Generation Application Integration: From Simple Information to Web Services
ISBN: 0201844567
EAN: 2147483647
Year: 2005
Pages: 220

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