if (event == null) return null; // end of stream
if (event.type == XMLEvent.DOCUMENT && !((DocumentEvent) event).start) return null; // end of stream
if (event.type == XMLEvent.PREFIX_MAPPING) {
// namespace directive found
PrefixMappingEvent prefixMappingEvent = (PrefixMappingEvent) event;
String prefix = prefixMappingEvent.prefix;
if (prefixesToNamespace.containsKey(prefix)) {
throw new IllegalStateException("nested namespaces not supported by currently parser. xmlns=" + prefix);
}
prefixesToNamespace.put(prefix, prefixMappingEvent.uri);