Here you can find the source of getRequiredNamespaceDeclaration(String localName, Element element)
public static Node getRequiredNamespaceDeclaration(String localName, Element element)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; public class Main { public static Node getRequiredNamespaceDeclaration(String localName, Element element) { Node node = getNamespaceDeclarationOrNull(localName, element); if (node == null) { throw new IllegalStateException( String.format("Namespace declaration for prefix '%s' not found", localName)); }/* w w w . j a v a 2 s. c o m*/ return node; } public static Node getNamespaceDeclarationOrNull(String localName, Element element) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node node = map.item(i); String nsUri = node.getNamespaceURI(); if (nsUri == null) { continue; } if ("http://www.w3.org/2000/xmlns/".equals(nsUri) && localName.equals(node.getLocalName())) { return node; } } return null; } }