Я пытаюсь работать со следующим кодом, я получаю эту ошибку на xsltProcessor.importStylesheet
Ошибка при удалении: xhttp.send(null);
uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIXSLTProcessor.importStylesheet]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: file:///C:/Users/bobby/Desktop/geocoding.html :: displayResult :: line 35" data: no]
Line 0
Ошибка, когда у меня есть: xhttp.send(null);
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/bobby/Desktop/geocoding.html :: loadXMLDoc :: line 16" data: no]
Line 0
Мой HTML-файл:
<html>
<head>
<script>
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false");
alert("successful call to xml");
xsl=loadXMLDoc("latitude.xsl");
alert("successful applying style sheet");
// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onload="displayResult()">
<div id="example" />
</body>
</html>
Моя таблица стилей Xslt по запросу:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Latitude Longitute finder</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Latitude</th>
<th>Longitude</th>
</tr>
<tr>
<td><xsl:value-of select="GeocodeResponse/result/geometry/location/lat"/></td>
<td><xsl:value-of select="GeocodeResponse/result/geometry/location/lng"/></td>
<td><xsl:value-of select="GeocodeResponse/result/type"/></td>
<td><xsl:value-of select="GeocodeResponse/result/formatted_address"/></td>
<td><xsl:value-of select="GeocodeResponse/result/address_component/long_name"/></td>
<td><xsl:value-of select="GeocodeResponse/result/address_component/short_name"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>