Solved

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

Posted on 2011-02-22
4
1,709 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

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

15 Experts available now in Live!

Get 1:1 Help Now