Solved

How can i use createProcessor when i transform using transformNodeToObject method.

Posted on 2003-11-10
2
446 Views
Last Modified: 2012-05-04

I'm getting [object Error]  error on followinh line
Processor.transformNodeToObject(gxslDOM, result);

------------------------------------------------------------------------
var gxmlDOM = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0");
gxmlDOM.async = false;
gxmlDOM.loadXML(XML);


var gxslDOM = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0");
gxslDOM.async = false;
gxslDOM.loadXML(XSL);


var gTemplate = Server.CreateObject("MSXML2.XSLTemplate.3.0");
gTemplate.stylesheet = gxslDOM;

var Processor = gTemplate.createProcessor();
Processor.input = gxmlDOM;
Processor.addParameter("MENU", "NO", "");
Processor.addParameter("MENU1", "YES", "");


// Set up the resulting document.
var result = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0");
result.async = false;
result.validateOnParse = true;

// Parse results into a result DOM Document.
Processor.transformNodeToObject(gxslDOM, result);

Response.Write("result<BR>")

----
Following code works fine but i want to use transformNodeToObject instead of transform

....
....
// Parse results into a result DOM Document.
Processor.transform();
var strResult;
strResult = Processor.output;
return (strResult);
0
Comment
Question by:Bharat Guru
2 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 50 total points
ID: 9724232
transformNodeToObject() is a method of the IXMLDOMNode interface, not the template processor interface.  You can't use transformNodeToObject() on IXSLTemplate.   And you can't use parameters on transformNodeToObject()

Why would you want to do this anyway?  The transform() method does exactly what you want.  Note, I modified your code slightly:
============================================
// Don't need free threaded for this one, unless you're caching in an Application object or something
var gxmlDOM = Server.CreateObject("Msxml2.DOMDocument.3.0");
gxmlDOM.async = false;
gxmlDOM.loadXML(XML);

var gxslDOM = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0");
gxslDOM.async = false;
gxslDOM.loadXML(XSL);

// Set up the resulting document.  It doesn't need to be free threaded either
var result = Server.CreateObject("Msxml2.DOMDocument.3.0");
result.async = false;
// is this really necessary??  If you're doing the transform, are you *sure* the output is valid?
// result.validateOnParse = true;


var gTemplate = Server.CreateObject("MSXML2.XSLTemplate.3.0");
gTemplate.stylesheet = gxslDOM;

var Processor = gTemplate.createProcessor();
Processor.input = gxmlDOM;
// Set the output property to point to the XML target.  This has the same effect as transformNodeToObject
Processor.output = result
Processor.addParameter("MENU", "NO", "");
Processor.addParameter("MENU1", "YES", "");

Processor.transform()

// now result contains the output of the transform.
// if you wanted to send the output to the client, just use:

var Processor = gTemplate.createProcessor();
Processor.input = gxmlDOM;
Processor.output = Response
Processor.addParameter("MENU", "NO", "");
Processor.addParameter("MENU1", "YES", "");
Processor.transform()
=====================================

Again, if the intent is to send the result to the Response, don't use Response.Write.  Set the output to the Response object so that the result of the transform uses IStream to the Response object directly.

Regards,
Mike Sharp

0
 

Author Comment

by:Bharat Guru
ID: 10274178
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question