XSL: Presenting XML Data

 
xslt for dummies
Chapter 1 - Introducing the X-Team
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

Time to pass the baton to the second member of the X-Team: Extensible Stylesheet Language (XSL). XSL is charged with styling or laying out XML documents into a form that makes sense to its intended audience. As shown in Figure 1-2, you use XSL to define a set of formatting rules that are referred to when an XML document is processed .


Figure 1-2: Using XSL to apply formatting to XML documents.

For example, if I want to format the letter from the preceding XML to the rescue section, I use XSL to create a few rules, such as

  • When a < date > element is found, italicize the dates text.

  • When a < salutation > element is found, indent salutations text.

  • When a < closing > element is found, add an extra line after it.

XSL rules like these are contained in an XSL Stylesheet , which is just a plain text file filled with formatting instructions that look like the following example.

 <fo:page-sequence master-name="easy"> <fo:flow flow-name="xsl-region-body"> <fo:block font-family="Serif">Serif font</fo:block> </fo:flow> </fo:page-sequence> 

Note that this XSL is written in something that resembles XML. That is more than mere coincidence because, ironically, XSL is actually written in XML and is itself an XML vocabulary.

If your head is spinning around, hang on. XSL is used to format XML, which in turn is used as the language for defining XSL. The circular logic can be confusing, but fortunately, you dont need to worry about the particulars of how that all worksjust know that it does. Actually, the fact that XSL uses XML to describe its instructions makes it far easier to learn than trying to grasp yet another language syntax.

When XSL was conceived by the W3C, the original intention of XSL was simply to provide a way to format XML data. However, after people began to use XML in the real world, it was discovered that something more was needed besides assigning font colors and margin indentions to the content. True, developers needed to be able to style XML in a way that was easily readable, but they also discovered a need to change an XML document from one XML structure to another, as well as to have the ability to easily convert XML into HTML and other output options. Taking up this charge, the W3C expanded the scope of XSL to support transforming, and in doing so, gave birth to XSL Transformations (XSLT).

  
 
 
2000-2002    Feedback


XSLT For Dummies
XSLT for Dummies
ISBN: 0764536516
EAN: 2147483647
Year: 2002
Pages: 148

Similar book on Amazon

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