Using XSL


XSL, the "eXtensible Style sheet Language," is so called because it is designed specifically for XML, the "eXtensible Markup Language."

The XSL language is itself based on XML, which means it looks very different from CSS. Ease of reading and writing isn't as important for XSL as it is for CSS. Writing XSL requires more training than writing CSS.

XSL has two parts: transformation and formatting. The transformation can be used on its own to translate XML documents to other XML documents, or to a limited extent to other types of text-based formats. It can also be combined with formatting to transform an XML document to a document with "formatting objects," which is just another XML document, but one in which all elements have a full set of CSS properties. You can think of the formatting process performed by XSL as a transformation of an XML document to an HTML document in which all elements have a STYLE attribute with the properties that apply to that element.

An XSL script contains a series of template rules, each of which contains a pattern similar to a CSS selector and a piece of text, representing how to rewrite a matching piece of the input document. An XSL interpreter tries to match all patterns and thereby replaces parts of the XML document with new text until no more templates match.

XSL is meant to be used for tasks such as sorting parts of a document, generating a table of content, generating a report for an XML-based database, and other tasks related to formatting documents. The focus is on printed output. Much of XSL processing is expected to be invisible to users: A server might use an XSL script to create an HTML document dynamically from a large database of XML documents.

But, XSL could also be used in browsers as an alternative to CSS for documents that need to be re-ordered before they can be displayed to a reader.

XSL is currently mostly used to transform documents before sending them to a browser, but it is possible that more browsers will support XSL in the future, and it becomes possible to send XSL to the browser the same way you can send a CSS.

In many cases, XSL will be used to condense a large document or set of documents into one or more small Web pages. In that case, the logical place is near the server because it would be wasteful (and time-consuming) to send the large document plus XSL script to a browser, when the user eventually only sees a small part of it. But, if XSL is used to expand a compact piece of machine data into a human-readable description of the data, sending the compact document and the XSL script to a browser for processing makes sense.

Although XSL looks different from CSS no semicolons (;), no curly braces ({...}), no colons (:), etc. when XSL is used for formatting, it won't be difficult to recognize the CSS properties. Nearly all CSS properties are available with the same names and values as in CSS.



Cascading Style Sheets(c) Designing for the Web
Cascading Style Sheets: Designing for the Web (3rd Edition)
ISBN: 0321193121
EAN: 2147483647
Year: 2003
Pages: 215

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