Java Code Examples for javax.xml.stream.XMLStreamReader#getPrefix()
The following examples show how to use
javax.xml.stream.XMLStreamReader#getPrefix() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLSupport.java From FHIR with Apache License 2.0 | 6 votes |
private static void writeStartElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { String prefix = reader.getPrefix(); String namespaceURI = reader.getNamespaceURI(); String localName = reader.getLocalName(); if (namespaceURI != null) { if (prefix != null) { writer.writeStartElement(prefix, localName, namespaceURI); } else { writer.setDefaultNamespace(namespaceURI); writer.writeStartElement(namespaceURI, localName); } } else { writer.writeStartElement(localName); } writeNamespaces(reader, writer); writeAttributes(reader, writer); }
Example 2
Source File: DomReader.java From cosmo with Apache License 2.0 | 6 votes |
private static Element readElement(Document d, XMLStreamReader reader) throws XMLStreamException { Element e = null; 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); } 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; }
Example 3
Source File: XmlFormatter.java From hop with Apache License 2.0 | 5 votes |
public StartElementBuffer( XMLStreamReader rd ) { prefix = rd.getPrefix(); namespace = rd.getNamespaceURI(); localName = rd.getLocalName(); for ( int i = 0; i < rd.getAttributeCount(); i++ ) { attrBuffer.add( new AttrBuffer( rd, i ) ); } }
Example 4
Source File: BaseStAXUT.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Specific method makes sense, since earlier it was not clear whether null * or empty string (or perhaps both) would be the right answer when there is * no prefix. * <p> * However: as per javadocs of {@link XMLStreamReader#getPrefix}, from JDK * 1.6 indicate, the current understanding is that <b>null</b> is the * ultimate right answer here. */ protected static void assertNoPrefix(XMLStreamReader sr) throws XMLStreamException { String prefix = sr.getPrefix(); if (prefix != null) { if (prefix.length() != 0) { Assert.fail("Current element should not have a prefix: got '" + prefix + "'"); } else { Assert.fail("Expected null to signify missing prefix (see XMLStreamReader#getPrefix() JavaDocs): got empty String"); } } }
Example 5
Source File: StreamWriterFacade.java From yangtools with Eclipse Public License 1.0 | 5 votes |
private void forwardStartElement(final XMLStreamReader reader) throws XMLStreamException { final String localName = reader.getLocalName(); final String prefix = reader.getPrefix(); if (prefix != null) { writer.writeStartElement(prefix, localName, reader.getNamespaceURI()); } else { writer.writeStartElement(localName); } forwardNamespaces(reader); forwardAttributes(reader); }
Example 6
Source File: XMLFormatter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public StartElementBuffer( XMLStreamReader rd ) { prefix = rd.getPrefix(); namespace = rd.getNamespaceURI(); localName = rd.getLocalName(); for ( int i = 0; i < rd.getAttributeCount(); i++ ) { attrBuffer.add( new AttrBuffer( rd, i ) ); } }