Text.XML.Cursor.Generic

xml-conduit-1.9.1.1: Pure-Haskell utilities for dealing with XML with the conduit package.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.XML.Cursor.Generic

Contents

- Core
- Axes
- Operators

Description

Generalized cursors to be applied to different nodes.

Synopsis

- data Cursor node
- type Axis node = Cursor node -> [Cursor node]
- toCursor :: (node -> [node]) -> node -> Cursor node
- node :: Cursor node -> node
- child :: Cursor node -> [Cursor node]
- parent :: Axis node
- precedingSibling :: Axis node
- followingSibling :: Axis node
- ancestor :: Axis node
- descendant :: Axis node
- orSelf :: Axis node -> Axis node
- preceding :: Axis node
- following :: Axis node
- (&|) :: (Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
- (&/) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
- (&//) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
- (&.//) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
- ($|) :: Cursor node -> (Cursor node -> a) -> a
- ($/) :: Cursor node -> (Cursor node -> [a]) -> [a]
- ($//) :: Cursor node -> (Cursor node -> [a]) -> [a]
- ($.//) :: Cursor node -> (Cursor node -> [a]) -> [a]
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c

# Core

data Cursor node #

A cursor: contains an XML `Node` and pointers to its children, ancestors and siblings.

#### Instances

Instances details

Show node => Show (Cursor node) # |
Instance details Defined in Text.XML.Cursor.Generic Methods showsPrec :: Int -> Cursor node -> ShowS # show :: Cursor node -> String # showList :: [Cursor node] -> ShowS #

type Axis node = Cursor node -> [Cursor node] #

toCursor #

Arguments

:: (node -> [node]) | get children
-> node |
-> Cursor node |

node :: Cursor node -> node #

The current node.

# Axes

child :: Cursor node -> [Cursor node] #

The child axis. XPath: the child axis contains the children of the context node.

parent :: Axis node #

The parent axis. As described in XPath: the parent axis contains the parent of the context node, if there is one.

Every node but the root element of the document has a parent. Parent nodes will always be `NodeElement`s.

precedingSibling :: Axis node #

The preceding-sibling axis. XPath: the preceding-sibling axis contains all the preceding siblings of the context node [...].

followingSibling :: Axis node #

The following-sibling axis. XPath: the following-sibling axis contains all the following siblings of the context node [...].

ancestor :: Axis node #

The ancestor axis. XPath: the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node.

descendant :: Axis node #

The descendant axis. XPath: the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus the descendant axis never contains attribute or namespace nodes.

orSelf :: Axis node -> Axis node #

Modify an axis by adding the context node itself as the first element of the result list.

preceding :: Axis node #

The preceding axis. XPath: the preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes.

following :: Axis node #

The following axis. XPath: the following axis contains all nodes in the same document as the context node that are after the context node in document order, excluding any descendants and excluding attribute nodes and namespace nodes.

# Operators

(&|) :: (Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b] infixr 1 #

Apply a function to the result of an axis.

(&/) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a] infixr 1 #

Combine two axes so that the second works on the children of the results of the first.

(&//) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a] infixr 1 #

Combine two axes so that the second works on the descendants of the results of the first.

(&.//) :: Axis node -> (Cursor node -> [a]) -> Cursor node -> [a] infixr 1 #

Combine two axes so that the second works on both the result nodes, and their descendants.

($|) :: Cursor node -> (Cursor node -> a) -> a infixr 1 #

Apply an axis to a 'Cursor node'.

($/) :: Cursor node -> (Cursor node -> [a]) -> [a] infixr 1 #

Apply an axis to the children of a 'Cursor node'.

($//) :: Cursor node -> (Cursor node -> [a]) -> [a] infixr 1 #

Apply an axis to the descendants of a 'Cursor node'.

($.//) :: Cursor node -> (Cursor node -> [a]) -> [a] infixr 1 #

Apply an axis to a 'Cursor node' as well as its descendants.

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #

Left-to-right composition of Kleisli arrows.

'`(bs `>=>` cs) a`' can be understood as the `do` expression

    do b <- bs a
       cs b