Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1
-
Fix Version/s: 1.1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
From: Anna Afonchenko <anna@ubaccess.com>
To: jaxen-interest@lists.codehaus.org
I am using Jaxen to evaluate XPath expressions in Java (JDOM).
I encountered problems when comparing results returned by jaxen with
results returned by other XPath implementation - I was using Saxon.
Here is my example:
<html>
<head>
</head>
<body>
<p>
<span>text1</span>
</p>
<div>text2</div>
</body>
</html>
I want to get the first preceding element of the div element.
I apply the following XPath - //div/preceding::*[1]
Saxon results in span element matched.
Jaxen results in p element matched.
What I want is the span element.
This looks similar to
JAXEN-21, but it isn't..JAXEN-21is actually misreported.Here is some code that reproduces this issue:
import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
import org.jaxen.jdom.JDOMXPath;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class TestJ {
public static void main(String[] args) throws Exception { XMLOutputter outputter = new XMLOutputter(); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build( new StringReader( new String("<html><head> </head> <body> <p> <span> text1 </span> </p> <div> text2 </div> </body> </html>"))); JDOMXPath query = new JDOMXPath("//div/preceding::*"); List set = query.selectNodes(doc); for (Iterator iter=set.iterator();iter.hasNext();) System.out.println(iter.next()); outputter.output(set, System.out); }
}
JAXEN-21, but it isn't..JAXEN-21is actually misreported. Here is some code that reproduces this issue: import java.io.StringReader; import java.util.Iterator; import java.util.List; import org.jaxen.jdom.JDOMXPath; import org.jdom.Document; import org.jdom.input.SAXBuilder; import org.jdom.output.XMLOutputter; public class TestJ { public static void main(String[] args) throws Exception { XMLOutputter outputter = new XMLOutputter(); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build( new StringReader( new String("<html><head> </head> <body> <p> <span> text1 </span> </p> <div> text2 </div> </body> </html>"))); JDOMXPath query = new JDOMXPath("//div/preceding::*"); List set = query.selectNodes(doc); for (Iterator iter=set.iterator();iter.hasNext();) System.out.println(iter.next()); outputter.output(set, System.out); } }