You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Martin Bernauer <be...@big.tuwien.ac.at> on 2003/10/28 14:09:08 UTC

Node identifier

Hello all,

my application is in need of a document-wide unique node-id for every node
in a DOM tree. These ids should be persistent, i.e., uniquely exist as long
as the document existst and not as long as the identified node exists.

I was wondering if an implementation class of Xerces provides such a
feature? After a look at the API I only found int NodeImpl.getNodeNumber().
Is the returned number an id or is it, e.g., a position? (I wasn't able to
find anything about it)

Otherwise, does the possibility exist to write a wrapper class around
NodeImpl and configure Xerces so that it instantiates the wrapper instead of
NodeImpl?

Kind regards,
Martin Bernauer


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Node identifier

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
A completely portable, low-tech, arms-length solution would be to construct
the document, then traverse it to construct one or both of the Maps,
Node->Id and Id->Node, assigning the Id as you go.

Each modification of the document thereafter could traverse the affected
subtree and add to the maps, first checking each node in the Node->Id map to
see if had already been encountered.

Jeff

----- Original Message ----- 
From: "Martin Bernauer" <be...@big.tuwien.ac.at>
To: <xe...@xml.apache.org>
Sent: Tuesday, October 28, 2003 5:09 AM
Subject: Node identifier


Hello all,

my application is in need of a document-wide unique node-id for every node
in a DOM tree. These ids should be persistent, i.e., uniquely exist as long
as the document existst and not as long as the identified node exists.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Node identifier

Posted by Joseph Kesselman <ke...@us.ibm.com>.



The most portable nonportable solution is probably to use the (DOM Level 3
prototype) userData hook to associate your own generated identifiers with
each node.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org