if(((type == Node.ELEMENT_NODE) || (type == Node.ATTRIBUTE_NODE)) && null == localName) localName = node.getNodeName();
  protected int addNode(Node node, int level, int parentIndex,                        int previousSibling, int forceNodeType)  {    int nodeIndex = m_nodes.size();    m_size++;    ensureSize(nodeIndex);        int type;    if(NULL==forceNodeType)	type = node.getNodeType();    else	type=forceNodeType;        m_nodes.addElement(node);        // Do casts here so that if we change the sizes, the changes are localized.    // %REVIEW% Remember to change this cast if we change    // m_level's type, or we may truncate values without warning!    m_level[nodeIndex] = (byte)level;    // %REVIEW% The Namespace Spec currently says that Namespaces are    // processed in a non-namespace-aware manner, by matching the    // QName, even though there is in fact a namespace assigned to    // these nodes in the DOM. If and when that changes, we will have    // to consider whether we check the namespace-for-namespaces    // rather than the node name.    //    // %TBD% Note that the DOM does not necessarily explicitly declare    // all the namespaces it uses. DOM Level 3 will introduce a    // namespace-normalization operation which reconciles that, and we    // can request that users invoke it or otherwise ensure that the    // tree is namespace-well-formed before passing the DOM to Xalan.    // But if they don't, what should we do about it? We probably    // don't want to alter the source DOM (and may not be able to do    // so if it's read-only). The best available answer might be to    // synthesize additional DTM Namespace Nodes that don't correspond    // to DOM Attr Nodes.    if (Node.ATTRIBUTE_NODE == type)    {      String name = node.getNodeName();      if (name.startsWith("xmlns:") || name.equals("xmlns"))      {        type = DTM.NAMESPACE_NODE;        declareNamespaceInContext(parentIndex,nodeIndex);      }    }        m_firstch[nodeIndex] = NOTPROCESSED;    m_nextsib[nodeIndex] = NOTPROCESSED;    m_prevsib[nodeIndex] = previousSibling;    m_parent[nodeIndex] = parentIndex;        if(DTM.NULL != parentIndex &&        type != DTM.ATTRIBUTE_NODE &&        type != DTM.NAMESPACE_NODE)    {      // If the DTM parent had no children, this becomes its first child.      if(NOTPROCESSED == m_firstch[parentIndex])        m_firstch[parentIndex] = nodeIndex;    }        String nsURI = node.getNamespaceURI();    // Deal with the difference between Namespace spec and XSLT    // definitions of local name. (The former says PIs don't have    // localnames; the latter says they do.)    String localName =  (type == Node.PROCESSING_INSTRUCTION_NODE) ?                          node.getNodeName() :                         node.getLocalName();    ExpandedNameTable exnt = m_expandedNameTable;    // %TBD% Nodes created with the old non-namespace-aware DOM    // calls createElement() and createAttribute() will never have a    // localname. That will cause their expandedNameID to be just the    // nodeType... which will keep them from being matched    // successfully by name. Since the DOM makes no promise that    // those will participate in namespace processing, this is    // officially accepted as Not Our Fault. But it might be nice to    // issue a diagnostic message!    if(node.getLocalName()==null &&       (type==Node.ELEMENT_NODE || type==Node.ATTRIBUTE_NODE))      {        // warning("DOM 'level 1' node "+node.getNodeName()+" won't be mapped properly in DOM2DTM.");      }        int expandedNameID = (null != localName)        ? exnt.getExpandedTypeID(nsURI, localName, type) :         exnt.getExpandedTypeID(type);    m_exptype[nodeIndex]  = expandedNameID;        indexNode(expandedNameID, nodeIndex);    if (DTM.NULL != previousSibling)      m_nextsib[previousSibling] = nodeIndex;    return nodeIndex;  }