Solved

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

Posted on 2011-02-22
4
1,790 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

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…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

630 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