XSL, XSLT
I wanted to do some experimenting with XSL (extensible styles sheets) and XSLT (XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML.) I did my initial hunt on the web and came across a pretty thorough tutorial on w3 schools. The most important sentence for newbies to XSLT is the statment “XSLT transforms an XML source-tree into an XML result-tree.”
XSLT is a way to format XML data into a template based format, not the way you would usually think of a style sheet. For my particular example I wanted to have a better way to format my audio discography. The first step I did was to range all of the data in a logical format in a XML doc. That can be viewed here.
The finished formatted XML with XSL can be viewed here. (with the exception of Safari, it has a known issue with XSL and it has to be parsed for it to be read correctly)
I wanted to parse this out into a HTML doc to fix the Safari issue and so it could be presented along with some addition hard coded video pieces and some other layout constraints I had with WordPress.
This was easily handled by a simple PHP script…
<?php
$xslDoc = new DOMDocument();
$xslDoc->load("disco.xsl");
$xmlDoc = new DOMDocument();
$xmlDoc->load("disco.xml");
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
echo $proc->transformToXML($xmlDoc);
?>
And the finished product.
I’m going to go more in depth on XPATH selectors, another part of XSL in another post.
~ H
No comments yet.