I need to port a JavaScript to Perl in order to run it on an Apache 
server hosted on a Windows 2000 box. I wrote the original JavaScript

and I have used it many times so I know that it is solid and I know 
how to automate control of the Microsoft MSXML set of objects with it.

If you wonder why I'm not using the transformNode() method of the DOM

Document object, it's because in the original of this script, I need
to 
pass one or more parameters to the XSL transform which I can't do 
using that method. I have left out the lines which add the parameters

to simplify the demonstration.

I have been wandering around looking for a better place to post this

question than the ActivePerl page. It has drawn very little attention

there. I was happy to find this Win32 page because I'm certain that 
what I'm dealing with is a Win32 issue.

Saturday night I went to a bookstore and found an excellent volume on
Win32
Perl called "Win32 Perl Programming, The Standard Extensions", second
edition by Dave Roth (New Riders Publishing, ISBN 1-57870-216-x). Chapter
Five in on Win32::OLE and it gave me some debugging tips.

Based on that, I have modified my earlier script (see below), inserting
some additional print statements so that when the program is run, a message
explaining the debugging measures is printed to STDOUT.

In short, the effort to assign to the "input" property of the XSLProcessor
object the DOM Document resulting from parsing the data file fails
 $XSLProc->{input} = $DOMDoc;
because the input property cannot be found.

This is especially puzzling because immediately after creating $XSLProc,
I loop through all the keys and values of the blessed hash which $XSLProc
represents, and print them out, including the "input" property which
only a moment later cannot be found.

Will someone with a lot of Win32::OLE experience please look this over
and tell me where I'm going wrong.

If you need a data file and an XSL file, I'll be happy to provide them.

Thanks.
#############################################################3
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("ServerMap2.xsl");

if($XSLT->parseError->reason eq ""){
  $DOMDoc = Win32::OLE->new("Msxml2.DOMDocument.4.0");
  $DOMDoc->{async} = "false";
  $DOMDoc->load("Servers2.xml");
  if($DOMDoc->parseError->reason eq ""){
    $XSLTemplate = Win32::OLE->new("Msxml2.XSLTemplate.4.0");
    $XSLTemplate->{stylesheet} = $XSLT;
    $XSLProc = $XSLTemplate->createProcessor();
    print 'Here is a list of the properties of $XSLProc and their 
values'."\n".'obtained
by querying the object itself immediately after creating it:'."\n";
    print "Property\tValue\n";
    foreach(keys %$XSLProc){
      print "$_\t".$XSLProc->{$_}."\n";
    }
    $XSLProc->{input} = $DOMDoc;
    print "\n".'After assigning $DOMDoc to $XSLProc->input we check the
last error recorded: '."\n". Win32::OLE->LastError()."\n";
    print "Which yields the puzzling message appearing to state that
the property we just\n showed to exist by iterating through the keys
of the hash which comprises ".'$XSLProc'.",\n doesn't exist!\n\n";
    print "Which further explains why when we check the 'readyState'
property before the transform\n";
    print "we see the expected value: ".$XSLProc->readyState."\n";
    $XSLProc->transform();
    print "And after calling the transform method the value does not
change: \n";
    print $XSLProc->readyState."\n";
    print "because we can't set a property which can't be found by the
method \n that is supposed to set it.\n";
    print $XSLProc->output;
    $DOMDoc->DESTROY();
    $XSLT->DESTROY();
    $XSLProc->DESTROY();
  }else{
    print "Data document parse failure: ".$DOMDoc->parseError->reason;
    $DOMDoc->DESTROY();
    $XSLT->DESTROY();
  }
}else{
  print "XSL document parse failure: ".$XSLT->parseError->reason;
  $XSLT->DESTROY();
}
-- 
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

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to