* is no such element. This relies on the getElementById() method in the
* underlying DOM.
*/
public NodeInfo selectID(String id) {
Node el;
// IE does not support getElementById for XML documents
// but it does support it for XHTML if its the host page
Document doc = ((Document)node);
if (!isHttpRequested) {
el = (doc).getElementById(id);
if (el == null) {
return null;
}
return wrap(el);
} else {
if (idIndex != null) {
return idIndex.get(id);
} else {
idIndex = new HashMap();
AxisIterator iter = iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT);
boolean useNS = isNSok(node);
while (true) {
NodeInfo node = (NodeInfo)iter.next();
if (node == null) {
break;
}
Node testNode = (Node)((HTMLNodeWrapper)node).getUnderlyingNode();
String xmlId = (useNS)? getXmlIdNS(testNode) : getXmlId(testNode);
//String xmlId = ((Element)((HTMLNodeWrapper)node).getUnderlyingNode()).getAttribute("xml:id");
if (xmlId != null && !xmlId.isEmpty()) {
idIndex.put(xmlId, (HTMLNodeWrapper)node);
}