I am trying to request an xml file using xslt called by javascript.
Here is the main page:
<html> <head> <script> function loadXMLDoc(dname) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",dname,false); xhttp.send(""); return xhttp.responseXML; } function displayResult() { xml=loadXMLDoc("FooBar.xml"); xsl=loadXMLDoc("FooBar.xsl"); </script> </head> <body onload="displayResult()"> <div id="Main"> </div> </body> </html>
The xml file is simple:
<?xml version="1.0" standalone="yes"?> <Foobars xmlns:xs="http://www.w3.org/2001/XMLSchema"> <Foobar> <numFoobar>1</numFoobar> <nameFoobar>Foo</numFoobar> </Foobar> <Foobar> <numFoobar>2r</numFoobar> <nameFoobar>Bar</nameFoobar> </Foobar> </Foobars>
and for xslt :
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <table border="2" bgcolor="yellow"> <tr> <th>Num</th> <th>Name</th> </tr> <xsl:param name="numFoobar" <xsl:for-each select="Foobars/Foobar"> <tr> <td><xsl:value-of select="numFoobar"/></td> <td><xsl:value-of select="nameFoobar"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
As you can see, in the xslt file I added a parameter. I use it in javascript to filter by numFoobar .
The problem is that Safari returns this error:
TypeError: Result of expression 'xsltProcessor.addParameter' [undefined] is not a function.
So why is addParameter not recognized?
Thanks,
Sincerely.
source share