Solved

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

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

Suggested Solutions

Title # Comments Views Activity
C# SQL BULK INSERT CLASS 5 47
XSLT XML 4 19
Excel file not created as expected 7 71
Select record with the most recent date 14 54
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.

776 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