import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
class SampleOfNamespacePrefixes extends DefaultHandler {
private Map namespaceMapping = new HashMap();
public void startPrefixMapping(String prefix, String uri) throws SAXException {
namespaceMapping.put(uri, prefix);
}
public void endPrefixMapping(String prefix) throws SAXException {
Iterator i = namespaceMapping.keySet().iterator();
for (; i.hasNext();) {
String uri = (String) i.next();
String uriPrefix = (String) namespaceMapping.get(uri);
if (prefix.equals(uriPrefix)) {
namespaceMapping.remove(uri);
break;
}
}
}
}
sources68 the directory containing the programming examples, source code and programming guide online
Monday, 1 August 2011
Handling namespaces during parsing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment