public int getHandleOfNode ( Node node ) { if ( null != node ) { // Is Node actually within the same document? If not, don't search! // This would be easier if m_root was always the Document node, but // we decided to allow wrapping a DTM around a subtree. if ( ( m_root == node ) || ( m_root . getNodeType ( ) == DOCUMENT_NODE && m_root == node . getOwnerDocument ( ) ) || ( m_root . getNodeType ( ) != DOCUMENT_NODE && m_root . getOwnerDocument ( ) == node . getOwnerDocument ( ) ) ) { // If node _is_ in m_root's tree, find its handle // // %OPT% This check may be improved significantly when DOM // Level 3 nodeKey and relative-order tests become // available! for ( Node cursor = node ; cursor != null ; cursor = ( cursor . getNodeType ( ) != ATTRIBUTE_NODE ) ? cursor . getParentNode ( ) : ( ( org . w3c . dom . Attr ) cursor ) . getOwnerElement ( ) ) { if ( cursor == m_root ) // We know this node; find its handle. return getHandleFromNode ( node ) ; } // for ancestors of node } // if node and m_root in same Document } // if node!=null return DTM . NULL ; }
Get the handle from a Node . This is a more robust version of getHandleFromNode intended to be usable by the public .