package xpath
- Source
- package.scala
- Alphabetic
- By Inheritance
- xpath
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type Attr = org.w3c.dom.Attr
- sealed case class CompileError(message: String) extends XPathError with Product with Serializable
Describes a XPath expression compilation error.
- type CompileResult[A] = Either[CompileError, A]
Represents the result of taking a string and compiling it into an XPath query.
- 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.
- sealed abstract class DecodeError extends ReadError
Describes an error that occurred while decoding some XML content.
- 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.
- type Document = org.w3c.dom.Document
- type Element = org.w3c.dom.Element
- trait GeneratedDecoders extends AnyRef
- type InputSource = org.xml.sax.InputSource
- trait LowPriorityXmlSourceInstances extends AnyRef
- type Node = org.w3c.dom.Node
- type NodeDecoder[A] = Decoder[Option[Node], A, DecodeError, codecs.type]
Type class for types that can be decoded from an XML Node.
- trait NodeDecoderInstances extends AnyRef
Provides default NodeDecoder instances.
- type NodeList = org.w3c.dom.NodeList
- sealed abstract class ParseError extends ReadError
Describes errors that occur while parsing XML content.
- 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.
- trait Query[A] extends Serializable
Compiled XPath expression.
Compiled XPath expression.
Instance creation is achieved through the companion object.
- sealed abstract class ReadError extends XPathError
Describes an error that occurred while parsing and / or decoding XML content.
- 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.
- 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.
- 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
.
- 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.
- sealed abstract class XPathError extends Error
Describes an error that can occur while dealing with XPath.
- type XPathExpression = javax.xml.xpath.XPathExpression
- 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.
- 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 thenekohtml
module, which needs to take control of the entire parsing process to tidy up messy HTML documents. - 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
- object CompileError extends ErrorCompanion[CompileError]
- object CompileResult extends WithError[CompileError]
- object Compiler extends Serializable
Provides implicit methods to summon Compiler instances.
- object DecodeError extends Serializable
- object DecodeResult extends WithDefault[DecodeError]
Provides instance creation methods for DecodeResult.
- object NodeDecoder extends GeneratedDecoders with DecoderCompanion[Option[Node], DecodeError, codecs.type]
Provides instance creation and summoning methods.
- object ParseError extends Serializable
- object ParseResult extends WithDefault[ParseError]
Provides instance creation methods for ParseResult.
- 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.
- object ReadResult extends Simple[ReadError]
- object RetryStrategy extends Serializable
- object XPathCompiler extends Serializable
- object XPathResult extends Simple[XPathError]
- object XmlParser
Declares the default XmlParser instance in the implicit scope.
- 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 anXmlSource[S]
and aT ⇒ S
, you just need to call XmlSource.contramap to get your implementation. - object codecs extends NodeDecoderInstances
- object implicits extends ToXPathLiteral with AllOps