code: private static void fillNSMapWithPrefixesDeclaredInElement(final Map<String, String> nsMap, final Element element) throws DOMException {
          NamedNodeMap attributes = element.getAttributes();
          for (int i = 0; i < attributes.getLength(); i++) {
              Node attribute = attributes.item(i);
              if ((!XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getPrefix())) && (!XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getLocalName()))) {
                  continue;
              }
              if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getLocalName())) {
                  nsMap.put("xbdefaultns", attribute.getNodeValue());
                  continue;
              }
              nsMap.put(attribute.getLocalName(), attribute.getNodeValue());
          }
          NodeList childNodes = element.getChildNodes();
          for (Node n : nodeListToIterator(childNodes)) {
              if (n.getNodeType() != Node.ELEMENT_NODE) {
                  continue;
              }
              fillNSMapWithPrefixesDeclaredInElement(nsMap, (Element) n);
          }
      }
docs: Search for prefix definitions in element and all children. There still is an issue for
  documents that use the same prefix on differen namespaces in disjunct subtrees. This might be
  possible but we won't support this. Same is with declaring multiple default namespaces.
  XMLBeams behaviour will be undefined in that case. There is a workaround by defining a custom
  namespace/prefix mapping, so the effort to support this is not justified.
  
  @param nsMap
  @param element
  @throws DOMException