Solved

msxml.document vs msxml2.document.6.0: transformNode goes funny

Posted on 2011-02-22
4
1,692 Views
Last Modified: 2013-11-18
using a classic ASP page, I started out with:

    set oXSLDoc   = Server.CreateObject("MSXML.DOMDocument")
    oXSLDoc.load(Server.MapPath(strXSLSheet)
    set oDocument = Server.CreateObject("MSXML.DOMDocument")
    oDocument.loadXML(doc)
    xmlTrans = oDocument.transformNode(oXSLDoc)

It works fine, but it is to slow sometimes. So now I want to use MSXML2.DOMDocument.6.0 in stead of MSXML.DOMDocument:

    set oXSLDoc   = Server.CreateObject("MSXML2.DOMDocument.6.0")
    oXSLDoc.load(Server.MapPath(strXSLSheet)
    set oDocument = Server.CreateObject("MSXML2.DOMDocument.6.0")
    oDocument.loadXML(doc)
    xmlTrans = oDocument.transformNode(oXSLDoc)

The good news is that it is much quicker. The bad news is that xmlTrans still gets data, but the transform returns not the same structure. It is as if there was no transformation at all, just a copy of the textnodes. There is no error so both the xml and xslt appear to have loaded just fine.

Any thoughts?


0
Comment
Question by:Amkick
  • 3
4 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34950707
There are various important differences between msxml.domdocument and msxml2.domdocument
2 has solved a number of issues from 1 and is indeed quicker.

I usually use a template processor instead of trasnform node, but it should not make a difference

What you tell indicates that none of the templates is activated.
Maybe not only the XSLT processing changed, but you are also getting correct namespaces now.
In order to see what happens, I would like to see the source XML and the XSLT

Also note that msxml2 stopped supporting the WS-XSLT (the older specification that ever only got support from Microsoft and is still lingering around)
If you have the WS namespace in use, you migt be up for a bigger update

Let's see, source XML and XSLT please :-)

0
 
LVL 2

Author Comment

by:Amkick
ID: 34950866
Hi Gertone,

Your question alone got me much further: I was getting the xml and the xslt and then realised that the xslt included several other xslt's. What a hassle! At that point people around me saw a light bulb hovering just above my head...

            oXSLDoc.resolveExternals = True

makes quite the difference...  (http://msdn.microsoft.com/en-us/library/ms762283(v=vs.85).aspx and see the remark: In MSXML 3.0, MSXML 4.0, and MSXML 5.0 the default resolveExternals value is True. In MSXML 6.0, the default setting is False. )

Thanks for that!

What did you mean by using a template processor instead of a transformNode?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34950923
look at the ASP code in this article
http://www.inov8design.com.au/articles/xml_xslt_asp.asp#asp

a template processor gets created, which allows passing parameters easily to the XSLT
also note the use of  freethreaded objects, which is specially recomended for the XSLT
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 34950925
     Set objXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
you don't need to do that for the XML,
but I believe it is safest doing so for the XSLT
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 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

22 Experts available now in Live!

Get 1:1 Help Now