CFLib.org – Common Function Library Project

XSLTCF5(Source, Style)

Last updated September 20, 2004

author

Joshua Miller

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
Returns the Transformed content of an XML document from a specified XSL document. This function uses the MSXML processor. (Tested on MSXML3+)

Return Values:
Returns the XML data with formatting.

Example:

<!---
<cfset sourceDoc="#GetDirectoryFromPath(GetCurrentTemplatePath())#cd_list.xml">
<cfset styleDoc="#GetDirectoryFromPath(GetCurrentTemplatePath())#cd_list.xsl">
<cfoutput>#xsltcf5(sourceDoc,styleDoc)#</cfoutput>
Commented out since the COM object has issues on this box.
--->

Parameters:

Name Description Required
Source XML Source Yes
Style XML Stylesheet Yes

Full UDF Source:

/**
 * Processes an XSL Template against an XML document and returns the transformed content.
 * 
 * @param Source 	 XML Source (Required)
 * @param Style 	 XML Stylesheet (Required)
 * @return Returns the XML data with formatting. 
 * @author Joshua Miller (josh@joshuasmiller.com) 
 * @version 1, September 20, 2004 
 */
function xsltcf5(source,style){
	// Instantiate COM Objects
	var objSource=CreateObject("COM", "Microsoft.XMLDOM", "INPROC");
	var objStyle=CreateObject("COM", "Microsoft.XMLDOM", "INPROC");
	var sourceReturn = "";
	var styleReturn = "";
	var styleRoot = "";
	var xsloutput = "";
	// Parse XML
	objSource.async = "false";
	sourceReturn = objSource.load("#source#");
	// Parse XSL
	objStyle.async = "false";
	styleReturn = objStyle.load("#style#");
	// Transform Document 
	styleRoot = objStyle.documentElement;
	xsloutput = objSource.transformNode(styleRoot);
	// Output Results
	return xsloutput;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson