XSL

The majority of XML is structured around how data is stored. It does not concern itself with presentation. This is where the Extensible Stylesheet Language (XSL) comes in. XSL has a similar functionality to XQuery. However XSL is much older than XQuery. It allows you to transform XML to a presentation format such as HTML.

There are two places you can perform an XSL transformation. It can be done on the server with the resulting output such as HTML being piped to the client. Or you can send both the XML and XSL data for the client to do the transformation. It is recommend that the server do this. You cannot always guarantee that a client Web browser has the capability to do the transformation.

The transformation makes use of an XSL stylesheet. The default behavior of an empty stylesheet is to traverse the children of an XML data tree and print the PCDATA elements. However you normally add template matches to the stylesheet in XPath format. When such a match is made, the code in that template block is executed and the traversal normally stops. You can issues an apply-templates command in this block. That causes XSL to continue processing the templates you instruct it to (with the default being all children elements in the tree).

Here are a couple closing ideas on this brief intro to XSL. The XSL templates are never nested. And their order in the XSL file is not important. Execution is determined by the order of nodes in the XML tree, and the XPath information in the templates. Tomorrow we are going to learn how to use XSL formatting objects to turn XML into a PDF file. There is also another 3 day long class on the topic of XSL transformations by itself. So you know it is a huge topic that I cannot even start to cover here. I just wanted to share what little bit I have learned. I can't wait to get back to work and put some of this XML knowledge into action.