use of org.apache.axiom.om.OMContainer in project webservices-axiom by apache.
the class OMXMLReader method generateParentPrefixMappingEvents.
private void generateParentPrefixMappingEvents(OMElement omElement, boolean start) throws SAXException {
if (!(omElement.getParent() instanceof OMElement)) {
return;
}
// Maintain a set of the prefixes we have already seen. This is required to take into
// account that a namespace mapping declared on an element can hide another one declared
// for the same prefix on an ancestor of the element.
Set /*<String>*/
seenPrefixes = new HashSet();
for (Iterator it = omElement.getAllDeclaredNamespaces(); it.hasNext(); ) {
seenPrefixes.add(((OMNamespace) it.next()).getPrefix());
}
OMElement current = omElement;
while (true) {
OMContainer parent = current.getParent();
if (!(parent instanceof OMElement)) {
return;
}
current = (OMElement) parent;
for (Iterator it = current.getAllDeclaredNamespaces(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace) it.next();
if (seenPrefixes.add(ns.getPrefix())) {
generatePrefixMappingEvents(ns, start);
}
}
}
}
Aggregations