Solved

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

Posted on 2003-11-10
2
439 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now