Example usage for javax.xml.stream XMLStreamReader getPrefix

List of usage examples for javax.xml.stream XMLStreamReader getPrefix

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamReader getPrefix.

Prototype

public String getPrefix();

Source Link

Document

Returns the prefix of the current event or null if the event does not have a prefix

Usage

From source file:org.unitedinternet.cosmo.util.DomReader.java

private static Element readElement(Document d, XMLStreamReader reader) throws XMLStreamException {
    Element e = null;/*from  w  w w. jav  a 2s .c  o  m*/

    String local = reader.getLocalName();
    String ns = reader.getNamespaceURI();
    if (ns != null && !ns.equals("")) {
        String prefix = reader.getPrefix();
        String qualified = prefix != null && !prefix.isEmpty() ? prefix + ":" + local : local;
        e = d.createElementNS(ns, qualified);
    } else {
        e = d.createElement(local);
    }

    //if (log.isDebugEnabled())
    //log.debug("Reading element " + e.getTagName());

    for (int i = 0; i < reader.getAttributeCount(); i++) {
        Attr a = readAttribute(i, d, reader);
        if (a.getNamespaceURI() != null) {
            e.setAttributeNodeNS(a);
        } else {
            e.setAttributeNode(a);
        }
    }

    return e;
}