public static Map<String, String> mapifyAttrs(Node node, Map<String, String> overwrite) {
        Map<String, String> map = new HashMap<>();
        NamedNodeMap nnMap = node.getAttributes();
        for (int i = 0; i < nnMap.getLength(); i++) {
            Node attr = nnMap.item(i);
            map.put(attr.getNodeName(), attr.getNodeValue());
        }
        if (overwrite != null) {
            for (Map.Entry<String, String> e : overwrite.entrySet()) {
                map.put(e.getKey(), e.getValue());
            }
        }
        return map;
    }
This grabs the attributes from a dom node and overwrites those values with those
specified by the overwrite map.

@param node      node for building
@param overwrite map of attributes to overwrite
@return map of attributes
tika-batch/src/main/java/org/apache/tika/util/XMLDOMUtil.java