Under the guise of providing better security, Internet Explorer will not recognize as XML any MIME type other than text/xml or application/xml, and then only when the URI (or Content-disposition header filename) ends with .xml [1]. (I say guise of better security, because a server or intercept that is determined to falsely label XML data can do so in any case: refusing to believe the server's content-type when the data properly conforms to that type does not help; maybe what they are really protecting against is Windows' flawed model of using the filename pattern to determine how to open a file.)
In our case, we use jQuery to request XML data, and pass the resulting jQuery XML object to rdfQuery to build a local RDF "databank" from which metadata can be extracted. On Firefox and Safari, this works just fine. But on Internet Explorer it fails with a "parseerror", which is generated by jQuery.ajax when the retrieved data does not match the requested xml type.
Fortunately, rdfQuery databank.load is also capable of parsing RDF from plain text as well as from a parsed XML document structure. So the fix is simple, albeit not immediately obvious: when performing the jQuery.ajax operation, request text rather than XML data. For example:
jQuery.ajax({
type: "GET",
url: "/admiral-test/datasets/"+datasetName,
username: "...",
password: "...",
dataType: "text", // To work on IE, NOT "xml"!
cache: false
beforeSend: function (xhr)
{
xhr.setRequestHeader("Accept", "application/rdf+xml");
},
success: function (data, status, xhr)
{
var databank = jQuery.rdf.databank();
databank.load(data);
...
},
error: function (xhr, status)
{
...
},
});
Sigh!
[1] http://technet.microsoft.com/en-us/library/cc787872(WS.10).aspx
No comments:
Post a Comment