Unofficial MSXML XSLT FAQ
When Internet Explorer 5.0 was first shipped in 1998, Microsoft shipped an implementation of XSL that was based on the current working draft of XSL at that time. Millions of copies of this XML/XSL processor were burned on CDs and were installed on systems all around the world. Since then, the XSLT specification changed very significantly (even the namespace changed!) and was finalized. So the situation as it is today (12/4/2000) is that there are millions of copies of a parser out there which does not (by default) support the latest XSLT specification. It is quite common for people to write to the xslt-list asking for information about why some operation does not work in Internet Explorer 5.0. Although there have been updates to the MSXML parser to make it more current, many people are not aware that they can download these and do not realize that they are using the older, less compliant processor. While the XSLT community appreciates the way that IE5 has exposed many more people to the cross-platform wonders of XSL, there is quite a bit of consternation caused by frequent questions having a root in the fact that IE5 shipped before the specification was mature.
This is not meant to be a replacement or even a subset of the excellent XSL FAQ that exists. It is rather meant to be a simple URL that people on xslt-list can refer individuals having trouble getting started with XSLT and IE. If you are reading this, there is a good chance you were referred here from the list :-).
1. Why do my transforms fail using IE (or using my custom application)?
Before you send a question to the XSLT list, it is best to check a few things:
Once you have checked these things, you will have much better information to ask your question.
2. How do I run XSLT transforms automatically from code?
Here is some code that calls a transform against the recent versions of MSXML:
Dim xmlSource As Object Dim xmlXForm As Object Set xmlSource = CreateObject("MSXML2.DOMDocument") Set xmlXForm = CreateObject("MSXML2.DOMDocument") xmlSource.validateOnParse = True xmlXForm.validateOnParse = True xmlSource.async = False xmlXForm.async = False xmlSource.loadXML Text3.Text ' This loads the text that I want to transform If Err.Number <> 0 Then strErr = Err.Description & vbCrLf strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error loading the XML" GoTo bail End If xmlXForm.loadXML Text1.Text ' This loads the XSLT transform If Err.Number <> 0 Then strErr = Err.Description & vbCrLf strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error loading the Transform" GoTo bail End If Text2.Text = xmlSource.transformNode(xmlXForm) ' This transforms the data in xmlSource If Err.Number <> 0 Then strErr = Err.Description & vbCrLf strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error executing the Transform" GoTo bail End If Set xmlSource = Nothing Set xmlXForm = Nothing
The code above is written in VB, but you can write using Java, JScript, VBScript, PerlScript, C++, or any other language that supports COM. The important thing about the above code sample is that we are using the CreateObject("MSXML2.DOMDocument") instead of CreateObject("MSXML.DOMDocument"). Using "MSXML2" ensures that you call the newer XSLT processor, and not the working draft version from 1998. This example should also show you how to get detailed error information if your transform fails. One thing to note: if you are transforming unstructured data (non-XML), then you will probably want to set xmlSource.ValidateOnParse=False in the above example. You probably don't want it to be telling you that your document is not well-formed XML when you already know that and don't care!
3. How do I run XSLT transforms within Internet Explorer?
As long as your XML file refers to the appropriate .xslt stylesheet, it should render in IE5. If you are running side-by-side installation of MSXML, IE will use the old XSLT processor. To unregister the old processor and tell IE to use the new one, type the following four commands at a command prompt:
regsvr32 msxml3.dll xmlinst
If you would like to unregister the older version of the processor, type the following sequence of commands instead:
xmlinst -u regsvr32 -u msxml.dll regsvr32 msxml3.dll xmlinst
Note: In the final release, xmlinst.exe is a separate download from MSDN, and does not come with the MSXML download. You can download xmlinst.exe here.
More information about installing for replace mode is found in the online documentation that comes with the updated parsers. You may also wish to download the "Internet Explorer Tools for Validating XML and Viewing XSLT Output".
4. Why do I need to use a different XSLT namespace with Internet Explorer?
Actually, you don't! You should use the standard xmlns:xsl="http://www.w3.org/1999/XSL/Transform". If your code is complaining when you try to use this namespace, it is likely that you are using the old version of the MSXML processor (which was developed before the above namespace was even dreamed up).
If you have older style sheets and do not wish to convert them to the new format, you can also use the old namespace declaration xmlns:xsl="http://www.w3.org/TR/WD-xsl".
5. How do I install the updated MSXML on my machine?
FirstFirst, try pointing your browser to the magic install tool provided by Chris Bayes. If this does not work, try the following manual steps:
There is also a code-signed package that allows you to install MSXML3 to people's machines through their web browser. For instructions on how to create a web page that installs MSXML3, see http://msdn.microsoft.com/xml/articles/msxmlcabfile.asp.
Note: The MSXML3 parser is a binary COM Object written for high performance on the Windows platform and is not written in Java. The old MSXML-Java parser is no longer maintained.
Note: If you have trouble executing the install files, they can also be loaded using WinZip.
Note: The installation files above use the Microsoft Installer. If your machine does not have Windows Installer, you can download it here.
Note: If you want to try another way to download and install MSXML3, you can try the automated install utility I wrote. This is a very crude tool, but usually works. It downloads and installs 8 other XSLT Processing tools and the XSLT test tool as well.
6. I know I have installed the most recent MSXML processor; why is my application not using it?
If you are calling your transform from within some programming language, this is probably because you are not using "MSXML2.DOMDocument" in your call to CreateObject(). See the question about calling transforms from code for an example using the correct call. If you are attempting to view the XSLT transform directly from Internet Explorer, you have probably installed the newest MSXML in side-by-side mode.
7. When will Microsoft ship a 100% compliant XSLT processor?
The final release of MSXML3 attempts to be 100% compliant. This release passes the OASIS conformance test suite 100%, and is one of the most conformant engines available. It is always possible that there are conformance bugs.
8. Does IE5.5 include a newer XSLT processor?
No. Internet Explorer 5.5 still ships with the older processor. If you want to use an implementation of the current XSLT specification, you will need to install it. The next versions of Internet Explorer and Windows will come with the newest XSLT processor included.
9. The newest MSXML processors available for download say that they are not supported. How can I use these if they are not supported? [Obsolete]
The release version of MSXML3 is now available and is fully supported.
10. Why is the MSDN online documentation for XSL so different from the W3C XSLT specification?
You are probably looking at the wrong documentation. The MSDN Online Library shows the documentation for the XSL processor that shipped with IE5 long before the XSLT specification was complete. You need to install the XML SDK for the updated MSXML to get the updated documentation. The updated XSLT reference will be installed as <C:\Program Files\Microsoft XML Parser SDK\Docs\xmlsdk30.chm> on your hard drive. You can double-click this file to view the documentation, including full disclosure about level of conformance. MSDN will be updated soon to reflect the new release of MSXML3.
MSDN now has an interactive visual tool for learning the W3C XSLT and XPath.
11. Where does Microsoft provide documentation about compliance of MSXML?
Each of the new releases of the MSXML parsers have a bug listing page which describes all known problems with that version. Bugs listed here can include things typically thought of as coding mistakes, or areas that are not fully implemented. In addition, if you have installed the documentation for the latest MSXML, you can read full conformance disclosure under the section "XSLT Developer's Guide\XSLT and XPath Conformance Notes". Finally, the VBXML community maintains some pretty charts showing compliance of various versions of MSXML. It is possible that there are bugs which have not been discovered with the current MSXML parsers, and it is also possible that some un-implemented part of the specification is not clearly documented. Contrary to popular opinion, Microsoft does not want to "hide" information about MSXML compliance. If you find a bug or implementation point that is not clearly documented, please send e-mail to Microsoft or to me (or better yet, both) so that the documentation can be updated.
12. How can I call MSXML from the command line to do batch processing of XSLT?
There is now a command-line utility with source code available that allows fast command-line processing of XSLT. Since MSXML is a COM object, you can write any .vbs, .js or other Windows Scripting Host (WSH) file to launch MSXML from the command line. Ken Holman provides a comprehensive treatment of calling MSXML from command-line script to supplement the book "Practical Transformation Using XSLT and XPath". Another option is to use the command-line syntax of the XSLT Test Tool or write your own executable wrapper.
13. Why doesn't MSXML support XML Schema (XSD) or, Why did Microsoft make their own version of schema (XDR)?
XML-Schema efforts are continuing, and as of this writing (12/5/2000), XML-Schema is not finalized. Microsoft has committed to support XML Schema when it becomes a full W3C recommendation. Before XML-Schema efforts began, a number of companies developed the XML-Data specification. When it became apparent that XML-Schema would supercede XML-Data, Microsoft wanted to support XML-Schema, but needed to ship product without waiting for standards efforts to continue. To this end, XML-Data Reduced was developed as a minimal subset of XML-Data that was guaranteed to be compatible with XSL-Schema as it developed. Current Microsoft XML parsers will validate documents against an XDR schema, and will support XSD when it is released. The released MSXML3 uses XDR, but beta products such as the .NET framework SDK are already using XSD. MSXML4 will use XSD. In addition, tools to automatically convert XDR to XSD are now provided. In fact, the conversion is accomplished through an XSLT stylesheet. If you would like a conversion stylesheet that converts XDR to the latest XSD, you can get it at http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/539/msdncompositedoc.xml.
14. What do I do if I already wrote lots of XSL using the old IE version of XSL?
If you would like to upgrade XSL stylesheets based on the earlier working draft to be compliant with the final XSLT specification, you can use the XSL to XSLT Converter available at MSDN.
15. Why do I sometimes have problems loading or including a document from a URL (or what's this talk about async vs. synch)?
If you attempt to load an XMLDOM using the loadXML() method, the default behavior of the method is to load asynchronously. This means that the DOM starts loading, and immediately returns control to you. Unfortunately this means that you may attempt to use the DOM before it is loaded, resulting in annoying errors. There are two things you can do to prevent this situation. First, you can always tell the DOM to load synchronously (that is, wait for the document to finish loading before moving on to the next line of code) by setting the property async = False. This is how the load is accomplished in the code sample here. If you want the DOM to load asynchronously, you can always check to make sure that the property readyState = True before reading the DOM.
16. When will server-side HTTP in XML be reliable under heavy load?
The final MSXML release has changed the HTTP loaders for SAX and DOM to be safe under heavy server load. You must explicitly tell your code to use the new server-safe loader, as described here. This link also includes a utility that allows you to configure the XML HTTP to transfer through a proxy server. In order to make sure that no backward-compatible issues would exist, you will need to perform XMLHTTP loads as before, but using new objects. Instead of using CreateObject("MSXML2.XMLHTTP") you will use CreateObject("MSXML2.ServerXMLHTTP"). If using the MSXML2.DOMDocument load() method, use code like the following (note the new call to setProperty()):
Dim xmldoc Set xmldoc = CreateObject("MSXML2.DOMDocument") xmldoc.async = false xmldoc.setProperty("ServerHTTPRequest", true) xmldoc.load("http://machinename/path/file.xml")
17. I need to use the node-set() extension function, but MSXML doesn't seem to have it.
It's there! MSXML originally treated everything as a node-set, thus no extension function. Most other processors have a node-set extension function (which is how Saxon does things). There is talk of having the next XSLT spec formally require that everything be a node set by default. Now, since all processors besides MSXML require you to explicitly convert the RTF to a node-set first, and since MSXML didn't have a node-set function (node-set isn't in the spec) the finally released MSXML3 contains msxsl:node-set(string).
18. How do I dynamically change the client-side (for Internet Explorer) stylesheet associated with my XML file from code?
Check out the XML/XSL Viewer sample on MSDN. Chris Bayes has released a Power Toy utility that you can download from his XML Portal. Also, see the next question if you are interested in the default XSL stylesheet used to display raw XML files in the browser.
19. How does Internet Explorer format XML files in a collapsible view, and how can I modify this behavior?
For XML files that do not have a stylesheet associated, Microsoft Internet Explorer uses a default XSL stylesheet to create a DHTML rendering of the XML file. Depending on which version of MSXML you are using, you can browse to either res://msxml3.dll/DEFAULTSS.xsl or res://msxml.dll/DEFAULTSS.xsl. The res:// URN format indicates that the XSL file is compiled as a resource directly into the dll. If you have a binary resource editor (such as the one included with Visual C++), you can edit the XSL directly inside the MSXML dll and save back into the binary file. Alternately, you can start with a copy of the stylesheet from http://msdn.microsoft.com/xml/samples/defaultss/defaultss.xsl.
Joshua Allen <firstname.lastname@example.org>
Last Update: 1/30/2001
2/11/2001 - Pointer to new detect sniffer, vbxml.com
2/11/2001 - Pointers to .cab file distribution and xdr-xsd conversion
1/30/2001 - Remove autodetect to fix (and hopefully add .cab pointers)
1/22/2001 - Autodetect MSXML version, thanks Jarno Elovirta
12/25/2000 - Added line numbers
12/4/2000 - Some changes to reference released version of MSXML3
12/4/2000 - node-set() update, thanks to Gavin Bong
10/28/2000 - setProperties() example on Server-side XML
10/25/2000 - IE5 XML Stylesheet, thanks Jarno Elovirta
10/25/2000 - More info on server-side XMLHTTP
10/7/2000 - Added information about the new secret location of xmlinst.exe.
10/3/2000 - Added Questions 15, 16, 17, & 18
10/3/2000 - Added reference to .msi file added in September release
10/3/2000 - Added some comment on September Beta compliance
7/28/2000 - Added helpful hints about installing thanks to Kit Lueder
7/27/2000 - Fixed hyperlink bug in TOC Q5
7/26/2000 - Added more information about XSL namespace
7/19/2000 - Updated msxml2.dll to point to more current msxml3.dll
7/19/2000 - Linked to information about MSXML from WSH
7/16/2000 - Added information about XSD/XDR
7/16/2000 - Added information about XSL to XSLT conversion
7/16/2000 - Removed references to "ProgID" to avoid confusion
7/15/2000 - Fixed page title, spelling error in "regsvr32"
7/13/2000 - First posted to web