[XML-SIG] XPath's reliance on id()

Martin v. Loewis martin@v.loewis.de
13 Mar 2002 19:05:19 +0100

Martijn Faassen <faassen@vet.uu.nl> writes:

> Now, it's hard to see how to make this code work without some hashing,
> so we seem to have to rely on *something*. But can't we make it 
> use __hash__ instead of using id? I think I can make this work for
> ParsedXML (in fact I tried and at least it's not giving any errors).

I think this approach (for determining document order) really does
need the notion of identity, so it's hard to believe that this could
actually work.

>   * all DOMs that expect to work with PyXML's xpath need to define 
>     __hash__(). In the simplest case this simply does an id() on the
>    node.

Those DOMs that use Python classes would not need to do anything at
all, right?

>   * we need to alter the code in xpath/Util.py so as not to rely on
>     id() anymore but to use the node objects as hash keys directly. 

Then doing what? What happens if you have two nodes that have the same
hash value, but which are different?

Do you think you could make this work by giving each ParseXML Node a
docIndex attribute? With that, SortByDocOrder would not even attempt
to put node ids into a dictionary.