Closed
Description
I might be misunderstanding how to use fs2.data.xml.xpath.filter.raw
, but my first attempt led to my code hanging forever.
Using a simple XML file, test.xml
:
<?xml version='1.0' encoding='UTF-8'?>
<data>
<test>text</test>
</data>
and running this code with scala-cli /path/to/test.scala
:
//> using scala 3.6.4
//> using dep co.fs2::fs2-core:3.11.0
//> using dep co.fs2::fs2-io:3.11.0
//> using dep org.gnieh::fs2-data-xml:1.11.2
import cats.effect.{IO, IOApp}
object Test extends IOApp.Simple {
def run: IO[Unit] =
fs2.data.xml.xpath.XPathParser[IO]("/data/test").flatMap(xpath =>
fs2.io.file.Files[IO].readAll(fs2.io.file.Path("/path/to/test.xml"))
.through(fs2.text.utf8.decode)
.through(fs2.data.xml.events[IO, String]())
.through(fs2.data.xml.xpath.filter.raw(xpath))
// This `debug` call prints `Stream(..)`
.debug()
// Nothing is ever printed by this `debug` call
.evalMap(_.debug().compile.drain)
.compile
.drain
)
}
The first .debug()
call on the main Stream
prints Stream(..)
, but the .debug().compile.drain
calls on the inner Stream
don't seem to run, and the code never terminates.