XSLT FAQ
Why do my transformations fail using Internet Explorer?
When Microsoft® Internet Explorer 5.0 was released in 1998, the Microsoft XML Parser (MSXML) included an implementation of Extensible Stylesheet Language (XSL) that was based on a working draft.
Although the XSLT community appreciates the way that Internet Explorer 5.0 and later versions have exposed people to the cross-platform potential of XSL, the fact that it was released before the specification was finalized has caused considerable confusion.
Although the XSLT specification has now been finalized, there are installed copies of the MSXML parser that do not support the most current XSLT specification. As a result, it is common for people to send feedback to Microsoft asking for information about why an XSLT operation does not work in Internet Explorer 5.0. Many people do not realize that their version of Internet Explorer is using a version of the MSXML parser that uses XSL, not XSLT.
Note If your XSLT transforms are failing in Internet Explorer 5.0 or a later version, make sure you have installed MXSML 3.0, the most current version of the MSXML parser. For instructions about how to install MSXML 3.0, see Setting Up Your Development Environment to Create XSLT Solutions.
If you are using the version of MSXML released with Internet Explorer 5.0 or Internet Explorer 5.5, then you are using a parser that was based on the working draft of XSL. For information about installing MSXML 3.0 in side-by-side or Replace mode, see Installing MSXML 3.0 for XSLT Support.
How do I run XSLT transformations automatically from code?
You can run an XSLT transformation on an XML document programmatically using code written in Microsoft JScript®, Microsoft Visual Basic® Scripting Edition (VBScript), Microsoft Visual Basic, C++, or any other language that supports COM, including PerlScript.
The following Visual Basic code calls a transformation against MSXML 3.0. This code sample uses the CreateObject("MSXML2.DOMDocument") syntax instead of the CreateObject("MSXML.DOMDocument") syntax associated with versions 2.x of MSXML. Using "MSXML2" ensures that you call the most current XSLT processor, not the 1998 working draft version. This example also shows you how to get detailed error information if your transformation fails. If you are transforming unstructured (non-XML) data, set xmlSource.ValidateOnParse=False instead of xmlSource.ValidateOnParse=True, as it appears in the following example.
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.resolveExternals = False
xmlXForm.resolveExternals = 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
How do I run XSLT transformations in Internet Explorer?
As long as your XML file references a well-formed XSLT style sheet, it should render in Microsoft Internet Explorer 5.0 or later versions. However, if you are running the Microsoft XML Parser (MSXML) 3.0 in side-by-side mode, Internet Explorer will use an earlier version of MSXML, which provides XSL, not XSLT, support. To unregister earlier versions of MSXML and run MSXML 3.0 in Replace mode, see Install MSXML 3.0 in Replace Mode. MSXML 3.0 provides full XSLT support. To run transformations in Internet Explorer, download the Internet Explorer Tools for Validating XML and Viewing XSLT Output. For more information about how you can use XSLT on the client and the server, see Deploying XSLT on Internet Explorer.
Do I need to use a different XSLT namespace with Internet Explorer?
No. Use the standard xmlns:xsl="http://www.w3.org/1999/XSL/Transform" syntax. If Microsoft Internet Explorer returns an error when you use this namespace, it is likely that you are using an earlier version of MSXML that uses an old version of the XSLT processor. If you have older style sheets and do not want to convert them to a new format, you can still use the namespace declaration xmlns:xsl="http://www.w3.org/TR/WD-xsl". To convert old XSL style sheets to XSLT, use the XSL to XSLT Converter 1.1 available from MSDN Online Downloads.
I have installed MSXML 3.0. Why isn't my application using it?
If you are using a programming language to call your transformation, it's likely that you are not using the correct progID in your call to CreateObject(). If you are running MSXML 3.0 in Replace mode, you can use the version-independent progID. If you are running MSXML 3.0 in side-by-side mode, use the version-dependent progID. The following Microsoft Visual Basic® code shows the correct syntax to create a DOMDocument object into which you load an XSLT style sheet.
Visual Basic using the version-independent progID
Dim xsltDoc
Set xsltDoc = CreateObject("Msxml2.DOMDocument")
Note You can also use a version-specific progID.
Visual Basic using the version-dependent progID
Dim xsltDoc
Set xsltDoc = CreateObject("Msxml2.DOMDocument30")
For more information about progIDs and syntax, see GUID and ProgID Information. For more information about creating the DOMDocument object, see Using the DOMDocument Object.
Does MSXML 3.0 provide a 100% compliant XSLT processor?
Unlike earlier versions of the Microsoft XML Parser (MSXML), the XSLT processor in MSXML 3.0 is highly compliant with the XSLT specification. For more information, see the XSLT and XPath Conformance Notes.
Does Internet Explorer 5.5 include a fully compliant XSLT processor?
No. Microsoft Internet Explorer 5.5 is still released with a version of the Microsoft XML Parser (MSXML) that does not offer XSLT support.
Is MSXML 3.0 a production version?
Yes. It is available for download from the XML Developer Center at MSDN.microsoft.com/xml.
Why is the MSDN online documentation for XSL so different from the W3C XSLT specification?
At the time of this writing, the MSDN® online documentation contains information related to MSXML version 2.5, which features XSL functionality, not the XSLT functionality included in MSXML 3.0. The MSXML documentation on MSDN will be updated to the MSXML SDK 3.0 documentation shortly after the production release of MSXML 3.0. Notethat you can download the MSXML 3.0 SDK, which contains the MSXML 3.0 documentation, from the XML Developer Center at MSDN.microsoft.com/xml. The documentation is installed in C:\Program Files\Microsoft XML Parser SDK\Docs\xmlsdk30.chm on your hard drive. To view the documentation, which includes full disclosure about levels of conformance, double-click xmlsdk30.chm.
Where can I find documentation about compliance of MSXML?
Each new release of the Microsoft XML Parser (MSXML) has a Bug List Page describing known problems, such as coding mistakes or features that are not fully implemented. For full conformance disclosure, see XSLT and XPath Conformance Notes. If you find a bug or implementation point that is not clearly documented, please send feedback to the XML documentation team by using the XML Documentation Feedback form. To use this form, click the Feedback icon (the envelope) at the top-right corner of any page of thisdocumentation.
How can I call MSXML from the command prompt to do batch processing of XSLT?
Because the Microsoft XML Parser (MSXML) is a COM object, you can write Microsoft Visual Basic® Scripting Edition, Microsoft JScript®, or other Microsoft Windows Script Host (WSH) files to launch MSXML from the command prompt. Microsoft provides an XSLT Command Line Utility, MSXSL.EXE that performs command-line XSL transformations using the Microsoft XSL processor. MSXSL is a small (~11K) command-line utility that invokes MSXML3.DLL to perform the actual work of the transformation. The MSXSL.EXE Command Line Utility is availablefor download at the XML Developer Center at MSDN.microsoft.com/xml.
What can I do if I wrote lots of XSL using the old Internet Explorer version of XSL?
If you would like to upgrade XSL style sheets so that they are compliant with the XSLT specification, you can use the XSL to XSLT 1.1 Converter available from MSDN Online Downloads.
Suresh [Microsoft MVP .Net ,India]