This is the XSLT tag I wrote for the MS IIS platform and that I use, I am
sure there is room for improvement.

<cfobject type="COM" name="objXMLdoc" class="microsoft.xmldom"
action="CREATE">  
<cfobject type="COM" name="objXSLdoc" class="microsoft.xmldom"
action="CREATE"> 

<cfscript>
        Err = 0
        XMLdoc = attributes.xml;
        XSLdoc = attributes.xsl;
        objXMLdoc.ValidateOnParse = -1; 
        objXSLdoc.ValidateOnParse = -1; 
        objXMLdoc.load(XMLdoc);
        If (objXML.parseError.errorCode <> 0) 
                Err = 1;
        objXSLdoc.load(XSLdoc);
        If (objXSL.parseError.errorCode <> 0) 
                Err = Err + 2;
        
        switch(err)
        {
    case 0:
    {
        Caller.Results = objXMLdoc.transformNode(objXSLdoc); 
        break;
    }
    case 1:
    {
                a = objXML.parseError.errorCode;
                b = objXML.parseError.reason; 
        Caller.error = true;
                Caller.errorreason = "XML ERROR! Error Code " + a + "
Description " + b;
        break;
    }
    case 2:
    {
        Caller.error = true;
                a = objXML.parseError.errorCode;
                b = objXML.parseError.reason; 
        Caller.error = true;
                Caller.errorreason = "XSL ERROR! Error Code " + a + "
Description " + b;
        break;
    }
            
} //end switch
        
</cfscript>

This is the calling page

<CF_XSLT 
XML="c:\inetpub\wwwroot\OnlineSalesReporting\sample.xml"
XSL="c:\inetpub\wwwroot\OnlineSalesReporting\sample.xsl"
>

<cfoutput>#XSLTResults#</cfoutput>




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 09, 2000 1:36 PM
To: CF-Talk
Subject: RE: XML / XSL


Good grief!  That's a lot of errors!

It would be nice if there was a custom tag that did the following:

<CF_XSLPROCESS
        XML = "[path]myfile.xml"
        XSL = "[path]myfile.xsl"
        VAR = "nameOfCFVariableToStoreResultIn">

Then you could output the variable "nameOfCFVariableToStoreResultIn" to the
user's browser.

The Lotus version seems to be close to this but requires output to a file
which means doing a file write and then a read as well as a delete for
housekeeping purposes.  That's very inefficient for page processing.

Any suggestions?

--Doug

-----Original Message-----
From: David Gassner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 03, 2000 4:17 AM
To: [EMAIL PROTECTED]
Subject: RE: XML / XSL


To use Lotusxsl for transformations, the classpath in the CF Administrator
needs to include full paths to these files:
xalan.jar
Lotusxsl.jar

For instance:

c:\lotusxsl\lotusxsl.jar;c:\lotusxsl\xalan.jar

As Sean Renet pointed out awhile back, the KB article has some fatal errors.
Here are the fixes you need to apply to get it working:

1.  If you copy the example XSL file from the website, the <xsl:stylesheet>
tag's xmlns:xsl attribute value is broken into 2 lines, causing the xsl
processor to fail completely.  Instead of doing the transformation, it just
outputs the content of the original xsl file.  The namespace needs to be in
a continuous line, as follows:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

2.  The printWriter class isn't being closed, so the file containing the
wddx isn't being flushed to disk.  Add the following to the end of the code:

<cfset printWriter.close()>

3.  The resulting processed file isn't being read into a CF variable, so
add:

        <cffile action="read"
           file="[path]wddx_test.wddx"
           variable="wddx">

4.  When you try to run <cfwddx> to transform the wddx to a structure,
you'll get:

        Error Diagnostic Information
        unknown exception condition
        TagCFWddx::execute

There is an error in the XSL file.  The "item" element is being mapped to a
named structure.  Since it's a structure within an array, it can't take a
name, causing the WDDX parser to fail.  Here's the corrected XSL file:

************************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Match invoice root & emit WDDX packet wrapper -->
<xsl:template match="/invoice">
    <wddxPacket version="1.0">
        <header/>
        <data>
            <struct>
                <xsl:apply-templates/>
            </struct>
        </data>
    </wddxPacket>
</xsl:template>


<!-- Process all elements that map to array variables -->
<xsl:template match="billableHours">
    <var name="{name(.)}">
        <array length="{count(*)}">
            <xsl:apply-templates/>
        </array>
    </var>
</xsl:template>

<!-- Process all elements that map to struct variables -->
<xsl:template match="invoice|contractorInfo|address">
    <var name="{name(.)}">
        <struct>
            <xsl:apply-templates/>
        </struct>
    </var>
</xsl:template>


<!--- Process structures inside arrays (no names) - this is the fixed
structure --->
<xsl:template match="item">
        <struct>
            <xsl:apply-templates/>
        </struct>
</xsl:template>

<!-- Process all elements that map to string variables -->
<xsl:template
match="firstName|lastName|street|city|state|zip|country|voice|fax|email|
description|currency">
    <var name="{name(.)}">
        <string>
            <xsl:value-of select="text()"/>
        </string>
    </var>
</xsl:template>

<!-- Process all elements that map to number variables -->
<xsl:template match="invoiceID|employeeID|hours|amount">
    <var name="{name(.)}">
        <number>
            <xsl:value-of select="text()"/>
        </number>
    </var>
</xsl:template>

<!-- Process all elements that map to date-time variables -->
<xsl:template match="dateSubmitted|date">
    <var name="{name(.)}">
        <string>
            <xsl:value-of select="text()"/>
        </string>
    </var>
</xsl:template>

</xsl:stylesheet>


> -----Original Message-----
> From: dave fauth [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 02, 2000 5:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: XML / XSL
>
>
> Cary,
>
> It is an Allaire KB:
>
> http://www.allaire.com/handlers/index.cfm?ID=14244&Method=Full
>
> Also, you may want to check here:
>
> http://www.sys-con.com/xml/archives/0102/gassner/index.html
>
> dave
>
> At 08:28 AM 8/2/00 -0700, you wrote:
> >What KB article would that be?  I searched xml, xsl and lotus and found
> >nothing like what you mentioned.
> >
> >Cary
> >
> >At 09:13 AM 8/2/2000 -0400, you wrote:
> >>Doug,
> >>
> >>I'm just getting started in XML/XSL with CF.  I've looked at the KB
> >>article from Allaire on it and have downloaded the Lotus XML parser.
> >>
> >>One question I have is how the set the Class Path.  The Lotus parser
> >>documentation isn't really clear on it.  It seems like there is
> a place in
> >>the CF administrator but there must be another place to do it.
> Anybody's
> >>help would be appreciated.
> >>
> >>I'm looking to both read XML into WDDX and also convert WDDX
> into XML via
> XSL.
> >>
> >>What kind of things are you doing with XML?
> >>
> >>dave
> >
> >-----------------------------------------------------------------
> ----------
> ---
> >Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> >To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in
> the body.
> >
> >
> ---------------
> dave fauth
> [EMAIL PROTECTED]
>
> "The opinions expressed here
> are my own and not those of
> DOMAIN technologies, inc."
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to