XSLT is a set of instructions to transform an xml file into something else (most often html) XML is a fancy way of describing a text document that stores data in structured fashion HTML is the most common way of formatting a document to present data (for web browsers)
example source XML file
Since an XSL style sheet is an XML document itself it always begins with the XML declaration:
then we indicate that this document is of type XSL (and where to understand what XSL is defined -> which means going onto that website!)
Thus a very simple example would be:
<xsl:template match="/">
<xsl:value-of select="catalog/cd/title"/>
</xsl:template>
AND THE RESULT IS:
Empire Burlesque
only one item because we have not done any looping or logic, just displaying one item... (Note the value-of select gives a path that is forward slash '/' delimited)
IF WE MODIFY IT A LITTLE BIT TO INCLUDE A for-each LOOP...
AND THE RESULT IS:
Empire Burlesque - Bob Dylan Hide your heart - Dolly Parton Greatest Hits - Dolly Parton Still got the blues - Gary Moore
NEXT WE HAVE MORE ADVANCED FORMATTING
<xsl:attribute name="title">
<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:text> *-* </xsl:text>
<xsl:attribute name="artist">
<xsl:value-of select="artist"/>
</xsl:attribute>
<br />
In this particular case we are trying to create an XML document from a RSS feed The "indent" means the output XML will have indentation, I'm not sure about the omit-xml... http://www.w3schools.com/xsl/el_output.asp
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
I believe this starts at the "root" of the XML document and then finds the first rss/channel, It then makes a "div" out of each channel
It then labels the feed with the name & link & description and then gets the next "item"
ABOVE you can see how it creates an unnumbered list from each Item
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<li>
<a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a>
</li>
XML link: http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=GBP&ToCurrency=USD
THE "source" RSS FEED DATA (which could be pulled regularly?)
http://coinmill.com/
1.00 USD = 0.71 GBP
Converter --
Rate Chart
]]>
THE WHOLE XSL EXAMPLE THAT TURNS AN XML INTO A BULLET LIST OF LINKS
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<ul><xsl:apply-templates select="item"/></ul>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<li>
<a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a>
</li>
</xsl:template>
//defines the root of the template
//to make things easy on ourselves
The xsl:variable instruction creates a variable. NAME attribute identifies the variable's name The value can be specified either as the xsl:variable element's contents (e.g. variableValue) or as the value of an optional select attribute in the xsl:variable element's start-tag.
ALSO you see that the variable select can call a function...
VARIABLES!!!!!!!!!! http://www.xml.com/pub/a/2001/02/07/trxml9.html
//or it could be something specific, note that the html is mixed with XSL to produce formatting
DEDUPLICATION
http://www.dpawson.co.uk/xsl/sect2/N2696.html#d3983e16