Transforms an XML document using the given XSL Stylesheet
<CF_XMLTransform XMLDATASOURCE ="datasource_name"
XSLSTYLESHEET = "stylesheet_name"
PARAMETERS="parameter_structure"
VARIABLE="return_variable_name">
Required. The XMLDatasource object containing the XML document to be transformed.
Required. The XSLStyleSheet object, containing the XSL transformation document.
Optional. A structure containing the values to be passed in as parameters to the XSLStyleSheet object, during the transformation.
Optional. The name of the variable that will contain the transformed content. If this variable isn't specified, the transformed content is written directly to the output.
In order to use this tag, you must have previously created an XMLDatasource and an XSLStyleSheet object. The XSLStyleSheet tag creates a pre-compiled stylesheet, however, the stylesheet can be changed using XSL parameters, such as :
<xsl:param name="department">Administration</xsl:param>
These parameters can be passed into the transformation tag via the Parameters attribute. This attribute takes a structure, the keys of which are the names of the parameters, with the values being the parameter value.
The tag also has two modes, it can either return the transformed content back to the calling template, using the variable attribute, or if this attribute isn't specified, it writes the transformed content straight to the output.
<!--- Create a simple cached Datasource --->
<CF_XMLDatasource name="People" CachedWithin="#createtimespan(0,0,5,0)#" cachename="People">
<people>
<person age="27" company="Torchbox">Tom Dyson</person>
<person age="27" company="WildFusion">David Maddison</person>
<person age="23" company="WildFusion">Peter Piper</person>
<person age="29" company="Torchbox">olly</person>
</people>
</CF_XMLDatasource>
<!--- Create a simple cached XSL StyleSheet --->
<CF_XSLStyleSheet Name="XSLPeople" CachedWithin="#createtimespan(0,0,10,0)#" cachename="XSLPeople">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="company">Torchbox</xsl:param>
<xsl:template match="/">
<xsl:apply-templates select="//person[@company=$company]"/>
</xsl:template>
<xsl:template match="person">
<b><xsl:value-of select="."/></b> (<xsl:value-of select="@age"/>)<br/>
</xsl:template>
</xsl:stylesheet>
</CF_XSLStyleSheet>
<CFPARAM Name="FORM.Company" Default="Torchbox">
<!--- Display a quick form --->
<FORM method="post">
<select name="company" onchange="form.submit()">
<CFOUTPUT>
<option value="WildFusion" #iif(form.company EQ "WildFusion","'SELECTED'","''")#>WildFusion</option>
<option value="Torchbox" #iif(form.company EQ "Torchbox","'SELECTED'","''")#>Torchbox</option>
</CFOUTPUT>
</select>
</form>
<!--- Create the parameter list ---> <CFSET stParams = StructNew()> <CFSET stParams.company = FORM.Company>
<!--- Transform the content and write straight out ---> <CF_XMLTransform XMLDatasource="People" XSLStyleSheet="XSLPeople" Parameters="#stParams#">
|
|
|
| Produced by Tom Dyson of Torchbox, and David Maddison of Wildfusion | |