Skip to content

Reasonable parser combinators for XML element streams

License

Notifications You must be signed in to change notification settings

amrhassan/scala-exemelle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exemelle

Build Status Maven Central

Reasonable parser combinators for XML element streams

Usage

libraryDependencies += "io.github.amrhassan" %% "exemelle" % "2.1.1"
import exemelle.StreamAction._
import exemelle.StreamParser

// You can describe how you want to process the stream in terms of combinators found in
// the StreamAction object

// Perhaps you want to capture the XML elements numbered 11 to 15?
val take5After10 = for {
    _ <- drop(10)
    elems <- take(5)
  } yield elems
  
// or drop everything until you encounter the "author" starting tag then take 5 elem?
import cats.implicits._   // For the >> shorthand
val dropUtilAuthor = dropUntil(_.name == "author") >> take(5)

// Or the full tag named "book"?
val bookTag = findTagNamed("book")

// Or al the full tags named "book"?
val allBookTags = findAllTagsNamed("book")


// You need parser implementation to parse through your stream
val parser = StreamParser.fromInputStream(/* a java.io.InputStream */)

// Now you can run one of the actions you've constructed earlier
run(parser)(allBookTags) // runs it into an Either[StreamError, Vector[Tag]]

About

Reasonable parser combinators for XML element streams

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages