Hi Dave,
According to the Dom4j API documentation and your examplean example.boolean exists = node.matches( "/order/customer/name" ); List nodeList = node.selectNodes( "/order/customer/name" );
variable 'exists' should return true as you expect.
But according to the method's name this is no more true.
My guess is that since 1.3 the behaviour of the matches() method
has been *corrected* to do what the meaning of the
method's name let us assume. Howeever the the API documentation
for this method remains missleading. According to the method's name i would say that node.matches(XPathExp) returns true *only* if 'node' is contained in the nodeset resulting of the XPathExp evaluation.
In other words, using your example :
node.matches( "/order/customer/name" )
is equivalent to:
in 1.3 : node.selectNodes( "/order/customer/name").contains(node)
which reflects the meaning of the method's name and not
in 1.2 : !node.selectNodes( "/order/customer/name").isEmpty()
which reflects the API but is not in accordance with the name "matches()"
Thus exists should be only if your node is
in the nodeset "/order/customer/name", that is your node
is a 'name' element in a 'customer' etc...
Again this is my guess, i am not 100% sure about it and it
has to be confirmed by the Dom4J team.
If confirmed, Dom4J API could be update to avoid ambiguity
API Doc for matches():
'matches' returns true if evaluating the given XPath expression on this node returns *[true or a non-empty node set. So calling this method is equivalent to calling <xsl:if test="xpathExpression"/> in XSLT.]*
could become something like:
*matches* returns true if evaluating the given XPath expression on this node a non-empty node set containing the node itself.
Talking API since Node.matches() does now the right job
shouldn't we considere adding a test() method in the Node API
in Node : boolean test(String "XPathExp")
that would take over the 1.2 behaviour of matches() and fit to the deprecated API documentation so that we got again a method equivalent to the XSLT 'test' attribute in the <xsl:if>
element.
Sincerely,
Thierry
-----------------------------------------------------------------------
IXELIS - Systèmes d'Information Sémantique
http://www.ixelis.com
17 rue des Cèdres, F67200 STRASBOURG (France)
Tél : +33 (0)3 88 27 81 39 Portable : 06 30 07 65 73
E-mail : [EMAIL PROTECTED] Fax : +33 (0)3 88 27 81 39
-----------------------------------------------------------------------
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user