Someone posted a while ago about the MSXML XSLT processor object failing in
CF5. I've run into the same problem. Per someone's suggestion, I wrote a
simple wrapper object as a Windows Scripting Component. I'm no WSC guru, so
if someone sees something wrong, please share.... The WSC code is pasted in
below.
This wrapper was just meant to work around the XSLT Processor problem. It
just lets you apply a stylesheet to some content xml that you pass to it.
The component populates an "errorMessage" property for you to check from
within your CF code after various operations.
I don't like having to wrap functionality this way because it pushes the
problem into the "configuration space". That makes a system more susceptible
to failure and more difficult to manage. But, until Macromedia gets its sh*t
together and fixes their COM facilities, this will have to do.
Rob
Rob Blitz
Team Leader
Web Application Development Team
RWD Technologies, MIS
410.884.5063 (Office phone)
410.884.2749 (Office fax)
39:12:42.426N 76:51:42.808W (ICBM)
+++++++++++++ CUT HERE (save to a file called, "msxmlXSLTWrapper.wsc" or
something +++++++++++++++++
<?xml version="1.0"?>
<component>
<?component error="true" debug="false"?>
<registration
description="msxmlXSLTWrapper"
progid="msxmlXSLTWrapper.WSC"
version="1.00"
classid="{c686949d-f775-40d9-abd1-272b86dbc823}"
>
</registration>
<public>
<property name="contentXML">
<put internalName="loadContentXML"/>
</property>
<property name="errorMessage">
<get internalName="getErrorMessage"/>
</property>
<property name="stylesheet">
<put internalName="setStylesheet" />
</property>
<method name="applyTransform" />
<method name="addParameter">
<PARAMETER name="name"/>
<PARAMETER name="value"/>
<PARAMETER name="namespace"/>
</method>
</public>
<implements type="ASP" id="ASP"/>
<script language="JScript">
<![CDATA[
var description = new msxmlXSLTWrapper;
//object properties
var contentXML="";
var errorMessage="";
var stylesheet="";
//global private vars
function msxmlXSLTWrapper()
{
sourceDOM= new ActiveXObject("MSXML2.DOMDocument");
xslt= new ActiveXObject("msxml2.XSLTemplate");
xslDoc= new ActiveXObject("msxml2.FreeThreadedDOMDocument");
this.applyTransform = applyTransform;
this.addParameter = addParameter;
}
function loadContentXML(contentXML)
//accessor method of contentXML property
{
var pErr;
//load the source DOM object
sourceDOM.loadXML(contentXML);
pErr=sourceDOM.parseError;
if(pErr.errorCode != 0)
{
errorMessage="Parse error at line "+pErr.line+", position
"+pErr.filepos+": "+pErr.reason+"(error code"+pErr.errorCode+")";
}
}
function setStylesheet(stylesheet)
//accessor method of stylesheet property
{
var pErr;
xslDoc.async=false;
//load the stylesheet as a DOM doc
xslDoc.load(stylesheet);
//check for MSXML parse errors
pErr=xslDoc.parseError;
if(pErr.errorCode != 0)
{
errorMessage="Parse error at line "+pErr.line+", position
"+pErr.filepos+": "+pErr.reason+"(error code "+pErr.errorCode+")";
}
else
{
//set the XSL Template to the created stylesheet
xslt.stylesheet=xslDoc;
//create the XSLT processor
xslProc=xslt.createProcessor();
//assign the DOM to be transformed
xslProc.input=sourceDOM;
}
}
function addParameter(name,value,namespace)
{
xslProc.addParameter(name,value,namespace);
}
function applyTransform()
{
//apply the transformation
xslProc.transform();
return xslProc.output;
}
function getErrorMessage(){
return errorMessage;
}
]]>
</script>
</component>
-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml