Connecting Tech Pros Worldwide Help | Site Map

[sarissa] XPath

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 3rd, 2005, 04:45 PM
Christoph
Guest
 
Posts: n/a
Default [sarissa] XPath

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


  #2  
Old November 3rd, 2005, 05:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: [sarissa] XPath



Christoph wrote:

[color=blue]
> 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?[/color]

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/
  #3  
Old November 4th, 2005, 07:05 AM
Christoph
Guest
 
Posts: n/a
Default Re: XPath


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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.