}
  final void addNamespaceNodes(Node source, Node target, Document doc,                               Collection elementExcludeResultPrefixes)  {    NamedNodeMap attrs = source.getAttributes();    if (attrs != null)      {        int len = attrs.getLength();        for (int i = 0; i < len; i++)          {            Node attr = attrs.item(i);            String uri = attr.getNamespaceURI();            if (uri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI)              {                String prefix = attr.getLocalName();                if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))                  {                    prefix = "#default";                  }                String ns = attr.getNodeValue();                // Should the namespace be excluded?                if (XSL_NS.equals(ns) ||                    extensionElementPrefixes.contains(prefix) ||                    elementExcludeResultPrefixes.contains(prefix) ||                    excludeResultPrefixes.contains(prefix))                  {                    continue;                  }                // Is the namespace already defined on the target?                if (prefix == "#default")                  {                    prefix = null;                  }                if (target.lookupNamespaceURI(prefix) != null)                  {                    continue;                  }                attr = attr.cloneNode(true);                attr = doc.adoptNode(attr);                target.getAttributes().setNamedItemNS(attr);              }          }      }    Node parent = source.getParentNode();    if (parent != null)      {        addNamespaceNodes(parent, target, doc, elementExcludeResultPrefixes);      }  }