[sarissa] XPath

C

Christoph

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:eek:utput 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));
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>
 
M

Martin Honnen

Christoph wrote:

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?

Firefox replies? Does that mean you get that message as an error message
in the JavaScript console?
Then there usually is the line number and URL of the HTML or JavaScript
document the error occurs in?
So those details should be provided if you want help.
And it might make more sense to ask in the Sarissa specific place like
<https://sourceforge.net/forum/forum.php?forum_id=256492>
Looks that recently someone else there already had problems with that
example.
 
C

Christoph

Thanks, the answer from the sarissa group is the following.

Regards,
Christoph

The extra thing I needed was just an include for the
sarissa_ieemu_xpath.js script.

I definitely also needed:
xmlDoc = parser.parseFromString( xmlStr, "text/xml" );
instead of:
xmlDoc.(new DOMParser()).parseFromString(xmlStr, "text/xml");

And the line:
var xmlDoc = Sarissa.getDomDocument();

is not necessary at all.
However, the xmlDoc.setProperty's do work now.

Can the example be fixed?

Regards,

[)o
IhIL..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top