if(ns==null)ns="";
  public static void cloneToResultTree(int node, int nodeType, DTM dtm,                                              ResultTreeHandler rth,                                             boolean shouldCloneAttributes)    throws TransformerException  {    try    {      switch (nodeType)      {      case DTM.TEXT_NODE :        dtm.dispatchCharactersEvents(node, rth, false);        break;      case DTM.DOCUMENT_FRAGMENT_NODE :      case DTM.DOCUMENT_NODE :        // Can't clone a document, but refrain from throwing an error        // so that copy-of will work        break;      case DTM.ELEMENT_NODE :        {          Attributes atts;          if (shouldCloneAttributes)          {            rth.addAttributes(node);            rth.processNSDecls(node, nodeType, dtm);          }          String ns = dtm.getNamespaceURI(node);          String localName = dtm.getLocalName(node);          rth.startElement(ns, localName, dtm.getNodeNameX(node), null);        }        break;      case DTM.CDATA_SECTION_NODE :        rth.startCDATA();                  dtm.dispatchCharactersEvents(node, rth, false);        rth.endCDATA();        break;      case DTM.ATTRIBUTE_NODE :        rth.addAttribute(node);        break;      case DTM.COMMENT_NODE :        XMLString xstr = dtm.getStringValue (node);        xstr.dispatchAsComment(rth);        break;      case DTM.ENTITY_REFERENCE_NODE :        rth.entityReference(dtm.getNodeNameX(node));        break;      case DTM.PROCESSING_INSTRUCTION_NODE :        {          // %REVIEW% Is the node name the same as the "target"?          rth.processingInstruction(dtm.getNodeNameX(node),                                       dtm.getNodeValue(node));        }        break;      default :        //"Can not create item in result tree: "+node.getNodeName());        throw new  TransformerException(                         "Can't clone node: "+dtm.getNodeName(node));      }    }    catch(org.xml.sax.SAXException se)    {      throw new TransformerException(se);    }  }  // end cloneToResultTree function