I've done a little further research on my problem, and if you will bear
with me asking the question again, I'd like to add some facts to my earlier
question.

For those of you who haven't seen the earlier message, let me recap.

I need to port a JavaScript to Perl. The script uses XSLT to transform
an XML document to XHTML. I have used the method you will see in the
attached files rather than the .transformNode() function of the DOMDocument
object because I need to be able to pass one or more parameters to the
transform which the DOMDocument.transformNode (that's DOMDocument->transformNode
in Perl) does not support.

As I say, I have attached two scripts. Franternal twins, one in JavaScript
which works like a champ, and one in Perl which fails. The point at which
the Perl fails is where I assign a value to the "input" property of the
instance of the "Msxml2.XSLTemplate.4.0" object.

According to the Microsoft SDK documentation, on assigning a value to
this property, the "Msxml2.XSLTemplate.4.0" property "readyState" should
change to a value of "2", meaning it is ready to transform.

If you run each of these functions (the JavaScript can be run from the
command line using cscript.exe), when you inspect "readyState" just before
the transform, you will indeed see that "readyState" has a value of "2".

If you run the Perl script, you will see that at that same point, the
value is "0", meaning that nothing has been assigned to the "input" property.

Having only a moderate amount of Perl experience, I intuit that either
I am experiencing one of those arcane reference/dereference issues that
come with hashes, or that there is something in MSXML that breaks what
I assume to be the "C" code that Win32::OLE wraps. As a person of only
moderate Perl experience (and no C experience), I cannot tell which is
the case, if indeed my intuition is correct.

I would be grateful if anyone who knows a good deal about Win32::OLE
will take a look at these two short scripts and tell me where I am going
wrong.

If such a person needs an XML file and the corresponding XSLT file, I
will be only too happy to send them along.

Thanks


-- 
Charles Knell
[EMAIL PROTECTED] - email
(703) 234-3955 x2544 - voicemail/fax



__________________________________________________
Voicemail, email, and fax...all in one place.
Sign Up Now! http://www.onebox.com

Attachment: xForm.js
Description: JavaScript source

use strict;
use Win32::OLE;

my $XSLProc;
my $DOMDoc;
my $XSLT;
my $XSLTemplate;

$XSLT = Win32::OLE->new("Msxml2.FreeThreadedDOMDocument.4.0");
$XSLT->{async} = "false";
$XSLT->load("ServerMap.xsl");

if($XSLT->parseError->reason eq ""){
        $DOMDoc = Win32::OLE->new("Msxml2.DOMDocument.4.0");
        $DOMDoc->{async} = "False";
        $DOMDoc->load("Servers.xml");
        if($DOMDoc->parseError->reason eq ""){
                $XSLTemplate = Win32::OLE->new("Msxml2.XSLTemplate.4.0");
                $XSLTemplate->{stylesheet} = $XSLT;
                $XSLProc = $XSLTemplate->createProcessor();
                $XSLProc->{input} = $DOMDoc;
                print 'readyState '.$XSLProc->readyState;
                $XSLProc->transform();
                print $XSLProc->output;
        }else{
                print "Data document parse failure: ".$DOMDoc->parseError->reason;
                undef $DOMDoc;
                undef $XSLT;
        }
}else{
        print "XSL document parse failure: ".$XSLT->parseError->reason;
        undef $XSLT;
}

Reply via email to