Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML.js : parser may fail in IE8 due to schema fetching and validation #1379

Open
justb4 opened this issue Aug 11, 2014 · 0 comments
Open

XML.js : parser may fail in IE8 due to schema fetching and validation #1379

justb4 opened this issue Aug 11, 2014 · 0 comments

Comments

@justb4
Copy link
Contributor

justb4 commented Aug 11, 2014

This is an IE8-specific (and possibly more versions) issue. I can provide a PR. When loading a WMS Capabilities document via GeoExt and subsequently via the OpenLayers.Format.WMSCapabilities, the responseText parsing in OpenLayers.Format.XML may fail due to DTD/schema checking, strangely even if the XML is DTD-valid. First observed with GeoServer and a GXP example: http://lib.heron-mc.org/heron/latest/examples/catalognl where Layers are loaded via WMSCapabilities.

Apart from the issue that IE actually fetches the DTD over the network, creating overhead, I think that by default validation should be disabled as is for all other browsers. This can be done via the validateOnParse MS.XMLDOM property in the OpenLayers.Format.XML.read() function. I made a local override and can confirm that the following works.

    .
    .
    var node = OpenLayers.Util.Try(
        OpenLayers.Function.bind((
            function() {
                var xmldom;
                /**
                 * Since we want to be able to call this method on the prototype
                 * itself, this.xmldom may not exist even if in IE.
                 */
                if(window.ActiveXObject && !this.xmldom) {
                    xmldom = new ActiveXObject("Microsoft.XMLDOM");
                } else {
                    xmldom = this.xmldom;

                }
                xmldom.validateOnParse = false; // <======
                xmldom.loadXML(text);
                return xmldom;
            }
        ), this),
        function() {
            return new DOMParser().parseFromString(text, 'text/xml');
        },
        .
        .

A similar implementation was done in OL XMLHttpRequest.js as below.

function fGetDocument(oRequest) {
    var oDocument    = oRequest.responseXML,
        sResponse    = oRequest.responseText;
    // Try parsing responseText
    if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader("Content-Type").match(/[^\/]+\/[^\+]+\+xml/)) {
        oDocument    = new window.ActiveXObject("Microsoft.XMLDOM");
        oDocument.async                = false;
        oDocument.validateOnParse    = false;  // <========
        oDocument.loadXML(sResponse);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant