Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-22
4
Medium Priority
?
1,862 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

876 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