private void extractNamespacesFromNode(Node node) {
		if (node.getParentNode() == null) {
			node = node.getFirstChild();
		}

		NamedNodeMap attrs = node.getAttributes();

		for (int i = 0; i < attrs.getLength(); i++) {
			Node attr = attrs.item(i);
			String name = attr.getNodeName();
			if (isDefaultNS(name) && defaultNSURI == null) {
				defaultNSURI = attr.getNodeValue();
			} else if (isPrefix(name)) {
				String prefix = prefixStringIn(name);
				String uri = attr.getNodeValue();
				if (!namespaces.containsKey(prefix)) {
					namespaces.put(prefix, uri);
				}
			}
		}

		Node parent = node.getParentNode();
		if (parent.getNodeType() == Node.ELEMENT_NODE) {
			extractNamespacesFromNode(parent);
		} else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
			if (defaultNSURI == null) {
				defaultNSURI = XMLConstants.NULL_NS_URI;
			}
		}
	}