p

kantan

xpath

package xpath

Source
package.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. xpath
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package laws
  2. package literals
  3. package nekohtml
  4. package ops

Type Members

  1. type Attr = org.w3c.dom.Attr
  2. sealed case class CompileError(message: String) extends XPathError with Product with Serializable

    Describes a XPath expression compilation error.

  3. type CompileResult[A] = Either[CompileError, A]

    Represents the result of taking a string and compiling it into an XPath query.

  4. trait Compiler[A] extends Serializable

    Compiles XPath expressions.

    Compiles XPath expressions.

    There's very little reason to interact with this class directly, it's only meant to act as a bridge between XPathCompiler and Query.

  5. sealed abstract class DecodeError extends ReadError

    Describes an error that occurred while decoding some XML content.

  6. type DecodeResult[A] = Either[DecodeError, A]

    Represents the result of taking some raw XPath result and turning it into a usable type.

    Represents the result of taking some raw XPath result and turning it into a usable type.

    Creation methods can be found in the companion object.

  7. type Document = org.w3c.dom.Document
  8. type Element = org.w3c.dom.Element
  9. trait GeneratedDecoders extends AnyRef
  10. type InputSource = org.xml.sax.InputSource
  11. trait LowPriorityXmlSourceInstances extends AnyRef
  12. type Node = org.w3c.dom.Node
  13. type NodeDecoder[A] = Decoder[Option[Node], A, DecodeError, codecs.type]

    Type class for types that can be decoded from an XML Node.

  14. trait NodeDecoderInstances extends AnyRef

    Provides default NodeDecoder instances.

  15. type NodeList = org.w3c.dom.NodeList
  16. sealed abstract class ParseError extends ReadError

    Describes errors that occur while parsing XML content.

  17. type ParseResult[A] = Either[ParseError, A]

    Represents the result of taking some raw data and turning it into a usable type.

    Represents the result of taking some raw data and turning it into a usable type.

    Creation methods can be found in the companion object.

  18. trait Query[A] extends Serializable

    Compiled XPath expression.

    Compiled XPath expression.

    Instance creation is achieved through the companion object.

  19. sealed abstract class ReadError extends XPathError

    Describes an error that occurred while parsing and / or decoding XML content.

  20. type ReadResult[A] = Either[ReadError, A]

    Represents the result of applying an XPath expression, applying to raw data and turning it into usable types.

    Represents the result of applying an XPath expression, applying to raw data and turning it into usable types.

    A ReadResult is either a DecodeResult or a ParseResult.

  21. final case class RemoteXmlSource[A](toURL: (A) => ParseResult[URL], retry: RetryStrategy, headers: Map[String, String])(implicit parser: XmlParser) extends XmlSource[A] with Product with Serializable

    XmlSource implementation anything that can be turned into a java.io.URL.

    XmlSource implementation anything that can be turned into a java.io.URL.

    The main purpose here is to allow application developers to set their own HTTP headers: when scraping websites, it's typically necessary to change the default user agent to something a bit more browser-like.

  22. final case class RetryStrategy(max: Int, delay: Long, factor: (Int) => Int) extends Product with Serializable

    Describes how to retry failed request for RemoteXmlSource.

    Describes how to retry failed request for RemoteXmlSource.

    Constructors for commonly used patterns can be found in the RetryStrategy$ companion object.

    max

    maximum number of attempts that can be made for a given request.

    delay

    delay, in milliseconds, between each attempt.

    factor

    function that calculates the delay factor based on the number of requests already attempted. In order to double waiting times between each attempt, for example, one would pass i ⇒ 2 ^ i.

  23. trait XPathCompiler extends Serializable

    Compiles XPath expressions.

    Compiles XPath expressions.

    There's always a default instance in scope, which should be perfectly suitable for most circumstances. Still, if some non-standard options are required, one can always declare a local implicit instance.

    Be careful, however: the default compiler performs some tricks to make sure its results are serializable. If you're planning on using frameworks that require serialization, such as Apache Spark, think twice about using a non-default compiler.

  24. sealed abstract class XPathError extends Error

    Describes an error that can occur while dealing with XPath.

  25. type XPathExpression = javax.xml.xpath.XPathExpression
  26. type XPathResult[A] = Either[XPathError, A]

    Represents the result of any XPath action.

    Represents the result of any XPath action.

    An XPathResult is either a CompileResult or a ReadResult.

  27. trait XmlParser extends AnyRef

    Contract for anything that knows how to parse XML.

    Contract for anything that knows how to parse XML.

    The default implementation is always in scope and uses the standard java javax.xml.parsers.DocumentBuilderFactory, with no special option. This can be overridden to set some options or, more drastically, to change the parsing mechanism entirely. A typical use case is the nekohtml module, which needs to take control of the entire parsing process to tidy up messy HTML documents.

  28. trait XmlSource[-A] extends Serializable

    Type class for turning instances of A into valid instances of Node.

    Type class for turning instances of A into valid instances of Node.

    While it's certainly possible, instances of XmlSource are rarely used directly. The preferred, idiomatic way is to use the implicit syntax provided by XmlSourceOps, brought in scope by importing kantan.xpath.ops._.

    See the companion object for construction methods and default instances.

Value Members

  1. object CompileError extends ErrorCompanion[CompileError]
  2. object CompileResult extends WithError[CompileError]
  3. object Compiler extends Serializable

    Provides implicit methods to summon Compiler instances.

  4. object DecodeError extends Serializable
  5. object DecodeResult extends WithDefault[DecodeError]

    Provides instance creation methods for DecodeResult.

  6. object NodeDecoder extends GeneratedDecoders with DecoderCompanion[Option[Node], DecodeError, codecs.type]

    Provides instance creation and summoning methods.

  7. object ParseError extends Serializable
  8. object ParseResult extends WithDefault[ParseError]

    Provides instance creation methods for ParseResult.

  9. object Query extends Serializable

    Provides convenient methods for XPath expression compilation.

    Provides convenient methods for XPath expression compilation.

    Actual compilation is done through instances of Compiler. Methods declared here will simply summon the right implicit value.

  10. object ReadResult extends Simple[ReadError]
  11. object RetryStrategy extends Serializable
  12. object XPathCompiler extends Serializable
  13. object XPathResult extends Simple[XPathError]
  14. object XmlParser

    Declares the default XmlParser instance in the implicit scope.

  15. object XmlSource extends LowPriorityXmlSourceInstances with Serializable

    Defines convenience methods for creating and summoning XmlSource instances.

    Defines convenience methods for creating and summoning XmlSource instances.

    Default implementation of standard types are declared here, always bringing them in scope without requirnig an explicit import.

    The default implementations can also be useful when writing new instances: if you need to write an XmlSource[T] and already have an XmlSource[S] and a T ⇒ S, you just need to call XmlSource.contramap to get your implementation.

  16. object codecs extends NodeDecoderInstances
  17. object implicits extends ToXPathLiteral with AllOps

Inherited from AnyRef

Inherited from Any

Ungrouped