Style sheet for XML not rendering in IE9

12,945

Solution 1

Can you be more specific as to how it's "is not even recognized as xml on IE9"? Do you get an error message, or is it simply that it looks different in IE9 than in previous versions?

The first thing your XML file does is associate itself with an XSLT stylesheet at "/mobiledoc/jsp/empi/master/CCD.xsl" so this could be the source of your problem. Some suggestions:

  • As a test, remove the <?xml-stylesheet .. ?> bit. Do you now get the same behaviour in all browsers? (Probably just a hierarchical view of the XML file) If so, then the problem is in your XSLT stylesheet.

  • What does that stylesheet do? If it's converting the XML file into HTML, it might be using some non-conformant (X)HTML constructs or styles which older versions of IE tolerated, but which IE9 is more strict about. If the "not recognized" is some layout/display issue, tweaking the stylesheet might fix what you see in the browser.

Based on what you've told us so far, I think that's probably where you need to start.

ETA: The upshot of the conversation below was that the <xsl:output> directive was forcing a 4.01 HTML doctype into the output; changing this to <xsl:output method="html"/> (and fixing a couple of other issues with the transform) fixed the problem in IE9.

Solution 2

I am glad that the issue was fixed - in this particular case that is.
But the real reason for the error in IE9 is not disclosed yet, so I will do that here.

The reason for the encountered behavior is a bug in XSLT processing in IE9.

Well OK - it's not really a bug, just bad error reporting. The point is that IE9 applies MSXML6 by default, and a lot of things have changed with respect to MSXML4. When there's a plain error in the XSLT, it's not reported - IE9 seemingly skips processing onto default text() templates, which results in presenting all text nodes.
Worse, when something is done in the XSLT that is prohibited by default in MSXML6, the same thing happens. So what's prohibited by default in MSXML6? A lot! Applying Jscript for instance. And DTD's. And the document() function won't work.

In the case above, one might suspect from the text shown (which obviously comes from applying the default templates), that there is an error in the xslt - waiting to be discovered with good tools. But this IE9 behavior is not so obviously linked to the xslt when there's no text in the xml part of the file opened (that is, when the xslt itself supplies all the data to be processed, for instance by importing xml files on runtime, or the data in the xml that the xslt processes is all in attributes and nodenames). You just have to know...

You can see the error message behind all this yourself if you go to developer tools by pressing F12 (or select it from the Tools menu). In developer tools subscreen, select Script Menu and load your page now. You will see that on the right, in the console, an error message appears:
XSLT8690: XSLT processing failed.
When this error occurs, only the text nodes in the xml are displayed (so, for an empty xml root node, the page will be blank).
I could find only one reference to this error on the web: http://www.wikistep.org/bugzilla/show_bug.cgi?id=4140.

Note that when you select "compatibility view" by clicking the torn page button next to the refresh button (which is not always available, another -minor- IE9 bug), the page goes back to IE8 display, and will be OK again - well, apart from any errors in xslt of course, but MSXML 4.0 does not have all these restrictions that MSXML 6.0 has by default. It's safer, for sure, but very annoying too.

Note that by selecting compatibility view, the site part of the file's url is added to the list of sites for which compatibility view is automatically applied.
To recreate the issue, you will have to remove the site from that list, by pressing Alt to open up the menu, selecting tools/compatibility view settings, and removing the site from the list before trying again.
Also note that the trick of applying compatibility view does not always fix things: when for instance the xslt calls embedded javascript containing classes not available in IE8 Jscript version, the xslt will fail in compatibility view too.

Now what can be done about this? Actually I am not sure - worth another question on SO!
The properties which are off by default can be switched on - but the examples I have seen only do so when loading an XML type string in a DOM object within a sequence of statements - and then one can assign the new DOM object the necessary properties before loading the string.
Here, IE9 takes care of loading the XML automatically and also loads the XSLT to process the XML. So where the hell can we set the XML load properties before the loading takes place?
I am sure it will take time - but I will find out!

Share:
12,945
Sap
Author by

Sap

There is nothing much I can say

Updated on June 04, 2022

Comments

  • Sap
    Sap almost 2 years

    I have a xml document which right now is not even recognized as xml on IE9. I have tried adding correct xmlns:xsl attribute, also it has a correct header starting with

    <?xml version="1.0" encoding="UTF-8"?>
    

    This xml renders perfectly in IE 6 7 8 but does not work in IE9. I am not sure if it is Quirks mode related issue, and if it is I am not sure what DOCTYPE is should use for XML documents. Any help will be greatly appreciated. Following is the first few lines of XML document.

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="/mobiledoc/jsp/empi/master/CCD.xsl" ?>
    <ClinicalDocument xmlns="urn:hl7-org:v3" 
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                      xmlns:sdtc="urn:hl7-org:sdtc" 
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                      xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd" 
                      classCode="DOCCLIN" 
                      moodCode="EVN">