Apache CXF API

org.apache.cxf.staxutils
Class StaxUtils

java.lang.Object
  extended by org.apache.cxf.staxutils.StaxUtils

public final class StaxUtils
extends Object


Method Summary
static Document copy(Document doc)
           
static void copy(Document doc, javax.xml.stream.XMLStreamWriter writer)
           
static void copy(Element node, javax.xml.stream.XMLStreamWriter writer)
           
static void copy(Source source, OutputStream os)
           
static void copy(Source source, javax.xml.stream.XMLStreamWriter writer)
           
static void copy(javax.xml.stream.XMLStreamReader reader, OutputStream os)
           
static void copy(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer)
          Copies the reader to the writer.
static void copy(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer, boolean fragment)
           
static javax.xml.stream.XMLStreamReader createFilteredReader(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.StreamFilter filter)
           
static javax.xml.stream.XMLInputFactory createXMLInputFactory(boolean nsAware)
          Return a new factory so that the caller can set sticky parameters.
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Document doc)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Document doc, String sysId)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Element el)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Element el, String sysId)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputSource src)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputStream in)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputStream in, String encoding)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Reader reader)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(Source source)
           
static javax.xml.stream.XMLStreamReader createXMLStreamReader(String systemId, InputStream in)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(OutputStream out)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(OutputStream out, String encoding)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(Result r)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(Writer out)
           
static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer)
           
static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer, String namespaceURI)
           
static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer, String namespaceURI, boolean declare)
          Create a unique namespace uri/prefix combination.
static boolean isWoodstox()
          CXF works with multiple STaX parsers.
static void nextEvent(javax.xml.stream.XMLStreamReader dr)
           
static void printXmlFragment(javax.xml.stream.XMLStreamReader reader)
           
static Document read(DocumentBuilder builder, javax.xml.stream.XMLStreamReader reader, boolean repairing)
           
static Document read(InputSource s)
           
static Document read(InputStream s)
           
static Document read(Source s)
           
static Document read(javax.xml.stream.XMLStreamReader reader)
           
static Document read(javax.xml.stream.XMLStreamReader reader, boolean recordLoc)
           
static void readDocElements(Document doc, Node parent, javax.xml.stream.XMLStreamReader reader, boolean repairing, boolean recordLoc)
           
static void readDocElements(Document doc, Node parent, javax.xml.stream.XMLStreamReader reader, boolean repairing, boolean recordLoc, boolean isThreshold)
           
static void readDocElements(Node parent, javax.xml.stream.XMLStreamReader reader, boolean repairing)
           
static void readDocElements(Node parent, javax.xml.stream.XMLStreamReader reader, boolean repairing, boolean isThreshold)
           
static QName readQName(javax.xml.stream.XMLStreamReader reader)
          Reads a QName from the element text.
static boolean skipToStartOfElement(DepthXMLStreamReader in)
           
static boolean skipToStartOfElement(javax.xml.stream.XMLStreamReader in)
          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.
static boolean toNextElement(DepthXMLStreamReader dr)
           
static boolean toNextTag(DepthXMLStreamReader reader, QName endTag)
           
static boolean toNextTag(javax.xml.stream.XMLStreamReader reader)
           
static boolean toNextText(DepthXMLStreamReader reader)
           
static String toString(Document doc)
           
static String toString(Element el)
           
static void writeDocument(Document d, javax.xml.stream.XMLStreamWriter writer, boolean repairing)
           
static void writeDocument(Document d, javax.xml.stream.XMLStreamWriter writer, boolean writeProlog, boolean repairing)
           
static void writeElement(Element e, javax.xml.stream.XMLStreamWriter writer, boolean repairing)
          Writes an Element to an XMLStreamWriter.
static void writeElement(Element e, javax.xml.stream.XMLStreamWriter writer, boolean repairing, boolean endElement)
          Writes an Element to an XMLStreamWriter.
static void writeEvent(javax.xml.stream.events.XMLEvent event, javax.xml.stream.XMLStreamWriter writer)
           
static void writeNode(Node n, javax.xml.stream.XMLStreamWriter writer, boolean repairing)
           
static void writeStartElement(javax.xml.stream.XMLStreamWriter writer, String prefix, String name, String namespace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isWoodstox

public static boolean isWoodstox()
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.

Returns:
true if Woodstox is in the classpath.

createXMLInputFactory

public static javax.xml.stream.XMLInputFactory createXMLInputFactory(boolean nsAware)
Return a new factory so that the caller can set sticky parameters.

Parameters:
nsAware -
Returns:

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(Writer out)

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(OutputStream out)

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(OutputStream out,
                                                                     String encoding)

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(Result r)

createFilteredReader

public static javax.xml.stream.XMLStreamReader createFilteredReader(javax.xml.stream.XMLStreamReader reader,
                                                                    javax.xml.stream.StreamFilter filter)

nextEvent

public static void nextEvent(javax.xml.stream.XMLStreamReader dr)

toNextText

public static boolean toNextText(DepthXMLStreamReader reader)

toNextTag

public static boolean toNextTag(javax.xml.stream.XMLStreamReader reader)

toNextTag

public static boolean toNextTag(DepthXMLStreamReader reader,
                                QName endTag)

writeStartElement

public static void writeStartElement(javax.xml.stream.XMLStreamWriter writer,
                                     String prefix,
                                     String name,
                                     String namespace)
                              throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

skipToStartOfElement

public static boolean skipToStartOfElement(javax.xml.stream.XMLStreamReader in)
                                    throws javax.xml.stream.XMLStreamException
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.

Throws:
javax.xml.stream.XMLStreamException

toNextElement

public static boolean toNextElement(DepthXMLStreamReader dr)

skipToStartOfElement

public static boolean skipToStartOfElement(DepthXMLStreamReader in)
                                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(Source source,
                        OutputStream os)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(Source source,
                        javax.xml.stream.XMLStreamWriter writer)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static Document copy(Document doc)
                     throws javax.xml.stream.XMLStreamException,
                            ParserConfigurationException
Throws:
javax.xml.stream.XMLStreamException
ParserConfigurationException

copy

public static void copy(Document doc,
                        javax.xml.stream.XMLStreamWriter writer)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(Element node,
                        javax.xml.stream.XMLStreamWriter writer)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(javax.xml.stream.XMLStreamReader reader,
                        OutputStream os)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(javax.xml.stream.XMLStreamReader reader,
                        javax.xml.stream.XMLStreamWriter writer)
                 throws javax.xml.stream.XMLStreamException
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.

Parameters:
reader -
writer -
Throws:
javax.xml.stream.XMLStreamException

copy

public static void copy(javax.xml.stream.XMLStreamReader reader,
                        javax.xml.stream.XMLStreamWriter writer,
                        boolean fragment)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeDocument

public static void writeDocument(Document d,
                                 javax.xml.stream.XMLStreamWriter writer,
                                 boolean repairing)
                          throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeDocument

public static void writeDocument(Document d,
                                 javax.xml.stream.XMLStreamWriter writer,
                                 boolean writeProlog,
                                 boolean repairing)
                          throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeElement

public static void writeElement(Element e,
                                javax.xml.stream.XMLStreamWriter writer,
                                boolean repairing)
                         throws javax.xml.stream.XMLStreamException
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.

Parameters:
e -
writer -
Throws:
javax.xml.stream.XMLStreamException

writeElement

public static void writeElement(Element e,
                                javax.xml.stream.XMLStreamWriter writer,
                                boolean repairing,
                                boolean endElement)
                         throws javax.xml.stream.XMLStreamException
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.

Parameters:
e -
writer -
endElement - true if the element should be ended
Throws:
javax.xml.stream.XMLStreamException

writeNode

public static void writeNode(Node n,
                             javax.xml.stream.XMLStreamWriter writer,
                             boolean repairing)
                      throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(Source s)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(InputStream s)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(InputSource s)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(javax.xml.stream.XMLStreamReader reader)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(javax.xml.stream.XMLStreamReader reader,
                            boolean recordLoc)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

read

public static Document read(DocumentBuilder builder,
                            javax.xml.stream.XMLStreamReader reader,
                            boolean repairing)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

readDocElements

public static void readDocElements(Node parent,
                                   javax.xml.stream.XMLStreamReader reader,
                                   boolean repairing)
                            throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

readDocElements

public static void readDocElements(Node parent,
                                   javax.xml.stream.XMLStreamReader reader,
                                   boolean repairing,
                                   boolean isThreshold)
                            throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

readDocElements

public static void readDocElements(Document doc,
                                   Node parent,
                                   javax.xml.stream.XMLStreamReader reader,
                                   boolean repairing,
                                   boolean recordLoc)
                            throws javax.xml.stream.XMLStreamException
Parameters:
parent -
reader -
Throws:
javax.xml.stream.XMLStreamException

readDocElements

public static void readDocElements(Document doc,
                                   Node parent,
                                   javax.xml.stream.XMLStreamReader reader,
                                   boolean repairing,
                                   boolean recordLoc,
                                   boolean isThreshold)
                            throws javax.xml.stream.XMLStreamException
Parameters:
parent -
reader -
Throws:
javax.xml.stream.XMLStreamException

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputSource src)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputStream in,
                                                                     String encoding)
Parameters:
in -
encoding -
ctx -
Returns:

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(InputStream in)
Parameters:
in -
Returns:

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(String systemId,
                                                                     InputStream in)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Element el)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Document doc)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Element el,
                                                                     String sysId)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Document doc,
                                                                     String sysId)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Source source)

createXMLStreamReader

public static javax.xml.stream.XMLStreamReader createXMLStreamReader(Reader reader)
Parameters:
reader -
Returns:

readQName

public static QName readQName(javax.xml.stream.XMLStreamReader reader)
                       throws javax.xml.stream.XMLStreamException
Reads a QName from the element text. Reader must be positioned at the start tag.

Throws:
javax.xml.stream.XMLStreamException

getUniquePrefix

public static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer,
                                     String namespaceURI,
                                     boolean declare)
                              throws javax.xml.stream.XMLStreamException
Create a unique namespace uri/prefix combination.

Parameters:
nsUri -
Returns:
The namespace with the specified URI. If one doesn't exist, one is created.
Throws:
javax.xml.stream.XMLStreamException

getUniquePrefix

public static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer,
                                     String namespaceURI)
                              throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

getUniquePrefix

public static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer)

printXmlFragment

public static void printXmlFragment(javax.xml.stream.XMLStreamReader reader)

writeEvent

public static void writeEvent(javax.xml.stream.events.XMLEvent event,
                              javax.xml.stream.XMLStreamWriter writer)
                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

toString

public static String toString(Document doc)
                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

toString

public static String toString(Element el)
                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

Apache CXF API

Apache CXF