The Composition of XSL


XSL is a W3C standard developed to allow for the application of stylesheets to XML data. There are three parts to XSL as shown in Figure 4-1.

image from book
Figure 4-1

Some consider XSL to be composed of only XSLT and XSL-FO but XPath was also required to satisfy the requirements of a transformation and formatting standard. The list that follows gives a short explanation of each of the components.

  • q Transformation (XSLT)-Applying transformations to XML data. This can be used to create other data formats, sort existing data, or query the XML data by selection.

  • q Formatting (XSL(-FO))-The main subject of this chapter, it allows, the formatting of XML data using defined structures.

  • q Selection (XPath)-XPath provides the capability to address sections of the XML document tree.

Transformation is by far the most well-known of the XSL components and inherently utilizes XPath to select the XML data to transform. Both these topics are covered in detail in chapters 9 & 10 but I also use them in an example later in the chapter. Also, XSLT is commonly the first step in producing an XML structure capable of being used with XSL-FO to produce formatted output.

Important 

The full specification for XSL can be found on the W3C site http://www.w3.org/TR/xsl/. This is a full technical specification that is targeted at developers of processing engines and can be used as a developer's reference. It is most certainly not a tutorial! The site is however very useful as a reference and does explain some of the aims and benefits of the specification.

Some of the potential uses for XSL are shown in Figure 4-2.

image from book
Figure 4-2

In the preceding example, the application extracts data from a data source such as a database, text file or another XML data source. The XSLT transforms the source to a defined XML tree structure in preparation for applying further transformations to the data. Depending on the desired destination, you can apply a stylesheet to the data to produce the appropriate output.

In the previous example, the application applies XSLT to the source, selecting appropriate data to be output within HTML tags. An XSL-FO stylesheet is applied to the source defining the pagination and format of the data to be output in Adobe PDF format. The final transformation performs an XML-to-XML transform to produce a SOAP packet.

You work through an example like this later in the chapter. First, however, you go through the basics of XSL-FO.




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

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