xsl
[xsl] enables the application of style sheets to XML data, which allows the querying and rendering of the XML data as html. Use of the [xsl] context requires familiarity with the XPath and XSLT languages. XSLT is a language for transforming XML documents into other XML documents. XPath is a language for defining parts of an XML document.
Parameters
Parameter | Description |
---|---|
name | The variable name used to represent the XSL parsed object. |
source | A URL reference to an external XSL file. If 'source' is provided, the content within the [xsl] context is ignored. |
These new contexts enable the WebDNA programmer to compile and apply XSL style sheets to XML data, allowing the programmer to query and render XML data as they see fit.
Example WebDNA code:
The [xsl] styles can also be called from a file.
Example WebDNA code:
This example uses an example file that you can view/download here example-xml-styles.xsl
Example WebDNA code:
[xsl var=xsl_var1]
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
[/xsl]
Results: WebDNA 'saves' this compiled instance as an internal variable in memory named 'xsl_var1'. This saved instance can then be referenced when using the [xslt] context on the same page.The [xsl] styles can also be called from a file.
Example WebDNA code:
This example uses an example file that you can view/download here example-xml-styles.xsl
[xsl var=xsl_var1][include file=example-xml-styles.xsl][/xsl]