XML

Summary

Although XSLT style sheets can be used in conjunction with CSS to perform basic XML document formatting, the real power of XSLT is revealed when you actually manipulate the content of a document in order to facilitate a more meaningful presentation. Fortunately, XSLT includes rich features for carrying out a variety of different transformation tasks. Some of the XSLT features that make it so flexible are patterns and expressions, along with the ability to use them to process and sort nodes. Of course, at the core of every XSLT style sheet is a set of templates that are used to transform different parts of XML documents.

This tutorial taught you a great deal about templates and how they are created and applied in XSLT style sheets. You also learned how to process and sort nodes, not to mention how to use patterns and expressions. The tutorial culminated in a couple of complete XSLT example style sheets, which hopefully gave you some practical knowledge that can help you get started on your own XSLT projects.

Q&A

Are there any limitations regarding the use of literals in an XSLT style sheet?

Yes. Because XSLT style sheets are coded in XML, everything in them must adhere to the syntax rules of XML. This applies to literals as well, which means that tags must be nested properly, start tags must have end tags, and so on.

What happens to nodes in an XML document that aren't matched by a template in an XSLT style sheet?

If nodes in a document aren't matched by a template in an XSLT style sheet, those nodes aren't processed or transformed. Keep in mind that it isn't necessary for a style sheet to address every single piece of information in an XML document; it's perfectly acceptable to pick out highly specific information from a document if so desired. The degree to which document content is processed is entirely dependent on each specific application of XSLT.

Are there any other functions I can use with XSLT beyond the standard functions mentioned in this tutorial?

Yes. There are several other standard XSLT functions that weren't covered in this tutorial; you can learn more about them by visiting the XSLT page at the W3C web site, which is located at http://www.w3.org/TR/xslt. Additionally, XSLT supports the inclusion of extended functions in different implementations of XSLT. For example, a web browser vendor could add browser-specific functions to their implementation of XSLT. You'll have to check with the specific browser you are targeting to see if extended XSLT functions are supported.

In regard to an XSLT style sheet, what happens if a document doesn't validate against a DTD/XSD schema?

If a document doesn't validate against a provided schema, a web browser will still apply the style sheet and display the document. However, if the document isn't well formed, the style sheet is never processed and the document isn't displayed.

by BrainBellupdated
Advertisement: