Here you can find the source of createNamespaceContext(final String nsPrefix, final String nsUri)
public static NamespaceContext createNamespaceContext(final String nsPrefix, final String nsUri)
//package com.java2s; //License from project: LGPL import java.util.Iterator; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; public class Main { public static NamespaceContext createNamespaceContext(final String nsPrefix, final String nsUri) { return new NamespaceContext() { public String getNamespaceURI(String prefix) { if (prefix.equals(nsPrefix)) { return nsUri; } else { return XMLConstants.NULL_NS_URI; }//from w w w. j ava 2 s.c om } public String getPrefix(String namespace) { if (namespace.equals(nsUri)) { return nsPrefix; } else { return null; } } public Iterator<String> getPrefixes(String namespace) { return null; } }; } }