JavaxSource

Provides helpers for creating Source[XmlEvent] using javax.xml.stream for the underlying event provider.

class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(eventReader: XMLEventReader): Source[XmlEvent]
def fromFile(file: File, factory: XMLInputFactory)(implicit codec: Codec): Source[XmlEvent]

Returns a Source[XmlEvent] which can open the given file to read raw XML data.

Returns a Source[XmlEvent] which can open the given file to read raw XML data.

The returned Source is reusable. The underlying streams are managed by the open method and the close function it returns.

Value parameters:
codec

Implicit Codec used to interpret the bytes to characters. Default is null

factory

Factory instance for the underlying Javax parser

file

A file containing XML

Returns:

A reusable Source[XmlEvent]

def fromInputStream(rawXml: InputStream, factory: XMLInputFactory)(implicit codec: Codec): Source[XmlEvent]

Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes.

Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes.

The returned Source will not attempt to close the rawXml stream; responsibility for closing rawXml lies with whoever created it.

Value parameters:
codec

Implicit Codec used to interpret the bytes to characters. Default is null

factory

Factory instance for the underlying Javax parser

rawXml

An InputStream containing raw XML bytes

Returns:

A single-use Source[XmlEvent]

def fromReader(rawXml: Reader, factory: XMLInputFactory): Source[XmlEvent]

Returns a single-use Source[XmlEvent] which interprets the contents of the given Reader as raw XML characters.

Returns a single-use Source[XmlEvent] which interprets the contents of the given Reader as raw XML characters.

The returned Source will not attempt to close the rawXml reader; responsibility for closing rawXml lies with whoever created it.

Value parameters:
factory

Factory instance for the underlying Javax parser

rawXml

A Reader containing raw XML character data

Returns:

A single-use Source[XmlEvent]

def fromString(rawXml: String, factory: XMLInputFactory): Source[XmlEvent]

Returns a Source[XmlEvent] which interprets the given string as raw XML.

Returns a Source[XmlEvent] which interprets the given string as raw XML.

Value parameters:
factory

Factory instance for the underlying Javax parser

rawXml

A string of raw XML

Returns:

A reusable Source[XmlEvent]

Concrete fields

lazy val defaultFactory: XMLInputFactory

Default XMLInputFactory used when creating an underlying XMLEventReader with the methods in this object.

Default XMLInputFactory used when creating an underlying XMLEventReader with the methods in this object.

This factory disables the IS_REPLACING_ENTITY_REFERENCES and IS_SUPPORTING_EXTERNAL_ENTITIES features, in efforts to mitigate xml injection attacks.

When using the methods in this object, if you want to override this default factory, define an implicit XMLInputFactory somewhere and make it available in the scope where you call the method, e.g.

  implicit val mySpecificXmlFactory: XMLInputFactory = ???
  val xmlEvents = JavaxSource[IO](new File("./stuff.xml"))