How do I perform an XSLT transform?
Here's a simple example of transforming an XML file using an XSLT stylesheet that are both located in the same directory as the running ColdFusion script:
<cffile action="read" file="#expandPath('transform.xsl')#" variable="xmltrans">
<cfoutput>#xmlTransform(xmldoc, xmltrans)#</cfoutput>
This question was written by Bif.
It was last updated on June 13, 2006 at 1:33:21 PM EDT.
CFML Referenced
Categories
Comments
Comment made by Rob Wilkerson on June 14, 2006 at 8:46 AM
You can also pass parameters to your XSLT file:
<cfset variables.XSLParams = structNew() /> <cfset variables.XSLParams['param1'] = 'value1' /> <cfset variables.XSLParams['param2'] = 'value2' /> <cfset variables.XSLParams['param3'] = 'value3' />
<cfoutput>#XMLTransform ( xmldoc, xmltrans, variables.XSLParams )#</cfoutput>
Comment made by Rob Wilkerson on June 14, 2006 at 8:49 AM
Be careful when passing parameters to your XSLT file, though. There is a ColdFusion issue that makes it important which structure notation is used. Dot notation, for whatever reason, does not seem to work. StructInsert() and the associative array notation show in my previous comment do work, however.