public int getFirstNamespaceNode ( int nodeHandle , boolean inScope ) { if ( inScope ) { int identity = makeNodeIdentity ( nodeHandle ) ; if ( _type ( identity ) == DTM . ELEMENT_NODE ) { SuballocatedIntVector nsContext = findNamespaceContext ( identity ) ; if ( nsContext == null || nsContext . size ( ) < 1 ) return NULL ; return nsContext . elementAt ( 0 ) ; } else return NULL ; } else { // Assume that attributes and namespaces immediately // follow the element. // // %OPT% Would things be faster if all NS nodes were built // before all Attr nodes? Some costs at build time for 2nd // pass... int identity = makeNodeIdentity ( nodeHandle ) ; if ( _type ( identity ) == DTM . ELEMENT_NODE ) { while ( DTM . NULL != ( identity = getNextNodeIdentity ( identity ) ) ) { int type = _type ( identity ) ; if ( type == DTM . NAMESPACE_NODE ) return makeNodeHandle ( identity ) ; else if ( DTM . ATTRIBUTE_NODE != type ) break ; } return NULL ; } else return NULL ; } }
Given a node handle get the index of the node s first child . If not yet resolved waits for more nodes to be added to the document and tries again