[OpenLayers-Users] [Solved but need confirmation on a possible OL bug] Re: WMC file parsing error in IE9

Ameet ameet_ch at rediffmail.com
Mon May 28 06:58:16 PDT 2012


I solved this by manually creating a new IXMLDomDocument object from xml
string retrieved from response object. Now I have the right object to pass
to the /OpenLayers.Format.WMC/ object's read method.  But the
'OnlineResource' element in WMC file was not retrieved properly at one place
in OL API.

Here I like to ask if there is a bug in OL API (specific to IE9, since it
works in other browsers). It can be described as below.

/OpenLayers.Format.WMC.v1/'s /getOnlineResource_href/ function uses
/node.getElementsByTagName("OnlineResource")/. In IE 9, this function does
not return the 'OnlineResource' element even though it exists for nodes like
'Server' and 'MetadataURL' (in our WMC files, it is the only childnode for
these two nodes) but properly returns the same for the node 'Style' (which
also has a 'title' childnode in addition to 'OnlineResource'). 

So is it that /getElementsByTagName/ does not behave properly in IE 9 when
the element it is trying to retrieve is the only child of the node on which
it is called? Has anyone else experienced the same? Please confirm if this
is a bug. I've found this issue earlier too when trying to show features
from Atom/GeoRSS feeds, but I ignored then by not using
/getElementsByTagName/.

I would also like to get approval for the workaround I implemented (below).
My code works but I want to know if these changes are safe and the right way
to get an element if /getElementsByTagName/ doesn't work.
My modification to /OpenLayers.Format.WMC.v1/'s /getOnlineResource_href/
function:

Note: I'm using OpenLayers 2.11

getOnlineResource_href:function(node){
    var object={};		
    if ( (navigator.appName == 'Microsoft Internet Explorer') &&
(getInternetExplorerVersion() > 8.0) ) {      
        var links= null;              
	for(var i = 0; i < node.childNodes.length; i++) {
	    if(node.childNodes[i].nodeName == 'OnlineResource' ||
node.childNodes[i].tagName == 'OnlineResource') {
		links = node.childNodes[i];
                break;
	    }
	}        
        if(links){
            this.read_wmc_OnlineResource(object,links);
	}
    } else {
        // for all other browsers including IE 8 or below.
	var links=node.getElementsByTagName("OnlineResource");
	if(links.length>0){
		this.read_wmc_OnlineResource(object,links[0]);
	}
    }		
    return object.href;
}


function getInternetExplorerVersion() {
    // Returns the version of Internet Explorer or a -1
    // (indicating the use of another browser).

    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null) {
            rv = parseFloat( RegExp.$1 );
        }
    }
    return rv;
}


Please confirm the above issue and tell me if this is indeed a bug, can we
merge this code to OL trunk and should I report this on OL dev forums?

Regards,
Ameet


Ameet wrote
> 
> I've moved a bit further on this issue. I am uploading the WMC file via a
> simple Ext form with 'file' inputType. A servlet returns this file to a
> javascript callback on success (like applyWMCToMap(cmp, response)). Using
> developer tools, I see that the response's type is DispHTMLDocument in IE
> 9 instead of IXMLDomDocument2 as in IE 8. This is because the form is
> marked as multipart/form-data. At other places, I read that it triggers
> Quirks mode for IE9, which assigns DispHTMLDocument type.
> 
> So the issue now is:
> 
> quirks mode in IE 9 assigns DispHTMLDocument type to the uploaded wmc xml
> document. quirks mode is  triggered by mutipart/form-data, but a form with
> 'file' inputType necessarily requires enctype to be multipart.. So how can
> I prevent triggering quirks mode in IE9 ? (or how can I upload file
> without mutipart enctype? )
> 
> *Note:* I have <meta http-equiv="X-UA-Compatible" content="IE=7"> defined
> as well, still quirks mode is triggered on file upload [Console msg:
> HTML1113: Document mode restart from IE9 Standards to Quirks]
> 


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/WMC-file-parsing-error-in-IE9-tp4975858p4977454.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list