سؤال

IE9 applies MSXML6 by default, where IE8 applies MSXML3. The fact that certain functionalities are off by default in MSXML6 causes trouble, in particular when loading pages like

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<root>...</root>

where the xslt stylesheet referred to applies embedded javascript (for example, custom extension functions).

It is possible to set DOM xslt properties in script code, for instance in Jscript:

var xsltDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xsltDoc.setProperty("AllowXsltScript", true);
xsltDoc.loadXML(xsltfile);

But when loading the file supplied above, IE9 loads the xslt file automatically, with default property values. And this results in a striking difference with IE8: IE8 will load the page flawlessly, but IE9 throws an error because of the default MSXML6 DOM objects property "allow xslt scripting = false". This is not true - see my answer below. The remainder of the question is thus insignificant

How can I trigger IE9 to load the file above and still allow running scripts in the xslt?

Note: I already tried the Internet Options/Security/Custom level.../Scripting/Active Scripting = Enable as suggested on msdn, but that setting was already correct.

I am hoping there is a specific IE9 processing instruction available but I guess there isn't. But maybe thre is a special stylesheet attribute that cooperates with IE9 xslt loading.
The concluson may also be that this is only possible by running a script on a main html file, where no automatic loading is done, but XML and XSLT are loaded into specified DOM objects with specified properties (like AllowXsltScript), and the output of the transformation is then loaded into the browser explicitly.

هل كانت مفيدة؟

المحلول 3

I was misguided. First, it's not IE security settings that trigger quirks mode; it's the (missing) doctype. Secondly, as can be seen in xslt8690-xslt-processing-failed, the real reason for not triggering quirks for a local file is a non-zone-related IE9 security setting.

So the DOM setting plays no role whatsoever - when IE loads xml or xslt the allowXsltScript property seems to be automatically set to true.

نصائح أخرى

I tried an example at http://home.arcor.de/martin.honnen/xslt/test2012050301.xml with the stylesheet being http://home.arcor.de/martin.honnen/xslt/test2012050301.xsl and it works fine with me and IE 9 on Windows 7. Based on that scripting is enabled even when IE 9 uses MSXML version 6 to execute the stylesheet. If you get an error there must be other reasons or there must be something particular to your code, you will need to post minimal but complete details allowing us to reproduce the problem.

I have a web page that performs client-side XSLT using built-in browser support (in IE9, MSXML6) invoked by JavaScript. The JavaScript uses an Ajax call to load the XSLT stylesheet (a static .xsl file) from the server into an XSLT processor object variable. The XML to be transformed is in an XML document object variable created by JavaScript. The contents of the XML document is based on the value of a textarea element on the page.

The XSL transformation was working in current versions of all target browsers (Firefox, Chrome, Safari) except for IE9, which reported the error:

"Use of default namespace declaration attribute in DTD not supported."

I tried a bunch of things to no avail. Finally, on a hunch, with hairs rising on the back of my neck, I inserted the attribute:

xmlns="http://www.w3.org/1999/xhtml"

in the html element of the web page. Not in the XML document that was being transformed, but in the web page that contained the JavaScript that invoked the XSLT transformation.

The error went away. The web page now works in IE9.

(The web page also contains an XML declaration and an XHTML 1.0 Strict DOCTYPE.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top