XSLT è una tecnologia utilizzata per trasformare documenti XML in diversi formati. Esistono tre versioni: 1, 2 e 3, con la versione 1 che è la più comunemente utilizzata. Il processo di trasformazione può essere eseguito sia sul server che all'interno del browser.
I framework più frequentemente utilizzati includono:
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:templatematch="/"><html><body><h2>The Super title</h2><tableborder="1"><trbgcolor="#9acd32"><th>Title</th><th>artist</th></tr><tr><td><xsl:value-ofselect="catalog/cd/title"/></td><td><xsl:value-ofselect="catalog/cd/artist"/></td></tr></table></body></html></xsl:template></xsl:stylesheet>
Esegui:
saxonb-xslt -xsl:xsl.xsl xml.xmlWarning: at xsl:stylesheet on line 2 column 80 of xsl.xsl:Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor<html><body><h2>The Super title</h2><tableborder="1"><trbgcolor="#9acd32"><th>Title</th><th>artist</th></tr><tr><td>CD Title</td><td>The artist</td></tr></table></body></html>
$saxonb-xslt -xsl:detection.xsl xml.xmlWarning: at xsl:stylesheet on line 2 column 80 of detection.xsl:Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor<h2>XSLT identification</h2><b>Version:</b>2.0<br><b>Vendor:</b>SAXON 9.1.0.8 from Saxonica<br><b>Vendor URL:</b>http://www.saxonica.com/<br>
$ saxonb-xslt -xsl:read.xsl xml.xmlWarning: at xsl:stylesheet on line 1 column 111 of read.xsl:Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor<?xml version="1.0" encoding="UTF-8"?>root:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:php="http://php.net/xsl" ><xsl:templatematch="/"><xsl:result-documenthref="local_file.txt"><xsl:text>Write Local File</xsl:text></xsl:result-document></xsl:template></xsl:stylesheet>
Estensione Xalan-J
<xsl:templatematch="/"><redirect:openfile="local_file.txt"/><redirect:writefile="local_file.txt"/> Write Local File</redirect:write><redirect:closefile="loxal_file.txt"/></xsl:template>
La seguente funzione chiamerà il metodo statico stringToUrl della classe XSL:
<!--- More complex test to call php class function--><xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:php="http://php.net/xsl"version="1.0"><xsl:outputmethod="html"version="XHTML 1.0"encoding="UTF-8"indent="yes" /><xsl:templatematch="root"><html><!-- We use the php suffix to call the static class function stringToUrl() --><xsl:value-ofselect="php:function('XSL::stringToUrl','une_superstring-àÔ|modifier')" /><!-- Output: 'une_superstring ao modifier' --></html></xsl:template></xsl:stylesheet>