-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | The XPath modules for HXT.
--   
--   The Haskell XML Toolbox XPath library.
--   
--   Changes from 9.1.2: Bug in indexing result sets removed
@package hxt-xpath
@version 9.1.2.2


-- | Navigable tree structure which allow a program to traverse for XPath
--   expressions copied and modified from HXML
--   (<a>http://www.flightlab.com/~joe/hxml/</a>)
module Text.XML.HXT.XPath.NavTree
maybeStar :: (a -> Maybe a) -> a -> [a]
maybePlus :: (a -> Maybe a) -> a -> [a]
parentAxis :: NavTree a -> [NavTree a]
ancestorAxis :: NavTree a -> [NavTree a]
ancestorOrSelfAxis :: NavTree a -> [NavTree a]
childAxis :: NavTree a -> [NavTree a]
descendantAxis :: NavTree a -> [NavTree a]
descendantOrSelfAxis :: NavTree a -> [NavTree a]
followingSiblingAxis :: NavTree a -> [NavTree a]
precedingSiblingAxis :: NavTree a -> [NavTree a]
selfAxis :: NavTree a -> [NavTree a]
followingAxis :: NavTree a -> [NavTree a]
precedingAxis :: NavTree a -> [NavTree a]

-- | converts a n-ary tree in a navigable tree
ntree :: NTree a -> NavTree a

-- | navigable tree with nodes of type node
--   
--   a navigable tree consists of a n-ary tree for the current fragment
--   tree, a navigable tree for all ancestors, and two n-ary trees for the
--   previous- and following siblings
data NavTree a
NT :: NTree a -> Int -> [NavTree a] -> [NTree a] -> [NTree a] -> NavTree a
[self] :: NavTree a -> NTree a
[selfIndex] :: NavTree a -> Int
[ancestors] :: NavTree a -> [NavTree a]
[previousSiblings] :: NavTree a -> [NTree a]
[followingSiblings] :: NavTree a -> [NTree a]

-- | converts a navigable tree in a n-ary tree
subtreeNT :: NavTree a -> NTree a

-- | function for selecting the value of the current fragment tree
dataNT :: NavTree a -> a

-- | function for selecting all children of a tree
childrenNT :: NavTree a -> [NTree a]

-- | position of tree in parent
indexNT :: NavTree a -> Int

-- | path (index list) of a navigatable tree
pathNT :: NavTree a -> [Int]
upNT :: NavTree a -> Maybe (NavTree a)
downNT :: NavTree a -> Maybe (NavTree a)
leftNT :: NavTree a -> Maybe (NavTree a)
rightNT :: NavTree a -> Maybe (NavTree a)
preorderNT :: NavTree a -> [NavTree a]
revPreorderNT :: NavTree a -> [NavTree a]
getChildrenNT :: NavTree a -> [NavTree a]

-- | Kleisli composition:
o' :: (b -> [c]) -> (a -> [b]) -> a -> [c]
attributeAxis :: NavTree XNode -> [NavTree XNode]
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Text.XML.HXT.XPath.NavTree.NavTree a)


-- | The core data types of XPath. The Type NodeSet is based on the module
--   <a>NavTree</a> which was adapted from HXML
--   (<a>http://www.flightlab.com/~joe/hxml/</a>)
module Text.XML.HXT.XPath.XPathDataTypes

-- | Represents a floating-point number according the IEEE 754 standard
--   
--   The standard includes a special Not-a-Number (NaN) value, positive and
--   negative infinity, positive and negative zero.
data XPNumber

-- | floating-point number
Float :: Float -> XPNumber

-- | not-a-number
NaN :: XPNumber

-- | negative infinity
NegInf :: XPNumber

-- | negative zero
Neg0 :: XPNumber

-- | positive zero
Pos0 :: XPNumber

-- | positive infinity
PosInf :: XPNumber

-- | Set of navigable trees identified by their document position
--   (NodePath)
newtype NodeSet
NS :: Map NodePath NavXmlTree -> NodeSet
[unNS] :: NodeSet -> Map NodePath NavXmlTree

-- | Represents XPath operators
data Op
Or :: Op
And :: Op
Eq :: Op
NEq :: Op
Less :: Op
Greater :: Op
LessEq :: Op
GreaterEq :: Op
Plus :: Op
Minus :: Op
Div :: Op
Mod :: Op
Mult :: Op
Unary :: Op
Union :: Op
type Name = (NamePrefix, LocalName)

-- | Represents XPath axis
data AxisSpec
Ancestor :: AxisSpec
AncestorOrSelf :: AxisSpec
Attribute :: AxisSpec
Child :: AxisSpec
Descendant :: AxisSpec
DescendantOrSelf :: AxisSpec
Following :: AxisSpec
FollowingSibling :: AxisSpec
Namespace :: AxisSpec
Parent :: AxisSpec
Preceding :: AxisSpec
PrecedingSibling :: AxisSpec
Self :: AxisSpec

-- | Variable name
type VarName = Name

-- | Represents location step
--   
--   A location step consists of an axis, a node-test and zero or more
--   predicates.
data XStep
Step :: AxisSpec -> NodeTest -> [Expr] -> XStep

-- | Represents expression
data Expr

-- | generic expression with an operator and one or more operands
GenExpr :: Op -> [Expr] -> Expr

-- | a path expression contains an optional filter-expression or an
--   optional locationpath. one expression is urgently necessary, both are
--   possible
PathExpr :: Maybe Expr -> Maybe LocationPath -> Expr

-- | filter-expression with zero or more predicates
FilterExpr :: [Expr] -> Expr

-- | variable
VarExpr :: VarName -> Expr

-- | string
LiteralExpr :: Literal -> Expr

-- | number
NumberExpr :: XPNumber -> Expr

-- | a function with a name and an optional list of arguments
FctExpr :: FctName -> FctArguments -> Expr

-- | Represents location path
--   
--   A location path consists of a sequence of one or more location steps.
data LocationPath
LocPath :: Path -> [XStep] -> LocationPath

-- | a string
type Literal = String

-- | Function name
type FctName = String

-- | Function arguments
type FctArguments = [Expr]

-- | A location path is either a relative or an absolute path.
data Path
Rel :: Path
Abs :: Path

-- | Represents XPath node-tests
data NodeTest

-- | name-test
NameTest :: QName -> NodeTest

-- | processing-instruction-test with a literal argument
PI :: String -> NodeTest

-- | all nodetype-tests
TypeTest :: XPathNode -> NodeTest

-- | Represents nodetype-tests
data XPathNode

-- | all 7 nodetypes (root, element, attribute, namespace, pi, comment,
--   text)
XPNode :: XPathNode

-- | comment-nodes
XPCommentNode :: XPathNode

-- | processing-instruction-nodes
XPPINode :: XPathNode

-- | text-nodes: cdata, character data
XPTextNode :: XPathNode
type NamePrefix = String
type LocalName = String

-- | Evaluation context
type Context = (ConPos, ConLen, ConNode)

-- | Context position
type ConPos = Int

-- | Context length
type ConLen = Int

-- | Context node
type ConNode = NavXmlTree

-- | Node of navigable tree representation
type NavXmlTree = NavTree XNode

-- | Represents XPath results
data XPathValue

-- | node-set
XPVNode :: NodeSet -> XPathValue

-- | boolean value
XPVBool :: Bool -> XPathValue

-- | number according the IEEE 754 standard
XPVNumber :: XPNumber -> XPathValue

-- | string value
XPVString :: String -> XPathValue

-- | error message with text
XPVError :: String -> XPathValue

-- | List of nodes of navigable tree representation
type NavXmlTrees = [NavXmlTree]

-- | path represented as list of indices starting at root
type NodePath = [Int]

-- | A functions that takes a XPath result and returns a XPath result
type XPathFilter = XPathValue -> XPathValue
withXPVNode :: String -> (NodeSet -> XPathValue) -> XPathFilter

-- | node set functions
emptyNodeSet :: NodeSet
singletonNodeSet :: NavXmlTree -> NodeSet
toNodeSet :: NavXmlTrees -> NodeSet
nullNodeSet :: NodeSet -> Bool
cardNodeSet :: NodeSet -> Int
deleteNodeSet :: NodePath -> NodeSet -> NodeSet
insertNodeSet :: NavXmlTree -> NodeSet -> NodeSet
unionNodeSet :: NodeSet -> NodeSet -> NodeSet
unionsNodeSet :: [NodeSet] -> NodeSet
elemsNodeSet :: NodeSet -> [(NodePath, NavXmlTree)]
fromNodeSet :: NodeSet -> NavXmlTrees
headNodeSet :: NodeSet -> NavXmlTree
withNodeSet :: (NavXmlTrees -> NavXmlTrees) -> NodeSet -> NodeSet

-- | XPath environment
--   
--   All variables are stored in the environment, each variable name is
--   bound to a value.
type VarTab = [(VarName, XPathValue)]
type KeyTab = [(QName, String, NavXmlTree)]
type Env = (VarTab, KeyTab)
varEnv :: Env
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.AxisSpec
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.Expr
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.LocationPath
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.NodeSet
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.NodeTest
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.Op
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.Path
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.XPNumber
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.XPathNode
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.XPathValue
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathDataTypes.XStep
instance GHC.Classes.Ord Text.XML.HXT.XPath.XPathDataTypes.NodeSet
instance GHC.Classes.Ord Text.XML.HXT.XPath.XPathDataTypes.XPNumber
instance GHC.Classes.Ord Text.XML.HXT.XPath.XPathDataTypes.XPathValue
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.AxisSpec
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.Expr
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.LocationPath
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.NodeSet
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.NodeTest
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.Op
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.Path
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.XPNumber
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.XPathNode
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.XPathValue
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathDataTypes.XStep


-- | The module contains arithmetic calculations according the IEEE 754
--   standard for plus, minus, unary minus, multiplication, modulo and
--   division.
module Text.XML.HXT.XPath.XPathArithmetic

-- | Multiplication
xPathMulti :: Op -> XPathValue -> XPathFilter

-- | Modulo
xPathMod :: Op -> XPathValue -> XPathFilter

-- | Division: the divison-operator is not according the IEEE 754 standard,
--   it calculates the same as the % operator in Java and ECMAScript
xPathDiv :: Op -> XPathValue -> XPathFilter

-- | Plus and minus
--   
--   <ol>
--   <li>parameter op : plus or minus operation</li>
--   </ol>
xPathAdd :: Op -> XPathValue -> XPathFilter

-- | Unary minus: the value <a>NaN</a> is not calculatable and returned
--   unchanged, all other values can be denied.
xPathUnary :: XPathFilter


-- | xpath keywords
module Text.XML.HXT.XPath.XPathKeywords
a_ancestor :: String
a_ancestor_or_self :: String
a_attribute :: String
a_child :: String
a_descendant :: String
a_descendant_or_self :: String
a_following :: String
a_following_sibling :: String
a_namespace :: String
a_parent :: String
a_preceding :: String
a_preceding_sibling :: String
a_self :: String
n_comment :: String
n_text :: String
n_processing_instruction :: String
n_node :: String


-- | The XPath Parser
module Text.XML.HXT.XPath.XPathParser

-- | parsing a number, parseNumber is used in <a>XPathFct</a> by the number
--   function
--   
--   <ul>
--   <li>returns : the parsed number as <a>XPNumber</a> float or
--   <a>XPVNumber</a> <a>NaN</a> in case of error</li>
--   </ul>
parseNumber :: String -> XPathValue

-- | the main entry point: parsing a XPath expression
parseXPath :: XPathParser Expr


-- | The module contains the core-functions of the XPath function library.
--   All functions are implemented as XFct. Each XFct contains the
--   evaluation context, the variable environment and the function
--   arguments.
module Text.XML.HXT.XPath.XPathFct

-- | Type signature for all functions which can be used in the XPath
--   module.
type XFct = Context -> Env -> [XPathValue] -> XPathValue

-- | Evaluates a function. Calculation of the function value is done by
--   looking up the function name in the function table, check the number
--   of arguments and calculate the funtion, if no argument evaluation
--   returns an error.
--   
--   <ul>
--   <li>returns : the function value as <a>XPathValue</a></li>
--   </ul>
evalFct :: FctName -> Env -> Context -> [XPathValue] -> XPathValue

-- | Converts a list of different <a>XPathValue</a> types in a list of one
--   <a>XPathValue</a> type.
--   
--   <ul>
--   <li>1.parameter fct : the conversion function</li>
--   </ul>
toXValue :: XFct -> Context -> Env -> [XPathValue] -> [XPathValue]

-- | number number(object?): converts its argument to a number
xnumber :: XFct

-- | boolean boolean(object): converts its argument to a boolean value
xboolean :: XFct

-- | string string(object?): converts an object to a string
xstring :: XFct

-- | Returns the conversion function for the XPath results: string, boolean
--   and number A nodeset can not be converted.
getConvFct :: XPathValue -> Maybe XFct

-- | Returns the string-value of a node, the value of a namespace node is
--   not supported
stringValue :: NavXmlTree -> XPathValue

-- | Check whether a node is not a part of a node list. Needed to implement
--   matching &amp; testing in xslt.
isNotInNodeList :: NavXmlTree -> [NavXmlTree] -> Bool

-- | Returns the table of variables from the environment
getVarTab :: Env -> VarTab

-- | Returns the table of keys, needed by xslt, from the environment
getKeyTab :: Env -> KeyTab
instance GHC.Classes.Eq Text.XML.HXT.XPath.XPathFct.IdPathStep
instance GHC.Internal.Show.Show Text.XML.HXT.XPath.XPathFct.IdPathStep


-- | Convert an XPath result set into a node set
module Text.XML.HXT.XPath.XPathToNodeSet

-- | Convert a a XPath-value into a XmlNodeSet represented by a tree
--   structure
--   
--   The XmlNodeSet can be used to traverse a tree an process all marked
--   nodes.
xPValue2XmlNodeSet :: XPathValue -> XmlNodeSet
emptyXmlNodeSet :: XmlNodeSet


-- | Format an expression or value in tree- or string-representation
module Text.XML.HXT.XPath.XPathToString

-- | Format a parsed XPath-expression in tree representation. Text output
--   is done by <a>formatXmlTree</a>
expr2XPathTree :: Expr -> XPathTree

-- | Format a XPath-value in string representation. Text output is done by
--   <a>formatXmlTree</a> for node-sets (trees), all other values are
--   represented as strings.
xPValue2String :: XPathValue -> String

-- | Convert a a XPath-value into XmlTrees.
xPValue2XmlTrees :: XPathValue -> XmlTrees
nt2XPathTree :: NodeTest -> XPathTree
pred2XPathTree :: [Expr] -> XPathTree

-- | Convert an navigable tree in a xmltree
toXPathTree :: [NavTree a] -> [NTree a]
formatXPathTree :: Expr -> String


-- | The core functions for evaluating the different types of XPath
--   expressions. Each <a>Expr</a>-constructor is mapped to an evaluation
--   function.
module Text.XML.HXT.XPath.XPathEval

-- | Select parts of a document by a string representing a XPath
--   expression.
--   
--   The main filter for selecting parts of a document via XPath. The
--   string argument must be a XPath expression with an absolute location
--   path, the argument tree must be a complete document tree. Result is a
--   possibly empty list of XmlTrees forming the set of selected XPath
--   values. XPath values other than XmlTrees (numbers, attributes,
--   tagnames, ...) are converted to text nodes.
getXPath :: String -> XmlTree -> XmlTrees

-- | Select parts of an XML tree by a string representing an XPath
--   expression.
--   
--   The main filter for selecting parts of an arbitrary XML tree via
--   XPath. The string argument must be a XPath expression with an absolute
--   location path, There are no restrictions on the arument tree.
--   
--   No canonicalization is performed before evaluating the query
--   
--   Result is a possibly empty list of XmlTrees forming the set of
--   selected XPath values. XPath values other than XmlTrees (numbers,
--   attributes, tagnames, ...) are convertet to text nodes.
getXPathSubTrees :: String -> XmlTree -> XmlTrees

-- | compute the node set of an XPath query
getXPathNodeSet' :: String -> XmlTree -> XmlNodeSet

-- | Select parts of a document by a namespace aware XPath expression.
--   
--   Works like <a>getXPath</a> but the prefix:localpart names in the XPath
--   expression are interpreted with respect to the given namespace
--   environment
getXPathWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees

-- | Same as <a>getXPathSubTrees</a> but with namespace aware XPath
--   expression
getXPathSubTreesWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees

-- | compute the node set of a namespace aware XPath query
getXPathNodeSetWithNsEnv' :: Attributes -> String -> XmlTree -> XmlNodeSet

-- | The main evaluation entry point. Each XPath-<a>Expr</a> is mapped to
--   an evaluation function. The <a>Env</a>-parameter contains the set of
--   global variables for the evaluator, the <a>Context</a>-parameter the
--   root of the tree in which the expression is evaluated.
evalExpr :: Env -> Context -> Expr -> XPathFilter
addRoot' :: XmlTree -> XmlTree

-- | parse an XPath expr string and return an expr tree or an error
--   message. Namespaces are not taken into account.
parseXPathExpr :: String -> Either String Expr

-- | parse an XPath expr string with a namespace environment for qualified
--   names in the XPath expr and return an expr tree or an error message
parseXPathExprWithNsEnv :: Attributes -> String -> Either String Expr

-- | Select parts of a document by an already parsed XPath expression
getXPath' :: Expr -> XmlTree -> XmlTrees

-- | Select parts of an XML tree by an XPath expression.
getXPathSubTrees' :: Expr -> XmlTree -> XmlTrees

-- | compute the node set of an XPath query for an already parsed XPath
--   expr
getXPathNodeSet'' :: Expr -> XmlTree -> XmlNodeSet


-- | Most of the XPath arrows come in two versions, one without dealing
--   with namespaces, element and attribute names in XPath expressions are
--   taken as they ar ignoring any prefix:localname structure.
--   
--   The second variant uses a namespace environment for associating the
--   right namespace for the appropriate prefix. An entry for the empty
--   prefix defines the default namespace for the expression.
--   
--   The second variant should be used, when in the application namespaces
--   are significant, that means when namespace propagation is done for the
--   documents to be processed.
--   
--   The XPath evaluator computes a result, which can be a simple value
--   like a string or number, or a node set. The nodes in these sets are
--   identified by their position in the document tree. Node sets are
--   returned as a list of XmlTrees with respect to the document order.
module Text.XML.HXT.XPath.Arrows

-- | Select parts of a whole XML document with root node by a XPath
--   expression.
--   
--   The main filter for selecting parts of a document via XPath.
--   
--   The string argument must be a XPath expression with an absolute
--   location path, the argument tree must be a complete document tree.
--   
--   Before evaluating the xpath query, the document is canonicalized with
--   <a>canonicalizeForXPath</a>
--   
--   Result is a possibly empty list of XmlTrees forming the set of
--   selected XPath values. XPath values other than XmlTrees (numbers,
--   attributes, tagnames, ...) are convertet to text nodes.
getXPathTreesInDoc :: ArrowXml a => String -> a XmlTree XmlTree

-- | Same as <a>getXPathTreesInDoc</a> but with namespace environment for
--   the XPath names
getXPathTreesInDocWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree

-- | Select parts of an arbitrary XML tree by a XPath expression.
--   
--   The main filter for selecting parts of an arbitrary XML tree via
--   XPath. The string argument must be a XPath expression with an absolute
--   location path, There are no restrictions on the argument tree.
--   
--   No canonicalization is performed before evaluating the query
--   
--   Result is a possibly empty list of XmlTrees forming the set of
--   selected XPath values. XPath values other than XmlTrees (numbers,
--   attributes, tagnames, ...) are convertet to text nodes.
getXPathTrees :: ArrowXml a => String -> a XmlTree XmlTree

-- | Same as <a>getXPathTrees</a> but with namespace environment for the
--   XPath names
getXPathTreesWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree

-- | compute a node set from a tree, containing all nodes selected by the
--   predicate arrow
--   
--   computation of the set of element nodes with name "a" is done with
--   
--   <pre>
--   getElemNodeSet (hasName "a")
--   </pre>
getElemNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet

-- | compute a node set from a tree, containing all nodes including
--   attribute nodes elected by the predicate arrow
getElemAndAttrNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet

-- | Select a set of nodes via an XPath expression from an arbitray XML
--   tree
--   
--   The result is a set of "pointers" to nodes. This set can be used to
--   access or modify the values of the subnodes in subsequent calls to
--   <a>getFromNodeSet</a> or <a>processFromNodeSet</a>.
--   
--   This function enables for parsing an XPath expressions and traversing
--   the tree for node selection once and reuse this result possibly many
--   times for later selection and modification operations.
getXPathNodeSet :: ArrowXml a => String -> a XmlTree XmlNodeSet

-- | select all subtrees specified by a previously computed node set
--   
--   the following law holds:
--   
--   <pre>
--   getFromNodeSet $&lt; getElemNodeSet f == multi f
--   </pre>
getFromNodeSet :: ArrowXml a => XmlNodeSet -> a XmlTree XmlTree

-- | process all subtrees selected by an XPath expression
--   
--   the following law holds:
--   
--   <pre>
--   processXPathTrees p xpathExpr == processFromNodeSet p $&lt; getXPathNodeSet xpathExpr
--   </pre>
processXPathTrees :: ArrowXml a => a XmlTree XmlTree -> String -> a XmlTree XmlTree

-- | Same as <a>processXPathTrees</a> but with namespace environment for
--   the XPath names
processXPathTreesWithNsEnv :: ArrowXml a => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree

-- | process all subtrees specified by a previously computed node set in
--   bottom up manner
--   
--   the following law should hold:
--   
--   <pre>
--   processFromNodeSet g $&lt; getElemNodeSet f == processBottomUp (g `when` f)
--   </pre>
--   
--   when attributes are contained in the node set (see
--   <a>getElemAndAttrNodeSet</a>), these are processed after the children
--   and before the node itself
--   
--   the advantage of processFromNodeSet is the separation of the selection
--   of set of nodes to be processed (e.g. modified) from the real
--   proccessing. The selection sometimes can be done once, the processing
--   possibly many times.
processFromNodeSet :: ArrowXml a => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree


-- | This helper module exports elements from the basic libraries:
--   XPathEval, XPathToString and XPathParser
--   
--   Author : Torben Kuseler
module Text.XML.HXT.XPath
