Hey Mike
 
I've added this test case to CVS in src/test/org/dom4j/TestXPathBug. The problem was the XPath.matches() method was returning true if anything was found. Now the source node must be returned in the XPath result set for the matches() to return true.
 
I've patched the code and checked this all into CVS. Its also available in the daily build. Thanks for spotting this one Mike!

James
----- Original Message -----
Sent: Monday, March 11, 2002 11:54 AM
Subject: [dom4j-dev] DefaultXPath.matches is still broken

Hi,

This is still broken in dom4j 1.2, or have I mis-understood the API

 

Mike

 

-----Original Message-----
From: Mike Skells [mailto:[EMAIL PROTECTED]]
Sent: Sunday 2 December 2001 00:30
To: 'Dom4j-Dev
Subject: DefaultXPath.matches is broken

 

Hi,

Seems to me that matches seems to match anything

Am I missing something?

Matched worked OK in 0.8, fails in 1.0 and 1.1

Any Ideas?

 

Test code

 

import org.dom4j.*;

import org.dom4j.xpath.*;

public class Bug {

 

    public static void main (String args[]) {

        Document top = DocumentFactory.getInstance().createDocument();

        Element root = top.addElement("root");

        root.addElement("child1").addElement("child11");

        root.addElement("child2").addElement("child21");

        System.out.println(top.asXML());

        XPath test1 = new DefaultXPath("/root/child1/child11");

        XPath test2 = new DefaultXPath("/root/child2/child21");

        Node position1 = test1.selectSingleNode(root);

        Node position2 = test2.selectSingleNode(root);

       

        System.out.println("test1= "+test1);

        System.out.println("test2= "+test2);

        System.out.println("Position1 Xpath = "+position1.getUniquePath());

        System.out.println("Position2 Xpath = "+position2.getUniquePath());

       

        System.out.println("test2.matches(position1) : "+test2.matches(position1));

       

    }

 

}

 

 

Mike Skells

eBizz Consulting

0774 052 0717

 

Reply via email to