Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > [sarissa] XPath

Reply
Thread Tools

[sarissa] XPath

 
 
Christoph
Guest
Posts: n/a
 
      11-03-2005
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'
xmlnssl='http://www.w3.org/1999/XSL/Transform'>"+
"<xslutput 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",
"xmlnssl='http://www.w3.org/1999/XSL/Transform'");
xmlDoc.setProperty("SelectionLanguage", "XPath");

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

testSelectNodesOn((xmlDoc.documentElement.getEleme ntsByTagName("*"))[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>

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-03-2005


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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Christoph
Guest
Posts: n/a
 
      11-04-2005

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..

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57