[sarissa] XPath
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

[sarissa] XPath

From: Christoph <wieser@gmail.com>
Date: Thu Nov 03 2005 - 18:39:11 CET

Hello,

I found the following XHTML document for testing sarissa's XPath
implementation at http://sarissa.sourceforge.net/doc/. I replaced
"Sarissa_0-9b3.js" in the test document below by "sarissa.js" from
sarissa0.9.6.1. Loading the document Firefox replies "XML filtering
predicate operator called on incompatible XMLDocument". What's wrong?

Thanks in advance,
Christoph

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Untitled</title>
    <script type="text/javascript" src="Sarissa_0-9b3.js">
    </script>
    <script type="text/javascript">
    <!--
function testXpath()
{
    var xmlDoc = Sarissa.getDomDocument();
    var objNodeList;
    var xmlStr = "<?xml version='1.0' encoding='UTF-8'?>"+
        "<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>"+
        "<xsl:output method='xml' version='1.0' encoding='UTF-8'
indent='yes'/>"+
        "<xsl:template match='*'></xsl:template><xsl:template
match='@*'>"+
        "</xsl:template></xsl:stylesheet>";
        xmlDoc.(new DOMParser()).parseFromString(xmlStr, "text/xml");

    // the following two lines are needed for IE
    xmlDoc.setProperty("SelectionNamespaces",
"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
    xmlDoc.setProperty("SelectionLanguage", "XPath");

    testSelectNodesOn(xmlDoc, "//xsl:template");
    testSelectNodesOn(xmlDoc.documentElement, "//xsl:template");

testSelectNodesOn((xmlDoc.documentElement.getElementsByTagName("*"))[0],
"//xsl:template");
}
function testSelectNodesOn(domNode, sXpath)
{
    alert("testing selectNodes("+sXpath+") on a "+domNode);
    var objNodeList = domNode.selectNodes(sXpath);
    for(i=0;i<objNodeList.length;i++)
        alert(Sarissa.serialize(objNodeList[i]));
    alert("testing selectSingleNode("+sXpath+") on a "+domNode);
    var oElem = domNode.selectSingleNode(sXpath);
    alert(oElem+"\n"+Sarissa.serialize(oElem));
};
    //-->
    </script>
</head>

<body>
<button onclick="testXpath()">test xpath</button>
</body>
</html>
Received on Mon Nov 21 03:18:02 2005