Example usage for javax.xml.stream XMLStreamReader getNamespaceURI

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

Introduction

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

Prototype

public String getNamespaceURI();

Source Link

Document

If the current event is a START_ELEMENT or END_ELEMENT this method returns the URI of the prefix or the default namespace.

Usage

From source file:org.osaf.cosmo.xml.DomReader.java

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

    String local = reader.getLocalName();
    String ns = reader.getNamespaceURI();
    if (ns != null) {
        String prefix = reader.getPrefix();
        String qualified = prefix != null ? 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;
}

From source file:org.slc.sli.modeling.wadl.reader.WadlReader.java

private static final void skipForeignNamespaceElement(final XMLStreamReader reader) throws XMLStreamException {
    final String namespaceURI = reader.getNamespaceURI();
    if (!WadlSyntax.NAMESPACE.equals(namespaceURI)) {
        skipElementReally(reader);/*from w w w  .j a v  a2  s  .c o  m*/
    } else {
        throw new AssertionError(reader.getName());
    }
}

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

private static Element readElement(Document d, XMLStreamReader reader) throws XMLStreamException {
    Element e = null;/*w  w  w.j  ava2  s.com*/

    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;
}