|
Apache CXF example source code file (StaxUtils.java)
The Apache CXF StaxUtils.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.staxutils; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; import java.net.URL; import java.util.Iterator; import java.util.Stack; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Logger; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.Location; import javax.xml.stream.StreamFilter; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLResolver; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.events.Attribute; import javax.xml.stream.events.DTD; import javax.xml.stream.events.Namespace; import javax.xml.stream.events.StartDocument; import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; import org.w3c.dom.UserDataHandler; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.helpers.XMLUtils; public final class StaxUtils { private static final Logger LOG = LogUtils.getL7dLogger(StaxUtils.class); private static final BlockingQueue<XMLInputFactory> NS_AWARE_INPUT_FACTORY_POOL; private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL; private static final String XML_NS = "http://www.w3.org/2000/xmlns/"; private static final String DEF_PREFIXES[] = new String[] { "ns1".intern(), "ns2".intern(), "ns3".intern(), "ns4".intern(), "ns5".intern(), "ns6".intern(), "ns7".intern(), "ns8".intern(), "ns9".intern() }; static { int i = 20; try { String s = System.getProperty("org.apache.cxf.staxutils.pool-size", "-1"); i = Integer.parseInt(s); } catch (Throwable t) { //ignore i = 20; } if (i <= 0) { i = 20; } NS_AWARE_INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i); OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLOutputFactory>(i); } private StaxUtils() { } /** * CXF works with multiple STaX parsers. When we can't find any other way to work * against the different parsers, this can be used to condition code. Note: if you've got * Woodstox in the class path without being the default provider, this will return * the wrong answer. * @return true if Woodstox is in the classpath. */ public static boolean isWoodstox() { try { ClassLoaderUtils.loadClass("org.codehaus.stax2.XMLStreamReader2", StaxUtils.class); } catch (ClassNotFoundException e) { return false; } return true; } /** * Return a cached, namespace-aware, factory. * @return */ private static XMLInputFactory getXMLInputFactory() { XMLInputFactory f = NS_AWARE_INPUT_FACTORY_POOL.poll(); if (f == null) { f = createXMLInputFactory(true); } return f; } private static void returnXMLInputFactory(XMLInputFactory factory) { NS_AWARE_INPUT_FACTORY_POOL.offer(factory); } private static XMLOutputFactory getXMLOutputFactory() { XMLOutputFactory f = OUTPUT_FACTORY_POOL.poll(); if (f == null) { f = XMLOutputFactory.newInstance(); } return f; } private static void returnXMLOutputFactory(XMLOutputFactory factory) { OUTPUT_FACTORY_POOL.offer(factory); } /** * Return a new factory so that the caller can set sticky parameters. * @param nsAware * @return */ public static XMLInputFactory createXMLInputFactory(boolean nsAware) { XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, nsAware); factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); factory.setXMLResolver(new XMLResolver() { public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) throws XMLStreamException { throw new XMLStreamException("Reading external entities is disabled"); } }); return factory; } public static XMLStreamWriter createXMLStreamWriter(Writer out) { XMLOutputFactory factory = getXMLOutputFactory(); try { return factory.createXMLStreamWriter(out); } catch (XMLStreamException e) { throw new RuntimeException("Cant' create XMLStreamWriter", e); } finally { returnXMLOutputFactory(factory); } } public static XMLStreamWriter createXMLStreamWriter(OutputStream out) { return createXMLStreamWriter(out, null); } public static XMLStreamWriter createXMLStreamWriter(OutputStream out, String encoding) { if (encoding == null) { encoding = "UTF-8"; } XMLOutputFactory factory = getXMLOutputFactory(); try { return factory.createXMLStreamWriter(out, encoding); } catch (XMLStreamException e) { throw new RuntimeException("Cant' create XMLStreamWriter", e); } finally { returnXMLOutputFactory(factory); } } public static XMLStreamWriter createXMLStreamWriter(Result r) { XMLOutputFactory factory = getXMLOutputFactory(); try { return factory.createXMLStreamWriter(r); } catch (XMLStreamException e) { throw new RuntimeException("Cant' create XMLStreamWriter", e); } finally { returnXMLOutputFactory(factory); } } public static XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) { XMLInputFactory factory = getXMLInputFactory(); try { return factory.createFilteredReader(reader, filter); } catch (XMLStreamException e) { throw new RuntimeException("Cant' create XMLStreamReader", e); } finally { returnXMLInputFactory(factory); } } public static void nextEvent(XMLStreamReader dr) { try { dr.next(); } catch (XMLStreamException e) { throw new RuntimeException("Couldn't parse stream.", e); } } public static boolean toNextText(DepthXMLStreamReader reader) { if (reader.getEventType() == XMLStreamReader.CHARACTERS) { return true; } try { int depth = reader.getDepth(); int event = reader.getEventType(); while (reader.getDepth() >= depth && reader.hasNext()) { if (event == XMLStreamReader.CHARACTERS && reader.getDepth() == depth + 1) { return true; } event = reader.next(); } return false; } catch (XMLStreamException e) { throw new RuntimeException("Couldn't parse stream.", e); } } public static boolean toNextTag(XMLStreamReader reader) { try { // advance to first tag. int x = reader.getEventType(); while (x != XMLStreamReader.START_ELEMENT && x != XMLStreamReader.END_ELEMENT && reader.hasNext()) { x = reader.next(); } } catch (XMLStreamException e) { throw new RuntimeException("Couldn't parse stream.", e); } return true; } public static boolean toNextTag(DepthXMLStreamReader reader, QName endTag) { try { int depth = reader.getDepth(); int event = reader.getEventType(); while (reader.getDepth() >= depth && reader.hasNext()) { if (event == XMLStreamReader.START_ELEMENT && reader.getName().equals(endTag) && reader.getDepth() == depth + 1) { return true; } event = reader.next(); } return false; } catch (XMLStreamException e) { throw new RuntimeException("Couldn't parse stream.", e); } } public static void writeStartElement(XMLStreamWriter writer, String prefix, String name, String namespace) throws XMLStreamException { if (prefix == null) { prefix = ""; } if (namespace.length() > 0) { writer.writeStartElement(prefix, name, namespace); if (prefix.length() > 0) { writer.writeNamespace(prefix, namespace); writer.setPrefix(prefix, namespace); } else { writer.writeDefaultNamespace(namespace); writer.setDefaultNamespace(namespace); } } else { writer.writeStartElement(name); writer.writeDefaultNamespace(""); writer.setDefaultNamespace(""); } } /** * Returns true if currently at the start of an element, otherwise move * forwards to the next element start and return true, otherwise false is * returned if the end of the stream is reached. */ public static boolean skipToStartOfElement(XMLStreamReader in) throws XMLStreamException { for (int code = in.getEventType(); code != XMLStreamReader.END_DOCUMENT; code = in.next()) { if (code == XMLStreamReader.START_ELEMENT) { return true; } } return false; } public static boolean toNextElement(DepthXMLStreamReader dr) { if (dr.getEventType() == XMLStreamReader.START_ELEMENT) { return true; } if (dr.getEventType() == XMLStreamReader.END_ELEMENT) { return false; } try { int depth = dr.getDepth(); for (int event = dr.getEventType(); dr.getDepth() >= depth && dr.hasNext(); event = dr.next()) { if (event == XMLStreamReader.START_ELEMENT && dr.getDepth() == depth + 1) { return true; } else if (event == XMLStreamReader.END_ELEMENT) { depth--; } } return false; } catch (XMLStreamException e) { throw new RuntimeException("Couldn't parse stream.", e); } } public static boolean skipToStartOfElement(DepthXMLStreamReader in) throws XMLStreamException { for (int code = in.getEventType(); code != XMLStreamReader.END_DOCUMENT; code = in.next()) { if (code == XMLStreamReader.START_ELEMENT) { return true; } } return false; } public static void copy(Source source, OutputStream os) throws XMLStreamException { XMLStreamWriter writer = createXMLStreamWriter(os); try { copy(source, writer); } finally { try { writer.flush(); } catch (XMLStreamException ex) { //ignore } } } public static void copy(Source source, XMLStreamWriter writer) throws XMLStreamException { if (source instanceof SAXSource) { SAXSource ss = (SAXSource)source; InputSource src = ss.getInputSource(); if (src == null || (src.getSystemId() == null && src.getPublicId() == null)) { if (ss.getXMLReader() != null) { //OK - reader is OK. We'll use that out StreamWriterContentHandler ch = new StreamWriterContentHandler(writer); XMLReader reader = ((SAXSource)source).getXMLReader(); reader.setContentHandler(ch); try { try { reader.setFeature("http://xml.org/sax/features/namespaces", true); } catch (Throwable t) { //ignore } reader.parse(((SAXSource)source).getInputSource()); return; } catch (Exception e) { throw new XMLStreamException(e); } } else if (ss.getInputSource() == null) { //nothing to copy, just return return; } } } if (source instanceof StreamSource) { StreamSource ss = (StreamSource)source; if (ss.getInputStream() == null && ss.getReader() == null && ss.getSystemId() == null) { //nothing to copy, just return return; } } XMLStreamReader reader = createXMLStreamReader(source); copy(reader, writer); reader.close(); } public static Document copy(Document doc) throws XMLStreamException, ParserConfigurationException { XMLStreamReader reader = createXMLStreamReader(doc); W3CDOMStreamWriter writer = new W3CDOMStreamWriter(); copy(reader, writer); Document d = writer.getDocument(); try { d.setDocumentURI(doc.getDocumentURI()); } catch (Exception ex) { //ignore - probably not DOM level 3 } return d; } public static void copy(Document doc, XMLStreamWriter writer) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(doc); copy(reader, writer); } public static void copy(Element node, XMLStreamWriter writer) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(node); copy(reader, writer); } /** * Copies the reader to the writer. The start and end document methods must * be handled on the writer manually. TODO: if the namespace on the reader * has been declared previously to where we are in the stream, this probably * won't work. * * @param reader * @param writer * @throws XMLStreamException */ public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { copy(reader, writer, false); } public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment) throws XMLStreamException { // number of elements read in int read = 0; int event = reader.getEventType(); while (reader.hasNext()) { switch (event) { case XMLStreamConstants.START_ELEMENT: read++; writeStartElement(reader, writer); break; case XMLStreamConstants.END_ELEMENT: writer.writeEndElement(); read--; if (read <= 0 && !fragment) { return; } break; case XMLStreamConstants.CHARACTERS: writer.writeCharacters(reader.getText()); break; case XMLStreamConstants.COMMENT: writer.writeComment(reader.getText()); break; case XMLStreamConstants.CDATA: writer.writeCData(reader.getText()); break; case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.END_DOCUMENT: case XMLStreamConstants.ATTRIBUTE: case XMLStreamConstants.NAMESPACE: break; default: break; } event = reader.next(); } } private static void writeStartElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { String local = reader.getLocalName(); String uri = reader.getNamespaceURI(); String prefix = reader.getPrefix(); if (prefix == null) { prefix = ""; } // System.out.println("STAXUTILS:writeStartElement : node name : " + local + " namespace URI" + uri); boolean writeElementNS = false; if (uri != null) { writeElementNS = true; Iterator<String> it = CastUtils.cast(writer.getNamespaceContext().getPrefixes(uri)); while (it != null && it.hasNext()) { String s = it.next(); if (s == null) { s = ""; } if (s.equals(prefix)) { writeElementNS = false; } } } // Write out the element name if (uri != null) { if (prefix.length() == 0 && StringUtils.isEmpty(uri)) { writer.writeStartElement(local); } else { writer.writeStartElement(prefix, local, uri); } } else { writer.writeStartElement(local); } // Write out the namespaces for (int i = 0; i < reader.getNamespaceCount(); i++) { String nsURI = reader.getNamespaceURI(i); String nsPrefix = reader.getNamespacePrefix(i); if (nsPrefix == null) { nsPrefix = ""; } if (nsPrefix.length() == 0) { writer.writeDefaultNamespace(nsURI); writer.setDefaultNamespace(nsURI); } else { writer.writeNamespace(nsPrefix, nsURI); writer.setPrefix(nsPrefix, nsURI); } if (nsURI.equals(uri) && nsPrefix.equals(prefix)) { writeElementNS = false; } } // Check if the namespace still needs to be written. // We need this check because namespace writing works // different on Woodstox and the RI. if (writeElementNS) { if (prefix == null || prefix.length() == 0) { writer.writeDefaultNamespace(uri); writer.setDefaultNamespace(uri); } else { writer.writeNamespace(prefix, uri); writer.setPrefix(prefix, uri); } } // Write out attributes for (int i = 0; i < reader.getAttributeCount(); i++) { String ns = reader.getAttributeNamespace(i); String nsPrefix = reader.getAttributePrefix(i); if (ns == null || ns.length() == 0) { writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i)); } else if (nsPrefix == null || nsPrefix.length() == 0) { writer.writeAttribute(reader.getAttributeNamespace(i), reader.getAttributeLocalName(i), reader.getAttributeValue(i)); } else { Iterator<String> it = CastUtils.cast(writer.getNamespaceContext().getPrefixes(ns)); boolean writeNs = true; while (it != null && it.hasNext()) { String s = it.next(); if (s == null) { s = ""; } if (s.equals(nsPrefix)) { writeNs = false; } } if (writeNs) { writer.writeNamespace(nsPrefix, ns); writer.setPrefix(nsPrefix, ns); } writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader .getAttributeLocalName(i), reader.getAttributeValue(i)); } } } public static void writeDocument(Document d, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { writeDocument(d, writer, true, repairing); } public static void writeDocument(Document d, XMLStreamWriter writer, boolean writeProlog, boolean repairing) throws XMLStreamException { if (writeProlog) { writer.writeStartDocument(); } Node node = d.getFirstChild(); while (node != null) { if (writeProlog || node.getNodeType() == Node.ELEMENT_NODE) { writeNode(node, writer, repairing); } node = node.getNextSibling(); } if (writeProlog) { writer.writeEndDocument(); } } /** * Writes an Element to an XMLStreamWriter. The writer must already have * started the document (via writeStartDocument()). Also, this probably * won't work with just a fragment of a document. The Element should be the * root element of the document. * * @param e * @param writer * @throws XMLStreamException */ public static void writeElement(Element e, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { writeElement(e, writer, repairing, true); } /** * Writes an Element to an XMLStreamWriter. The writer must already have * started the document (via writeStartDocument()). Also, this probably * won't work with just a fragment of a document. The Element should be the * root element of the document. * * @param e * @param writer * @param endElement true if the element should be ended * @throws XMLStreamException */ public static void writeElement(Element e, XMLStreamWriter writer, boolean repairing, boolean endElement) throws XMLStreamException { String prefix = e.getPrefix(); String ns = e.getNamespaceURI(); String localName = e.getLocalName(); // System.out.println("local name : " + localName + " URI: " + ns + " Prefix :" + prefix); if (prefix == null) { prefix = ""; } if (localName == null) { localName = e.getNodeName(); if (localName == null) { throw new IllegalStateException("Element's local name cannot be null!"); } } String decUri = writer.getNamespaceContext().getNamespaceURI(prefix); boolean declareNamespace = decUri == null || !decUri.equals(ns); if (ns == null || ns.length() == 0) { writer.writeStartElement(localName); if (StringUtils.isEmpty(decUri)) { declareNamespace = false; } } else { // System.out.println("Calling writeStartElement for local name : " // + localName + " URI: " + ns + " Prefix :" + prefix); writer.writeStartElement(prefix, localName, ns); } NamedNodeMap attrs = e.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); String name = attr.getLocalName(); String attrPrefix = attr.getPrefix(); if (attrPrefix == null) { attrPrefix = ""; } if (name == null) { name = attr.getNodeName(); } if ("xmlns".equals(attrPrefix)) { // System.out.println("WriteNamespace is called for prefix : " // + name + " namespace :" + attr.getNodeValue()); writer.writeNamespace(name, attr.getNodeValue()); writer.setPrefix(name, attr.getNodeValue()); if (name.equals(prefix) && attr.getNodeValue().equals(ns)) { declareNamespace = false; } } else { if ("xmlns".equals(name) && "".equals(attrPrefix)) { writer.writeDefaultNamespace(attr.getNodeValue()); writer.setDefaultNamespace(attr.getNodeValue()); if (attr.getNodeValue().equals(ns)) { declareNamespace = false; } else if (StringUtils.isEmpty(attr.getNodeValue()) && StringUtils.isEmpty(ns)) { declareNamespace = false; } } else { String attns = attr.getNamespaceURI(); String value = attr.getNodeValue(); if (attns == null || attns.length() == 0) { writer.writeAttribute(name, value); } else if (attrPrefix == null || attrPrefix.length() == 0) { writer.writeAttribute(attns, name, value); } else { writer.writeAttribute(attrPrefix, attns, name, value); } } } } if (declareNamespace && repairing) { if (ns == null) { writer.writeNamespace(prefix, ""); writer.setPrefix(prefix, ""); } else { writer.writeNamespace(prefix, ns); writer.setPrefix(prefix, ns); } } Node nd = e.getFirstChild(); while (nd != null) { writeNode(nd, writer, repairing); nd = nd.getNextSibling(); } if (endElement) { writer.writeEndElement(); } } public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { switch (n.getNodeType()) { case Node.ELEMENT_NODE: writeElement((Element)n, writer, repairing); break; case Node.TEXT_NODE: writer.writeCharacters(((Text)n).getNodeValue()); break; case Node.COMMENT_NODE: writer.writeComment(((Comment)n).getData()); break; case Node.CDATA_SECTION_NODE: writer.writeCData(((CDATASection)n).getData()); break; case Node.ENTITY_REFERENCE_NODE: writer.writeEntityRef(((EntityReference)n).getNodeValue()); break; case Node.PROCESSING_INSTRUCTION_NODE: ProcessingInstruction pi = (ProcessingInstruction)n; writer.writeProcessingInstruction(pi.getTarget(), pi.getData()); break; case Node.DOCUMENT_NODE: writeDocument((Document)n, writer, repairing); break; case Node.DOCUMENT_FRAGMENT_NODE: { DocumentFragment frag = (DocumentFragment)n; Node child = frag.getFirstChild(); while (child != null) { writeNode(child, writer, repairing); child = child.getNextSibling(); } break; } case Node.DOCUMENT_TYPE_NODE: try { if (((DocumentType)n).getTextContent() != null) { writer.writeDTD(((DocumentType)n).getTextContent()); } } catch (UnsupportedOperationException ex) { //can we ignore? DOM writers really don't allow this //as there isn't a way to write a DTD in dom } break; default: throw new IllegalStateException("Found type: " + n.getClass().getName()); } } public static Document read(Source s) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(s); try { return read(reader); } finally { try { reader.close(); } catch (Exception ex) { //ignore } } } public static Document read(InputStream s) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(s); try { return read(reader); } finally { try { reader.close(); } catch (Exception ex) { //ignore } } } public static Document read(InputSource s) throws XMLStreamException { XMLStreamReader reader = createXMLStreamReader(s); try { return read(reader); } finally { try { reader.close(); } catch (Exception ex) { //ignore } } } public static Document read(XMLStreamReader reader) throws XMLStreamException { return read(reader, false); } public static Document read(XMLStreamReader reader, boolean recordLoc) throws XMLStreamException { Document doc = DOMUtils.createDocument(); if (reader.getLocation().getSystemId() != null) { try { doc.setDocumentURI(new String(reader.getLocation().getSystemId())); } catch (Exception e) { //ignore - probably not DOM level 3 } } readDocElements(doc, doc, reader, true, recordLoc); return doc; } public static Document read(DocumentBuilder builder, XMLStreamReader reader, boolean repairing) throws XMLStreamException { Document doc = builder == null ? DOMUtils.createDocument() : builder.newDocument(); if (reader.getLocation().getSystemId() != null) { try { doc.setDocumentURI(new String(reader.getLocation().getSystemId())); } catch (Exception e) { //ignore - probably not DOM level 3 } } readDocElements(doc, reader, repairing); return doc; } /** * @param parent * @return */ private static Document getDocument(Node parent) { return (parent instanceof Document) ? (Document)parent : parent.getOwnerDocument(); } private static boolean isDeclared(Element e, String namespaceURI, String prefix) { while (e != null) { Attr att; if (prefix != null && prefix.length() > 0) { att = e.getAttributeNodeNS(XML_NS, prefix); } else { att = e.getAttributeNode("xmlns"); } if (att != null && att.getNodeValue().equals(namespaceURI)) { return true; } if (e.getParentNode() instanceof Element) { e = (Element)e.getParentNode(); } else if (StringUtils.isEmpty(prefix) && StringUtils.isEmpty(namespaceURI)) { //A document that probably doesn't have any namespace qualifies elements return true; } else { e = null; } } return false; } public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing) throws XMLStreamException { Document doc = getDocument(parent); readDocElements(doc, parent, reader, repairing, false); } /** * @param parent * @param reader * @throws XMLStreamException */ public static void readDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc) throws XMLStreamException { Stack<Node> stack = new Stack Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF StaxUtils.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.