object Fs2DataSource
Provides helpers for creating FS2 streams of io.dylemma.spac.xml.XmlEvent
,
using fs2-data-xml as the underlying event provider.
Fs2-data is already pretty "plug-and-play", so at best this helper just removes a few steps/pipes that you would have to manually call.
For example:
val charStream: Stream[IO, Char] = ??? // this... val xmlStream1: Stream[IO, XmlEvent] = { import fs2.data.xml._ charStream .through(events) .through(namespaceResolver) .through(reverenceResolver()) .through(normalize) .through(Fs2DataSource.convert) } // could be replaced with val xmlStream2: Stream[IO, XmlEvent] = { Fs2DataSource.fromRawXmlStream(charStream) }
Essentially this helper just provides a convenient apply
method that accepts
String
, Stream[F, Char]
, Stream[F, String]
, or Stream[F, fs2.data.xml.XmlEvent]
to return a Stream[F, XmlEvent]
which an XmlParser
could then interact with.
- Source
- Fs2DataSource.scala
- Alphabetic
- By Inheritance
- Fs2DataSource
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait Cleanup extends AnyRef
Represents some post-processing on a stream of fs2-data-xml
XmlEvent
, e.g.Represents some post-processing on a stream of fs2-data-xml
XmlEvent
, e.g. piping the stream through a resolver and/or normalizer.This is how the
ToFs2XmlEventStream
typeclass allows you to override the stream creation behavior for the instances that use theevents
pipe themselves.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def convert[F[_]]: Pipe[F, fs2.data.xml.XmlEvent, XmlEvent]
Pipe for converting
fs2.data.xml.XmlEvent
toio.dylemma.spac.xml.XmlEvent
.Pipe for converting
fs2.data.xml.XmlEvent
toio.dylemma.spac.xml.XmlEvent
. This will be used under the hood of theapply
andsyncIO
helpers, but is being made available to allow for manual stream creation if desired. The stream of fs2-data XmlEvents should ideally already be passed through areferenceResolver
andnormalize
pipe before this one. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def fromRawXmlStream[F[_], A](rawXmlStream: Stream[F, A], cleanup: Cleanup = Cleanup)(implicit A: CharLikeChunks[F, A], F: MonadError[F, Throwable]): Stream[F, XmlEvent]
Converts a stream of raw XML data (such as Strings, Characters, or Bytes) to a stream of XmlEvents.
Converts a stream of raw XML data (such as Strings, Characters, or Bytes) to a stream of XmlEvents.
Under the hood, this calls
events[F, A]
fromfs2-data-xml
, piped through thecleanup
functions (i.e.namespaceResolver, referenceResolver, normalize
), then converts the fs2-data based XML events to the SPaC model ofXmlEvent
- F
Stream effect type
- A
The chunk type of the raw XML data, i.e. String, Char, or Byte
- rawXmlStream
The raw XML data
- cleanup
Cleanup function used on the fs2-data XmlEvents. By default this will pass the events through
namespaceResolver through referenceResolver() through normalize
.- A
Evidence that the
A
type can be treated as raw xml by fs2-data-xml- F
Evidence that errors can be thrown in the
F
effect context- returns
A stream of SPaC
XmlEvent
s
- def fromString[F[_]](rawXml: String, cleanup: Cleanup = Cleanup)(implicit F: MonadError[F, Throwable]): Stream[F, XmlEvent]
Converts a raw XML string (expected to contain a complete XML document) to a stream of XmlEvents.
Converts a raw XML string (expected to contain a complete XML document) to a stream of XmlEvents.
- F
Stream effect type
- rawXml
The raw XML data
- cleanup
Cleanup function used on the fs2-data XmlEvents. By default this will pass the events through
namespaceResolver through referenceResolver() through normalize
.- F
Evidence that errors can be thrown in the
F
effect context- returns
A stream of SPaC
XmlEvent
s
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- object Cleanup extends Cleanup
Default cleanup function which passes the input stream through
namespaceResolver
(with default args), then a defaultreferenceResolver
, thennormalize
- object NoCleanup extends Cleanup
No-op cleanup function which returns the input stream unmodified