XmlSelection

zio.blocks.schema.xml.XmlSelection
See theXmlSelection companion object
final case class XmlSelection(either: Either[SchemaError, Chunk[Xml]]) extends AnyVal

A wrapper around Either[SchemaError, Chunk[Xml]] that provides fluent chaining for XML navigation and querying operations.

XmlSelection enables a fluent API style for navigating through XML structures:

 xml.get("users").elements.apply(0).get("name").texts

The selection can contain zero, one, or multiple XML values, supporting both single-value navigation and multi-value queries.

Attributes

Companion
object
Source
XmlSelection.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class AnyVal
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Combines two selections, concatenating their values.

Combines two selections, concatenating their values.

Attributes

Source
XmlSelection.scala
def all: Either[SchemaError, Xml]

Returns all selected values condensed into a single Xml. If there are multiple values, wraps them in an element. Fails if the selection is empty or an error.

Returns all selected values condensed into a single Xml. If there are multiple values, wraps them in an element. Fails if the selection is empty or an error.

Attributes

Source
XmlSelection.scala
def any: Either[SchemaError, Xml]

Returns any single value from the selection. Fails if the selection is empty or an error.

Returns any single value from the selection. Fails if the selection is empty or an error.

Attributes

Source
XmlSelection.scala
def apply(index: Int): XmlSelection

Navigates to the nth child (any type).

Navigates to the nth child (any type).

Attributes

Source
XmlSelection.scala
def as(xmlType: XmlType): Either[SchemaError, xmlType.Type]

Narrows the single selected value to the specified XML type. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Narrows the single selected value to the specified XML type. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Attributes

Source
XmlSelection.scala

Keeps only CDATA values.

Keeps only CDATA values.

Attributes

Source
XmlSelection.scala

Keeps only comment values.

Keeps only comment values.

Attributes

Source
XmlSelection.scala
def descendant(name: String): XmlSelection

Navigates to all descendant elements with the given name (recursive search). Does not include the starting element itself, only its descendants.

Navigates to all descendant elements with the given name (recursive search). Does not include the starting element itself, only its descendants.

Attributes

Source
XmlSelection.scala

Keeps only element values.

Keeps only element values.

Attributes

Source
XmlSelection.scala
def error: Option[SchemaError]

Returns the error if this is a failure, otherwise None.

Returns the error if this is a failure, otherwise None.

Attributes

Source
XmlSelection.scala
def filter(p: Xml => Boolean): XmlSelection

Filters selected values based on a predicate.

Filters selected values based on a predicate.

Attributes

Source
XmlSelection.scala

FlatMaps a function over all selected values, combining results.

FlatMaps a function over all selected values, combining results.

Attributes

Source
XmlSelection.scala
def get(name: String): XmlSelection

Navigates to child elements with the given name.

Navigates to child elements with the given name.

Attributes

Source
XmlSelection.scala

Navigates using a DynamicOptic path.

Navigates using a DynamicOptic path.

Attributes

Source
XmlSelection.scala
def getOrElse(default: => Chunk[Xml]): Chunk[Xml]

Returns this selection's values, or the default on failure.

Returns this selection's values, or the default on failure.

Attributes

Source
XmlSelection.scala
def isEmpty: Boolean

Returns true if this selection is empty (no values or error).

Returns true if this selection is empty (no values or error).

Attributes

Source
XmlSelection.scala
def isFailure: Boolean

Returns true if the selection is a failure.

Returns true if the selection is a failure.

Attributes

Source
XmlSelection.scala
def isSuccess: Boolean

Returns true if the selection is successful (contains values).

Returns true if the selection is successful (contains values).

Attributes

Source
XmlSelection.scala
def map(f: Xml => Xml): XmlSelection

Maps a function over all selected values.

Maps a function over all selected values.

Attributes

Source
XmlSelection.scala
def nonEmpty: Boolean

Returns true if this selection contains at least one value.

Returns true if this selection contains at least one value.

Attributes

Source
XmlSelection.scala
def one: Either[SchemaError, Xml]

Returns the single selected value or fails if there are 0 or more than 1 values.

Returns the single selected value or fails if there are 0 or more than 1 values.

Attributes

Source
XmlSelection.scala
def orElse(alternative: => XmlSelection): XmlSelection

Returns this selection if successful, otherwise the alternative.

Returns this selection if successful, otherwise the alternative.

Attributes

Source
XmlSelection.scala

Keeps only processing instruction values.

Keeps only processing instruction values.

Attributes

Source
XmlSelection.scala
def size: Int

Returns the number of selected values (0 on error).

Returns the number of selected values (0 on error).

Attributes

Source
XmlSelection.scala
def text: Either[SchemaError, String]

Extracts text content from the single selected element. For Text/CData nodes, returns the content directly. For Element nodes, returns concatenated text of all child text nodes.

Extracts text content from the single selected element. For Text/CData nodes, returns the content directly. For Element nodes, returns concatenated text of all child text nodes.

Attributes

Source
XmlSelection.scala
def textContent: String

Concatenates all text content from the selection. Never fails; returns empty string if no text is found.

Concatenates all text content from the selection. Never fails; returns empty string if no text is found.

Attributes

Source
XmlSelection.scala

Keeps only text values.

Keeps only text values.

Attributes

Source
XmlSelection.scala
def toArray: Either[SchemaError, Xml]

Returns all selected values as an XML element with children.

Returns all selected values as an XML element with children.

Attributes

Source
XmlSelection.scala
def toChunk: Chunk[Xml]

Returns the selected values as a Chunk, or an empty Chunk on failure.

Returns the selected values as a Chunk, or an empty Chunk on failure.

Attributes

Source
XmlSelection.scala
def unwrap(xmlType: XmlType): Either[SchemaError, xmlType.Unwrap]

Extracts the underlying Scala value from the single selected XML value. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Extracts the underlying Scala value from the single selected XML value. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Attributes

Source
XmlSelection.scala
def values: Option[Chunk[Xml]]

Returns the selected values if successful, otherwise None.

Returns the selected values if successful, otherwise None.

Attributes

Source
XmlSelection.scala

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala