On Thu, May 31, 2001 at 10:00:40PM -0400, bob mcwhirter wrote:
>> if(getName().equalsIgnoreCase(eltTmp.getName())){
>> i++;
>
>I'd personally just use equals(), since XML tags are case-sensitive.
>This could produce bogus paths:
>
> <a>
> <b/>
> <B/>
> </a>
>
>One is /a/b[1], while the other is /a/B[1]. Neither
>is /a/b[2] or /a/B[2].
Note also that the original method produced completely accurate XPaths,
and this greater specificity may not always be what is wanted. That
is, without this modification, the resultant XPath produces a node-set;
with this modification, the XPath in general will produce a node-set
with a single member. Both applications have utility. The greater
specificity is also more frangible: change something, even if it is not
in the ancestor axis for the node in question, and there's the
possibility that it will make this XPath point at the wrong thing (for
instance, in /root/nodeA[1]/nodeB[2]/@attribute, removing nodeB[1]
while you have a reference to this XPath may result in an empty
node-set, even though the XPath was generated from an existing node,
and none of that node's ancestors have been modified).
Amy!
--
Amelia A. Lewis [EMAIL PROTECTED] [EMAIL PROTECTED]
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev