Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
A cursor: contains an XML Node
and pointers to its children, ancestors and siblings.
Axes
child :: Cursor node -> [Cursor node] #
The child axis. XPath: the child axis contains the children of the context 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 [...].
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.
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.
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 the children of a 'Cursor node'.
($//) :: Cursor node -> (Cursor node -> [a]) -> [a] infixr 1 #
Apply an axis to the descendants of a 'Cursor node'.