spring-framework / org.springframework.util.xml / StaxUtils

StaxUtils

abstract class StaxUtils

Convenience methods for working with the StAX API. Partly historic due to JAXP 1.3 compatibility; as of Spring 4.0, relying on JAXP 1.4 as included in JDK 1.6 and higher.

In particular, methods for using StAX (javax.xml.stream) in combination with the TrAX API (javax.xml.transform), and converting StAX readers/writers into SAX readers/handlers and vice-versa.

Author
Arjen Poutsma

Author
Juergen Hoeller

Since
3.0

Constructors

<init>

StaxUtils()

Convenience methods for working with the StAX API. Partly historic due to JAXP 1.3 compatibility; as of Spring 4.0, relying on JAXP 1.4 as included in JDK 1.6 and higher.

In particular, methods for using StAX (javax.xml.stream) in combination with the TrAX API (javax.xml.transform), and converting StAX readers/writers into SAX readers/handlers and vice-versa.

Functions

createContentHandler

open static fun createContentHandler(streamWriter: XMLStreamWriter): ContentHandler

Create a SAX ContentHandler that writes to the given StAX XMLStreamWriter.

open static fun createContentHandler(eventWriter: XMLEventWriter): ContentHandler

Create a SAX ContentHandler that writes events to the given StAX XMLEventWriter.

createCustomStaxResult

open static fun createCustomStaxResult(streamWriter: XMLStreamWriter): Result

Create a custom, non-JAXP 1.4 StAX Result for the given XMLStreamWriter.

open static fun createCustomStaxResult(eventWriter: XMLEventWriter): Result

Create a custom, non-JAXP 1.4 StAX Result for the given XMLEventWriter.

createCustomStaxSource

open static fun createCustomStaxSource(streamReader: XMLStreamReader): Source

Create a custom, non-JAXP 1.4 StAX Source for the given XMLStreamReader.

open static fun createCustomStaxSource(eventReader: XMLEventReader): Source

Create a custom, non-JAXP 1.4 StAX Source for the given XMLEventReader.

createDefensiveInputFactory

open static fun createDefensiveInputFactory(): XMLInputFactory

Create an XMLInputFactory with Spring's defensive setup, i.e. no support for the resolution of DTDs and external entities.

createEventStreamReader

open static fun createEventStreamReader(eventReader: XMLEventReader): XMLStreamReader

Return a XMLStreamReader that reads from a XMLEventReader. Useful because the StAX XMLInputFactory allows one to create an event reader from a stream reader, but not vice-versa.

createEventStreamWriter

open static fun createEventStreamWriter(eventWriter: XMLEventWriter): XMLStreamWriter
open static fun createEventStreamWriter(eventWriter: XMLEventWriter, eventFactory: XMLEventFactory): XMLStreamWriter

Return a XMLStreamWriter that writes to a XMLEventWriter.

createStaxResult

open static fun createStaxResult(streamWriter: XMLStreamWriter): Result

Create a JAXP 1.4 StAXResult for the given XMLStreamWriter.

open static fun createStaxResult(eventWriter: XMLEventWriter): Result

Create a JAXP 1.4 StAXResult for the given XMLEventWriter.

createStaxSource

open static fun createStaxSource(streamReader: XMLStreamReader): Source

Create a JAXP 1.4 StAXSource for the given XMLStreamReader.

open static fun createStaxSource(eventReader: XMLEventReader): Source

Create a JAXP 1.4 StAXSource for the given XMLEventReader.

createXMLEventReader

open static fun createXMLEventReader(events: MutableList<XMLEvent>): XMLEventReader

Create a XMLEventReader from the given list of XMLEvent.

createXMLReader

open static fun createXMLReader(streamReader: XMLStreamReader): XMLReader

Create a SAX XMLReader that reads from the given StAX XMLStreamReader.

open static fun createXMLReader(eventReader: XMLEventReader): XMLReader

Create a SAX XMLReader that reads from the given StAX XMLEventReader.

getXMLEventReader

open static fun getXMLEventReader(source: Source): XMLEventReader

Return the XMLEventReader for the given StAX Source.

getXMLEventWriter

open static fun getXMLEventWriter(result: Result): XMLEventWriter

Return the XMLEventWriter for the given StAX Result.

getXMLStreamReader

open static fun getXMLStreamReader(source: Source): XMLStreamReader

Return the XMLStreamReader for the given StAX Source.

getXMLStreamWriter

open static fun getXMLStreamWriter(result: Result): XMLStreamWriter

Return the XMLStreamWriter for the given StAX Result.

isStaxResult

open static fun isStaxResult(result: Result): Boolean

Indicate whether the given Result is a JAXP 1.4 StAX Result or custom StAX Result.

isStaxSource

open static fun isStaxSource(source: Source): Boolean

Indicate whether the given Source is a JAXP 1.4 StAX Source or custom StAX Source.