Example usage for javax.xml.stream.events EndElement getNamespaces

List of usage examples for javax.xml.stream.events EndElement getNamespaces

Introduction

In this page you can find the example usage for javax.xml.stream.events EndElement getNamespaces.

Prototype

public Iterator<Namespace> getNamespaces();

Source Link

Document

Returns an Iterator of namespaces that have gone out of scope.

Usage

From source file:com.xiongyingqi.util.xml.XMLEventStreamWriter.java

private void writeNamespace(Namespace namespace) throws XMLStreamException {
    int last = endElements.size() - 1;
    EndElement oldEndElement = endElements.get(last);
    Iterator oldNamespaces = oldEndElement.getNamespaces();
    List<Namespace> newNamespaces = new ArrayList<Namespace>();
    while (oldNamespaces.hasNext()) {
        Namespace oldNamespace = (Namespace) oldNamespaces.next();
        newNamespaces.add(oldNamespace);
    }// www.ja  v a2  s  .c  o  m
    newNamespaces.add(namespace);
    EndElement newEndElement = eventFactory.createEndElement(oldEndElement.getName(), newNamespaces.iterator());
    eventWriter.add(namespace);
    endElements.set(last, newEndElement);
}