!Ksy       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde f g h i j k l m n o p q r s t u v w x y z { | } ~        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$% & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z {!|!}!~!"""""""""""""""""""""""""""##$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ $ $ $ $$$$$$$$$$$$$$$$$%% %!%"%#%$%%%&%'%(%)%*%+%,%-%.%/%0%1%2%3%4&5&6&7&8&9&:&;&<&=&>&?&@&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&[&\&]&^'_'`'a'b'c'd'e'f'g'h'i'j'k'l'm'n'o'p'q'r's't'u'v'w'x'y'z'{'|'}'~''''''''''''''''''''''''''(())))))))))))**************************+++++++++++++++++++++++++++++++++,,-................/01111111111111111111 1 1 1 1 1111111111111111111 1!1"1#1$1%1&1'1(1)1*1+1,1-1.1/202122232425262738393:3;3<3=3>3?3@3A3B3C3D3E3F3G3H3I3J3K3L3M3N3O3P3Q3R3S3T3U3V3W3X3Y3Z4[4\5]6^7_7`8a8b8c8d8e8f8g9h9i9j9k9l9m9n:o:p:q:r:s:t:u:v:w:x:y:z:{:|:};~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<=>>>>>>>?????????????@@@@@@@@@@@@@@@@@@AAAAAAAAAAAAAAAAAAAABBBBBBCDDDDDEEEEFFGGGGGGGHHHHHHHHIJJJJJJJJJJJJ J J J J JJJJJJJJJJJJJJJJJJJ J!J"J#J$J%J&J'J(J)J*J+J,J-J.J/J0J1J2J3J4J5J6K7K8K9K:K;K<K=K>K?K@KAKBKCKDKEKFKGKHKIKJKKKLKMKNKOKPKQKRKSKTKUKVKWKXKYKZK[K\K]K^K_K`KaKbKcKdKeKfKgKhKiKjKkKlKmKnKoKpLqLrLsLtLuLvLwLxLyLzL{L|L}L~LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNN NRCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AChphxt>the interface for converting an IO predicate into a list arrowhxt$builds an arrow from an IO predicatekif the predicate holds, the single list containing the input is returned, else the empty list, similar to Ohxt7the interface for converting an IO action into an arrowhxt$construct an arrow from an IO actionhxt:construct an arrow from an IO action without any parameterhxtJconstruction of a 2 argument arrow from a binary IO action | | example:  a1 &&& a2 >>> arr2 f hxtIconstruction of a 3 argument arrow from a 3-ary IO action | | example:  a1 &&& a2 &&& a3 >>> arr3 f hxtIconstruction of a 4 argument arrow from a 4-ary IO action | | example: $ a1 &&& a2 &&& a3 &&& a4 >>> arr4 f Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental not portableSafe2=?@ACj  Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AC hxtThe interface for list arrowsOnly mkA, + '(>>.)' don't have default implementations hxtIconstruction of a 2 argument arrow from a binary function | | example:  a1 &&& a2 >>> arr2 f hxtHconstruction of a 3 argument arrow from a 3-ary function | | example:  a1 &&& a2 &&& a3 >>> arr3 f hxtHconstruction of a 4 argument arrow from a 4-ary function | | example: $ a1 &&& a2 &&& a3 &&& a4 >>> arr4 f hxt>construction of a 2 argument arrow from a singe argument arrowhxtBconstructor for a list arrow from a function with a list as resulthxt-constructor for a list arrow with 2 argumentshxtconstructor for a const arrow:  constA = arr . const hxtconstructor for a const arrow:  constL = arrL . const hxtbuilds an arrow from a predicate. If the predicate holds, the single list containing the input is returned, else the empty listhxtFcombinator for converting the result of a list arrow into another list example:  foo >>. reverse  reverses the the result of foo example:  foo >>. take 1 J constructs a deterministic version of foo by deleting all further resultshxtMcombinator for converting the result of an arrow into a single element resulthxtrcombinator for converting an arrow into a determinstic version with all results collected in a single element list  listA af = af >>. (:[])^this is useful when the list of results computed by an arrow must be manipulated (e.g. sorted)+example for sorting the results of a filter ^collectAndSort :: a b c -> a b c collectAndSort collect = listA collect >>> arrL sorthxtthe inverse of   listA af >>> unlistA = afunlistA is defined as  arrL id hxt%the identity arrow, alias for returnAhxt#the zero arrow, alias for zeroArrowhxtDconverts an arrow, that may fail, into an arrow that always succeeds example:  withDefault none "abc"  is equivalent to  constA "abc" hxtDmakes a list arrow deterministic, the number of results is at most 1 definition single f = f >>. take 1examples with strings: runLA ( single none ) "x" == [] runLA ( single this ) "x" == ["x"] runLA ( single (constA "y" <+> this ) ) "x" == ["y"]hxtAcompute an arrow from the input and apply the arrow to this input definition:  (f &&& this) >>> app in a point free style, there is no way to use an argument in 2 places, this is a combinator for simulating this. first the argument is used to compute an arrow, then this new arrow is applied to the inputapplyA coresponds to:  apply f x = let g = f x in g x  see also: , ,  , !, "hxtcompute the parameter for an arrow with extra parameters from the input and apply the arrow for all parameter values to the input?a kind of "function call" for arrows, useful for joining arrows  infixl 2 ($<) definition: g $< f = applyA (f >>> arr g)if f$ fails, the whole arrow fails, e.g.  g $< none == none if f computes n values and g4 is deterministic, the whole arrow computes n values-examples with simple list arrows with strings prefixString :: String -> a String String prefixString s = arr (s++) runLA ( prefixString $< none ) "x" == [] runLA ( prefixString $< constA "y" ) "x" == ["yx"] runLA ( prefixString $< this ) "x" == ["xx"] runLA ( prefixString $< constA "y" <+> constA "z" ) "x" == ["yx","zx"] runLA ( prefixString $< constA "y" <+> this <+> constA "z" ) "x" == ["yx","xx","zx"] see also: , ,  , !, "hxtbinary version of ,example with simple list arrows with strings dinfixString :: String -> String -> a String String infixString s1 s2 = arr (\ s -> s1 ++ s ++ s2) runLA ( infixString $<< constA "y" &&& constA "z" ) "x" = ["yxz"] runLA ( infixString $<< this &&& this ) "x" = ["xxx"] runLA ( infixString $<< constA "y" &&& (constA "z" <+> this) ) "x" = ["yxz", "yxx"] hxt version of # for arrows with 3 extra parameters typical usage f $<<< g1 &&& g2 &&& g3!hxt version of # for arrows with 4 extra parameters typical usage f $<<<< g1 &&& g2 &&& g3 &&& g4"hxt#compute the parameter for an arrow f% with an extra parameter by an arrow g! and apply all the results from g sequentially to the input infixl 2 ($<$)typical usage: <g :: a b c g = ... f :: c -> a b b f x = ... x ... f $<$ gf# computes the extra parameters for g from the input of type b and g` is applied with this parameter to the input. This allows programming in a point wise style in gC, which becomes neccessary, when a value is needed more than once.[this combinator is useful, when transforming a single value (document) step by step, with g, for collecting the data for all steps, and f( for transforming the input step by stepif g2 is deterministic (computes exactly one result),  g $<$ f == g $< f  holdsif g fails,  f $<$ g == this if g computes more than one result, f< is applied sequentially to the input for every result from g-examples with simple list arrows with strings prefixString :: String -> a String String prefixString s = arr (s++) runLA ( prefixString $<$ none ) "x" == ["x"] runLA ( prefixString $<$ constA "y" ) "x" == ["yx"] runLA ( prefixString $<$ constA "y" <+> constA "z" ) "x" == ["zyx"] runLA ( prefixString $<$ constA "y" <+> this <+> constA "z" ) "x" == ["zxyx"] example with two extra parameter kg1 :: a b c1 g2 :: a b c2 f :: (c1, c2) -> a b b f (x1, x2) = ... x1 ... x2 ... f $<$ g1 &&& g2 see also: , #hxt-merge the result pairs of an arrow with type  a a1 (b1, b2)- by combining the tuple components with the op arrow@examples with simple list arrows working on strings and XmlTrees 9 a1 :: a String (XmlTree, XmlTree) a1 = selem "foo" [this >>> mkText] &&& selem "bar" [arr (++"0") >>> mkText] runLA (a1 >>> mergeA (<+>) >>> xshow this) "42" == ["<foo>42</foo>","<bar>420</bar>"] runLA (a1 >>> mergeA (+=) >>> xshow this) "42" == ["<foo>42<bar>420</bar></foo>"] see also: ,  and += in class PQ$hxtyuseful only for arrows with side effects: perform applies an arrow to the input ignores the result and returns the input example: ( ... >>> perform someTraceArrow >>> ... %hxt#generalization of arrow combinator   definition:  catA = foldl (<+>) none &hxt#generalization of arrow combinator   definition:  seqA = foldl (>>>) this  # !" &$% # !" &$%8822 2!2"2Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AC'hxtan auxiliary data type for 7)hxt)The interface for arrows as conditionals.ZRequires list arrows because False is represented as empty list, True as none empty lists.Only * and 6# don't have default implementations*hxtif lifted to arrows+hxt shortcut:  ifP p = ifA (isA p) ,hxt negation:  neg f = ifA f none this -hxt f `when` g J : when the predicate g holds, f is applied, else the identity filter this.hxt shortcut:  f `whenP` p = f `when` (isA p) /hxt f `whenNot` g R : when the predicate g does not hold, f is applied, else the identity filter this0hxtlike .1hxt g `guards` f 6 : when the predicate g holds, f is applied, else none2hxtlike .3hxt shortcut for  f 1 this 4hxt f `containing` g 3 : keep only those results from f for which g holds definition: * f `containing` g = f >>> g `guards` this 5hxt f `notContaining` g ; : keep only those results from f for which g does not hold definition: - f `notContaining` g = f >>> ifA g none this 6hxt f `orElse` g V : directional choice: if f succeeds, the result of f is the result, else g is applied7hxtgeneralisation of 61 for multi way branches like in case expressions.An auxiliary data type ' with an infix constructor (' is used for writing multi way branches example: 4 choiceA [ p1 :-> e1, p2 :-> e2, this :-> default ] 8hxt`tag a value with Left or Right, if arrow has success, input is tagged with Left, else with Right9hxt\split a list value with an arrow and returns a pair of lists. This is the arrow version of  . The arrow is deterministic. example: ( runLA (spanA (isA (/= '-'))) "abc-def"  gives  [("abc","-def")]  as result:hxt/partition a list of values into a pair of listsThis is the arrow Version of  '()-6*+,./012345789:'()-6*+,./012345789:Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental=multi parameter classes and functional depenedencies requiredSafe2=?@AC;hxt=The interface for accessing and changing the state component.AMulti parameter classes and functional dependencies are required.<hxtchange the state of a state arrow by applying a function for computing a new state from the old and the arrow input. Result is the arrow input=hxt_access the state with a function using the arrow input as data for selecting state components.>hxt+read the complete state, ignore arrow input definition: % getState = accessState (\ s x -> s) ?hxtoverwrite the old state definition: % setState = changeState (\ s x -> x) @hxt4change state (and ignore input) and return new stateFconvenience function, usefull for generating e.g. unique identifiers:"example with SLA state list arrows newId :: SLA Int b String newId = nextState (+1) >>> arr (('#':) . show) runSLA 0 (newId <+> newId <+> newId) undefined = ["#1", "#2", "#3"];>?<=@;>?<=@Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@ACAhxtcA class of types that can be partially evaluated, but evaluation can be propagated deeper than WHNFBhxt%Default for rwnf is reduction to WHNFChxtDefault for rwnf2 is rwnfACBDEFDEFACBD0Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental non-portableSafe2=?@AC<Whxt,partial evaluation of an arrow result using RSmThere are two arrows with force the partial evaluation. By convention the 2. should be less lazy than the 1.These arrows are sometimes useful for preventing space leaks, especially when parsing complex data structures. In many cases the evaluated AST is more space efficient than the unevaluaded with a lot of closures.\hxt-complete evaluation of an arrow result using RTthis is sometimes useful for preventing space leaks, especially after reading and validation of a document, all DTD stuff is not longer in use and can be recycled by the GC.WYXZ[\\Z[WYXCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableSafe2=?@AC^hxtlookup with default value_hxt6lookup with empty list (empty string) as default value`hxttest for existence of a keyahxtkadd an entry, remove an existing entry before adding the new one at the top of the list, addEntry is strictbhxt!add a whole list of entries with achxt#delete an entry, delEntry is strictdhxtdelete a list of entries with c]^_`abcd]^_`abcd Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental non-portableNone2=?@AChxt"the internal cache for the stringshxt'insert a bytestring into the atom cachefhxtcreation of an Atom from a Stringhxt.The internal operation running in the IO monadghxt Insert a String6 into the atom cache and convert the atom back into a String. locically  share == id; holds, but internally equal strings share the same memory.efgefg Safe2=?@AC#bqhxtXSelectors for pairs and 3-tuples: comp1, comp2, comp3, this can be extended to n-tuplesshxtwA Selector is a pair of an access function and a modifying function for reading and updating parts of a composite typeyhxtAlias for constructor Smnopqrstvuwxyz{stvuwxyz{qropmn{3 Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AC1hxtThe interface for treeshxtWtree construction: a new tree is constructed by a node attribute and a list of childrenhxt0leaf construction: leafs don't have any children definition:  mkLeaf n = mkTree n [] hxt"leaf test: list of children empty?hxtinnner node test:  not . isLeaf hxtselect node attributehxtselect childrenhxtedit node attributehxt edit childrenhxtsubstitute node: " setNode n = changeNode (const n) hxtsubstitute children: , setChildren cl = changeChildren (const cl) hxtfold for treeshxtall nodes of a treehxtdepth of a treehxtnumber of nodes in a treehxt%format tree for readable trace outputa  graphical* representation of the tree in text formathxt<convert a tree into a pseudo graphical string representation Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de)stableportableSafe2=?@AChxtThe interface for tree arrows*all functions have default implementationshxtconstruct a leafhxtconstruct an inner nodehxt)select the children of the root of a treehxt*select the node info of the root of a treehxt*select the attribute of the root of a treehxt-substitute the children of the root of a treehxt.substitute the attribute of the root of a treehxt'edit the children of the root of a treehxt(edit the attribute of the root of a treehxtapply an arrow element wise to all children of the root of a tree collect these results and substitute the children with this result example:  processChildren isText 5 deletes all subtrees, for which isText does not hold example: % processChildren (none `when` isCmt) , removes all children, for which isCmt holdshxtasimilar to processChildren, but the new children are computed by processing the whole input tree example:  replaceChildren (deep isText) t selects all subtrees for which isText holds and substitutes the children component of the root node with this listhxt&pronounced "slash", meaning g inside f defined as " f /> g = f >>> getChildren >>> g  example: 2 hasName "html" /> hasName "body" /> hasName "h1" This expression selects all "h1" elements in the "body" element of an "html" element, an expression, that corresponds 1-1 to the XPath selection path "html/body/h1"hxt>pronounced "double slash", meaning g arbitrarily deep inside f defined as ( f //> g = f >>> getChildren >>> deep g  example: $ hasName "html" //> hasName "table" This expression selects all top level "table" elements within an "html" element, an expression. Attention: This does not correspond to the XPath selection path "html//table". The latter on matches all table elements even nested ones, but //>3 gives in many cases the appropriate functionality.hxt+pronounced "outside" meaning f containing g defined as - f </ g = f `containing` (getChildren >>> g) hxtrecursively searches a whole tree for subtrees, for which a predicate holds. The search is performed top down. When a tree is found, this becomes an element of the result list. The tree found is not further examined for any subtress, for which the predicate also could hold. See  for this kind of search. example:  deep isHtmlTable  selects all top level table elements in a document (with an appropriate definition for isHtmlTable) but no tables occuring within a table cell.hxtorecursively searches a whole tree for subrees, for which a predicate holds. The search is performed bottom up. example:  deepest isHtmlTable b selects all innermost table elements in a document but no table elements containing tables. See  and  for other search strategies.hxtrecursively searches a whole tree for subtrees, for which a predicate holds. The search is performed top down. All nodes of the tree are searched, even within the subtrees of trees for which the predicate holds. example:  multi isHtmlTable . selects all table elements, even nested ones.hxtrecursively transforms a whole tree by applying an arrow to all subtrees, this is done bottom up depth first, leaves first, root as last tree example: 1 processBottomUp (getChildren `when` isHtmlFont) k removes all font tags in a HTML document, even nested ones (with an appropriate definition of isHtmlFont)hxt similar to , but recursively transforms a whole tree by applying an arrow to all subtrees with a top down depth first traversal strategie. In many cases  and  give same results.hxtrecursively transforms a whole tree by applying an arrow to all subtrees, but transformation stops when a predicte does not hold for a subtree, leaves are transformed firsthxtrecursively transforms a whole tree by applying an arrow to all subtrees, but transformation stops when a tree is successfully transformed. the transformation is done top down example: : processTopDownUntil (isHtmlTable `guards` tranformTable) ` transforms all top level table elements into something else, but inner tables remain unchangedhxt}computes a list of trees by applying an arrow to the input and inserts this list in front of index i in the list of children example: ! insertChildrenAt 0 (deep isCmt) ` selects all subtrees for which isCmt holds and copies theses in front of the existing childrenhxt similar to 9, but the insertion position is searched with a predicatehxtan arrow for inserting a whole subtree with some holes in it (a template) into a document. The holes can be filled with contents from the input.Example insertTreeTemplateTest :: ArrowXml a => a b XmlTree insertTreeTemplateTest = doc >>> insertTreeTemplate template pattern where doc -- the input data = constA "<x><y>The Title</y><z>The content</z></x>" >>> xread template -- the output template with 2 holes: xxx and yyy = constA "<html><head><title>xxx</title></head><body><h1>yyy</h1></body></html>" >>> xread pattern = [ hasText (== "xxx") -- fill the xxx hole with the input contents from element "x/y" :-> ( getChildren >>> hasName "y" >>> deep isText ) , hasText (== "yyy") -- fill the yyy hole with the input contents from element "x/z" :-> ( getChildren >>> hasName "z" >>> getChildren ) ]0computes the XML tree for the following document U"<html><head><title>The Title</title></head><body><h1>The content</h1></body></html>"555 #Copyright (C) 2005-2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de)stableportableSafe2=?@AChxt&shortcut for a sequence of n-ary treeshxtn-ary ordered tree (rose trees)a tree consists of a node and a possible empty list of children. If the list of children is empty, the node is a leaf, else it's an inner node.'NTree implements Eq, Ord, Show and ReadhxtImplementation of Data.Tree.Class interface for rose treeshxt!NTree implements class TaversablehxtNTree implements class FoldablehxtNTree implements class FunctorMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AChxt9editNTreeBottomUp is a space optimized tree edit functionThe nodes in a tree are visited bottom up. An edit function is applied to all nodes. A Nothing result of the editing function indicates no changes. This is used to share the input tree within the resulting tree.The following law holds: *editNTreeBottomUp (const Nothing) t == [t]In this case the resulting tree does not only represent the same value but it is the same machine value (relative to some evaluations of closures during the tree walkYWith a simple fold like editing function the whole tree would be reconstructed in memoryhxt A space optimized map for NTrees\Subtrees, that are not changed are reused in the resulting tree See also: editNTreeBottomUpCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AChxt#Edit operation on navigatable treesrThere is only a single navigatable tree implementation for a given tree allowed (see the functional dependencies)hxt;add an ordinary tree in front of the given navigatable treehxt9add an ordinary tree behind of the given navigatable treehxt?drop the direct left sibling tree of the given navigatable treehxt@drop the direct right sibling tree of the given navigatable treehxt)change the tree but remain the navigationhxt/Conversion between trees and navigatable trees,rThere is only a single navigatable tree implementation for a given tree allowed (see the functional dependencies)hxtconstruct a navigatable treehxtremove navigationhxt#The interface for navigatable treeshxtmove one step towards the roothxt&descend one step to the leftmost childhxtmove to the left neighbourhxtmove to the right neighbourCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@ACchxtIcollect all trees by moving into one direction, starting tree is includedhxtMcollect all trees by moving into one direction, starting tree is not includedhxtXPath axis: parenthxtXPath axis: ancestorhxtXPath axis: ancestor or selfhxtXPath axis: childhxtXPath axis: descendanthxtXPath axis: descendant or selfhxtYnot an official XPath axis but useful: reverse descendant or self, used in preceding axishxtXPath axis: following siblinghxtXPath axis: preceeding siblinghxtXPath axis: selfhxtXPath axis: followinghxtXPath axis: precedinghxtmove to the rootCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de)stableportableSafe2=?@ACɬhxtUOne unzipped step consists of the left siblings, the node info and the right siblingshxt?The list of unzipped nodes from a current tree back to the roothxtZipper for rose treesQA zipper consist of the current tree and the branches on the way back to the roothxt6Conversion of a rose tree into a navigatable rose treehxtAConversion of a navigatable rose tree into an ordinary rose tree.The context, the parts for moving up to the root are just removed from the tree. So when transforming a navigatable tree by moving around and by changing some nodes, one has to navigate back to the root, else that parts are removed from the resultCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AChxt)The interface for navigatable tree arrows*all functions have default implementationshxtXPath axis: ancestorhxtXPath axis: ancestor or selfhxtXPath axis: childhxtXPath axis: descendanthxtXPath axis: descendant or selfhxt5not an XPath axis but useful: descendant or followinghxtYnot an official XPath axis but useful: reverse descendant or self, used in preceding axishxtXPath axis: following siblinghxtXPath axis: preceeding siblinghxtXPath axis: selfhxtXPath axis: followinghxtXPath axis: precedinghxtmove to the root hxt.Conversion from a tree into a navigatable tree hxt8Conversion from a navigatable tree into an ordinary tree hxt7apply an operation using navigation to an ordinary tree<This root and all children may be visited in arbitrary order hxtHapply a simple operation without use of navigation to a navigatable treeDThis enables to apply arbitrary tree operations to navigatable trees hxt.Filter an axis with an ordinary tree predicateZExample: In a tree of Ints find all nodes in the subtrees (in preorder) that have label 42 /descendantAxis >>> filterAxis (hasNode (== 42))YExample: In an XML Tree find the following nodes of a node with attribute id and value 42 LdescendantAxis >>> filterAxis (hasAttrValue "id" (=="42")) >>> followingAxishxt:Move to the next tree on a given axis. Deterministic arrowUExample: Move to the next node in a preorder visit: next child or else next following  moveOn descendantOrFollowingAxishxt1Change the current subtree of a navigatable tree.]The arrow for computing the changes should be deterministic. If it fails nothing is changed.hxtDSubstitute the current subtree of a navigatable tree by a given treehxtzapply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees in front of the current tree.cIf this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.hxtuapply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees behind the current tree.cIf this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.hxt$addToOneSide does the real work for  and hxt?drop the direct left sibling tree of the given navigatable treeiIf this arrow is applied to the root or a leftmost tree, it will fail, because there is nothing to removehxt?drop the direct left sibling tree of the given navigatable treejIf this arrow is applied to the root or a rightmost tree, it will fail, because there is nothing to remove!     !     Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AChxt list arrow combined with a statehxtAconversion of state list arrows into arbitray other list arrows.7allows running a state list arrow within another arrow:example: :... >>> fromSLA 0 (... setState ... getState ... ) >>> ...Uruns a state arrow with initial state 0 (e..g. an Int) within another arrow sequenceCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AC*'hxtpure list arrow data type*hxtLconversion of pure list arrows into other possibly more complex list arrows'()*'()*Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@ACS7hxtEdit parts of a rose treesThe subtrees to be modified are selected by the first part of the IfThen pairs The modification by the second part7878 Copyright (C) 2005-8 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@AC 9hxt1list arrow combined with a state and the IO monad<hxtIlift the state of an IOSLA arrow to a state with an additional component.~This is uesful, when running predefined IO arrows, e.g. for document input, in a context with a more complex state component.=hxtrun an arrow with augmented state in the context of a simple state arrow. An initial value for the new state component is needed.oThis is useful, when running an arrow with an extra environment component, e.g. for namespace handling in XML.9:;<=9:;<=Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@ACNhxt!list arrow combined with IO monadNOPNOPUCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportableSafe2=?@ACp !" #$%&'()*+,- . # !" &$%'()-6*+,./012345789:;>?<=@WXYZ[\     '()*789:;<=NOPSafe2=?@AC`hxtBthe table with the mapping from file name extensions to mime types``Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableSafe2=?@ACabcdefghijklmnopqrabcdefghijklmnopqrCopyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableSafe2=?@AC3shxtNremove leading and trailing whitespace with standard Haskell predicate isSpacethxtBconvert string to uppercase with standard Haskell toUpper functionuhxtBconvert string to lowercase with standard Haskell toLower functionvhxt>find all positions where a string occurs within another stringwhxt4find the position of the first occurence of a stringxhxt3find the position of the last occurence of a stringyhxt8Removes leading / trailing whitespaces and leading zeroszhxt2Reduce whitespace sequences to a single whitespace{hxt&replace all whitespace chars by blanks|hxt9Escape all disallowed characters in URI references (see  )http://www.w3.org/TR/xlink/#link-locators)}hxtbescape XML chars &lt;, &gt;, &quot;, and ampercent by transforming them into character references see also : ~hxtqescape XML chars &lt; and ampercent by transforming them into character references, used for escaping text nodes see also : hxtiescape XML chars in attribute values, same as stringEscapeXml, but none blank whitespace is also escaped see also : }hxt2convert a string of hexadecimal digits into an Inthxt&convert a string of digits into an InthxtCconvert a string into a hexadecimal string applying charToHexString see also : hxt7convert a char (byte) into a 2-digit hexadecimal string see also : , hxt5convert a none negative Int into a hexadecimal string see also : hxt|take all elements of a list which occur more than once. The result does not contain doubles. (doubles . doubles == doubles)hxt9drop all elements from a list which occur more than once.hxtremove duplicates from listhxt(mothers little helpers for to much currystuvwxyz{|}~sutvwxyz{|~}Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableSafe2=?@AC8hxtLthe predefined namespace uri for xml: "http://www.w3.org/XML/1998/namespace"hxtGthe predefined namespace uri for xmlns: "http://www.w3.org/2000/xmlns/"hxtRelax NG namespaceLLCopyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC}%hxt2Namespace support for element and attribute names.A qualified name consists of a name prefix, a local name and a namespace uri. All modules, which are not namespace aware, use only the R component. When dealing with namespaces, the document tree must be processed by )Ve to split names of structure "prefix:localPart" and label the name with the apropriate namespace urihxt\Type for the namespace association list, used when propagating namespaces by modifying the  values in a treehxtXML names are represented by Strings, but these strings do not mix up with normal strings. Names are always reduced to normal form, and they are stored internally in a name cache for sharing equal names by the same data structurehxtset name prefixhxtset local parthxtset name prefixhxtabuilds the full name "prefix:localPart", if prefix is not null, else the local part is the resulthxt6functional list version of qualifiedName used in xshowhxtbuilds the "universal" name, that is the namespace uri surrounded with "{" and "}" followed by the local part (specialisation of )hxtbuilds an "universal" uri, that is the namespace uri followed by the local part. This is usefull for RDF applications, where the subject, predicate and object often are concatenated from namespace uri and local part (specialisation of )hxtbuilds a string from the namespace uri and the local part. If the namespace uri is empty, the local part is returned, else namespace uri and local part are combined with the combining function given by the first parameterhxtPconstructs a simple name, with prefix and localPart but without a namespace uri. see also , hxt@constructs a simple, namespace unaware name. If the name is in prefix:localpart` form and the prefix is not empty the name is split internally into a prefix and a local part.hxt*constructs a complete qualified name with ,  and x. This function can be used to build not wellformed prefix:localpart names. The XPath module uses wildcard names like xxx:*. These must be build with  and not with mkName.hxt old name for hxtmconstructs a simple, namespace aware name, with prefix:localPart as first parameter, namspace uri as second. see also , hxtnEquivalent QNames are defined as follows: The URIs are normalized before comparison. Comparison is done with  and hxt.Comparison of normalized namespace URIs using hxt*Sometimes a weaker equality relation than  equalQName is appropriate, e.g no case significance in names, ... a name normalization function can be applied to the strings before comparing. Called by  equalQName and hxtlNormalization of URIs: Normalization is done by conversion into lowercase letters. A trailing "/" is ignoredhxtCCompute the name prefix and the namespace uri for a qualified name.This function does not test whether the name is a wellformed qualified name. see Namespaces in XML Rule [6] to [8]. Error checking is done with separate functions, see  and  for error checking.hxt3test for wellformed NCName, rule [4] XML NamespaceshxtPtest for wellformed QName, rule [6] XML Namespaces predicate is used in filter valdateNamespaces.hxttest for wellformed QName values. A QName is wellformed, if the local part is a NCName, the namePrefix, if not empty, is also a NCName. predicate is used in filter valdateNamespaces.hxttest whether an attribute name is a namesapce declaration name. If this is not the case True is the result, else the name must be a well formed namespace name: All namespace prefixes starting with "xml" are reserved for XML related definitions. predicate is used in filter valdateNamespaces.hxt+test for a namespace name to be well formedhxt=test whether a name is a namespace declaration attribute namehxtpredicate is used in filter valdateNamespaces./hxt0the internal cache for QNames (and name strings)hxtTwo QNames are equal if (1. case) namespaces are both empty and the qualified names (prefix:localpart) are the same or (2. case) namespaces are set and namespaces and local parts are equal..#Copyright (C) 2008-2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC&hxt=data type for representing a set of nodes as a tree structurethis structure is e.g. used to repesent the result of an XPath query such that the selected nodes can be processed or selected later in processing a document treehxtis this node part of the set ?hxtthe set of attribute nodeshxt=the set of child nodes, a list of pairs of index and node sethxtAttribute list7used for storing option lists and features of DTD partshxt4Binary large object implemented as a lazy bytestringhxtRepresents a DTD elementhxt9attr: name, system, public, XDTD elems as childrenhxtattr: name, kindname: element name4kind: "EMPTY" | "ANY" | "#PCDATA" | children | mixedhxtelement contentattr: kind, modifiermodifier: "" | "?" | "*" | "+"kind: seq | choicehxt$attributes: name - name of elementvalue - name of attributeCtype: "CDATA" | "ID" | "IDREF" | "IDREFS" | "ENTITY" | "ENTITIES" |/"NMTOKEN" | "NMTOKENS" |"NOTATION" | "ENUMTYPE"kind: "REQUIRED\" | \"IMPLIED" | "DEFAULT" hxtfor entity declarations!hxt!for parameter entity declarations"hxt for notations#hxt,for INCLUDEs, IGNOREs and peRefs: attr: typetype = INCLUDE, IGNORE or %...;$hxt attr: nameEfor lists of names in notation types or nmtokens in enumeration types%hxt'for Parameter Entity References in DTDs&hxtRepresents elements'hxt:ordinary text (leaf)(hxt:text represented more space efficient as bytestring (leaf))hxt:character reference (leaf)*hxt:entity reference (leaf)+hxt:comment (leaf),hxt:CDATA section (leaf)-hxtProcessing Instr with qualified name (leaf) with list of attributes. If tag name is xml, attributes are "version", "encoding", "standalone", else attribute list is empty, content is a text child node.hxtCtag with qualified name and list of attributes (inner node or leaf)/hxt4DTD element with assoc list for dtd element features0hxtHattribute with qualified name, the attribute value is stored in children1hxt!error message with level and text2hxt-List of navigatable rose trees with XML nodes3hxt$Navigatable rose tree with XML nodes4hxt!List of rose trees with XML nodes5hxt Rose tree with XML nodes (XNode)6hxt!Evaluate an assoc list of strings9hxtno error, everything is ok:hxt$Error level for XError, type warning;hxt"Error level for XError, type error<hxt(Error level for XError, type fatal error`]^_`abcd" !#$%&'()*+,-./0123456789:;<*" !#$%&'()*+,-./0123456789:;<WCopyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC0123456789:;<=>?@ABCDEF]^_`abcdabcdefghijklmnopqrstuvwxyz{|}~" !#$%&'()*+,-./0123456789:;<Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACĖhxtppredefined system state data type with all components for the system functions, like trace, error handling, ...hxt8The arrow for stateful arrows with no user defined statehxt"The arrow type for stateful arrowshxtWstate datatype consists of a system state and a user state the user state is not fixedhxt'read the user defined part of the statehxt)change the user defined part of the statehxt&set the user defined part of the statehxtextend user state Run an arrow with an extended user state component, The old component is stored together with a new one in a pair, the arrow is executed with this extended state, and the augmented state component is removed form the state when the arrow has finished its executionhxtchange the type of user stateThis conversion is useful, when running a state arrow with another structure of the user state, e.g. with () when executing some IO arrowshxt;store a string in global state under a given attribute namehxt>remove an entry in global state, arrow input remains unchangedhxt)read an attribute value from global statehxt%read all attributes from global statehxt"store an int value in global statehxt#read an int value from global state getSysAttrInt 0 myIntAttrstuvwz{LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     stuvwz{Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC"hxtJset the table mapping of file extensions to mime types in the system stateDefault table is defined in XY[. This table is used when reading loacl files, (file: protocol) to determine the mime type#hxtQset the table mapping of file extensions to mime types by an external config file/The config file must follow the conventions of etc8mime.types on a debian linux system, that means all empty lines and all lines starting with a # are ignored. The other lines must consist of a mime type followed by a possible empty list of extensions. The list of extenstions and mime types overwrites the default list in the system state of the IOStateArrow$hxtread the system mimetype table"#$"#$ Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACEkhxt(weak normalform versions of constructorsh%E)=&/:DUFC.'(*+,-0123456789;<>?@ABGHIJKLMNOPQRSTVWXYZ[\]^_`abcdefghijklmnopqrstuvwxT%E)=&/:DUFC.'(*+,-0123456789;<>?@ABGHIJKLMNOPQRSTVWXYZ[\]^_`abcdefghijklmnopqrstuvwx! Copyright (C) 2008-9 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC{hxt%convert a list of trees into a string see also : xmlTreesToText for filter version, 3Z for the inverse operation|hxt=convert an XML tree into a binary large object (a bytestring)}hxt$convert a list of trees into a blob.Apply a quoting function for XML quoting of content, a 2. quoting funtion for attribute values and an encoding function after tree conversion{|}~{|}~"Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxtDcheck whether a sequence of XmlTrees match an Xml regular expressionThe arrow for .BThe expession is build up from simple arrows acting as predicate (<) for an XmlTree and of the usual cobinators for sequence (), repetition ( , mkRep', ) and choice (, )hxt9split the sequence of trees computed by the filter a intoThe arrow for .a first part matching the regex and a rest, if a prefix of the input sequence does not match the regex, the arrow fails else the pair containing the result lists is returnedhxtscan the input sequence with a regex and give the result as a list of lists of trees back the regex must at least match one input tree, so the empty sequence should not match the regexThe arrow for .hxtBmatch a sequence of XML trees with a regular expression over treesSIf the input matches, the result is Nothing, else Just an error message is returnedhxtKsplit a sequence of XML trees into a pair of a a matching prefix and a rest3If there is no matching prefix, Nothing is returnedhxtMscan a sequence of XML trees and split it into parts matching the given regexxIf the parts cannot be split because of a missing match, or because of the empty sequence as match, Nothing is returned#Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACB$Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACxoghxtDocument Type Definition arrowsThese are separated, because they are not needed for document processing, only when processing the DTD, e.g. for generating access funtions for the toolbox from a DTD (se example DTDtoHaskell in the examples directory)hxtArrows for processing [sWThese arrows can be grouped into predicates, selectors, constructors, and transformers. All predicates (tests) act like \ for failure and ]- for success. A logical and can be formed by  a1 >>> a2 , a locical or by  a1 <+> a2 ._Selector arrows will fail, when applied to wrong input, e.g. selecting the text of a node with , will fail when applied to a none text node.zEdit arrows will remain the input unchanged, when applied to wrong argument, e.g. editing the content of a text node with C applied to an element node will return the unchanged element node.hxttest for text nodeshxt,test for char reference, used during parsinghxt.test for entity reference, used during parsinghxttest for commenthxt+test for CDATA section, used during parsinghxttest for processing instructionhxt*test for processing instruction <?xml ...>hxttest for elementhxt&test for DTD part, used during parsinghxttest for attribute treehxttest for error messagehxt*test for root node (element with name "/")hxt:test for text nodes with text, for which a predicate holds example: hasText (all (`elem` " \t\n"))2 check for text nodes with only whitespace contenthxt)test for text nodes with only white spaceimplemented with hasTesthxtOtest whether a node (element, attribute, pi) has a name with a special propertyhxtstest whether a node (element, attribute, pi) has a specific qualified name useful only after namespace propagationhxt{test whether a node has a specific name (prefix:localPart or localPart), generally useful, even without namespace handlinghxt_test whether a node has a specific name as local part, useful only after namespace propagationhxtXtest whether a node has a specific name prefix, useful only after namespace propagationhxtYtest whether a node has a specific namespace URI useful only after namespace propagationhxtGtest whether an element node has an attribute node with a specific namehxtQtest whether an element node has an attribute node with a specific qualified namehxtCtest whether an element node has an attribute with a specific valuehxtXtest whether an element node has an attribute with a qualified name and a specific valuehxttext node construction arrowhxtblob node construction arrowhxt=char reference construction arrow, useful for document outputhxt?entity reference construction arrow, useful for document outputhxt5comment node construction, useful for document outputhxt.CDATA construction, useful for document outputhxt/error node construction, useful only internallyhxttelement construction: | the attributes and the content of the element are computed by applying arrows to the inputhxtaattribute node construction: | the attribute value is computed by applying an arrow to the inputhxtprocessing instruction construction: | the content of the processing instruction is computed by applying an arrow to the inputhxtGconvenient arrow for element construction, more comfortable variant of example for simplifying  : 4mkElement qn (a1 <+> ... <+> ai) (c1 <+> ... <+> cj)equals "mkqelem qn [a1,...,ai] [c1,...,cj]hxtmconvenient arrow for element construction with strings instead of qualified names as element names, see also  and hxtaconvenient arrow for element construction with attributes but without content, simple variant of  and hxtWconvenient arrow for simple element construction without attributes, simple variant of  and hxtZconvenient arrow for construction of empty elements without attributes, simple variant of  and hxt@construction of an element node with name "/" for document rootshxt alias for hxt?convenient arrow for attribute construction, simple variant of hxtconstant arrow for text nodeshxtconstant arrow for blob nodeshxt'constant arrow for char reference nodeshxt)constant arrow for entity reference nodeshxtconstant arrow for commenthxtconstant arrow for warninghxtconstant arrow for errorshxtconstant arrow for fatal errorshxt7constant arrow for simple processing instructions, see hxthconstant arrow for attribute nodes, attribute name is a qualified name and value is a text, | see also , , hxt]constant arrow for attribute nodes, attribute name and value are | given by parameters, see hxtselect the text of a text nodehxt$select the value of a char referencehxt*select the name of a entity reference nodehxt$select the comment of a comment nodehxt"select the content of a CDATA nodehxt+select the name of a processing instructionhxt.select the content of a processing instructionhxt"select the name of an element nodehxt,select the attribute list of an element nodehxt!select the DTD type of a DTD nodehxt'select the DTD attributes of a DTD nodehxtselect the name of an attributehxtBselect the error level (c_warn, c_err, c_fatal) from an error nodehxt+select the error message from an error nodehxt:select the qualified name from an element, attribute or pihxtIselect the prefix:localPart or localPart from an element, attribute or pihxt7select the univeral name ({namespace URI} ++ localPart)hxt5select the univeral name (namespace URI ++ localPart)hxtselect the local parthxtselect the name prefixhxtselect the namespace URIhxtkselect the value of an attribute of an element node, always succeeds with empty string as default value ""hxtlike +, but fails if the attribute does not existhxtlike x, but select the value of an attribute given by a qualified name, always succeeds with empty string as default value ""hxtlike ', but fails if attribute does not existhxtedit the string of a text nodehxtedit the blob of a blob nodehxt)edit the comment string of a comment nodehxt(edit an element-, attribute- or pi- namehxtedit an element namehxtedit an attribute namehxtedit a pi namehxtedit an attribute valuehxt)edit an attribute list of an element nodehxt(replace an element, attribute or pi name hxtreplace an element name hxtreplace an attribute name hxtreplace an element name hxt+replace an atribute list of an element node hxt&add a list of attributes to an elementhxtadd (or replace) an attributehxtremove an attributehxt)remove an attribute with a qualified namehxt7process the attributes of an element node with an arrowhxtJprocess a whole tree inclusive attribute list of element nodes see also: hxt9convenient op for adding attributes or children to a nodeusage:  tf += cf the tf; arrow computes an element node, and all trees computed by cf are added to this node, if a tree is an attribute, it is inserted in the attribute list else it is appended to the content list.;attention: do not build long content list this way because  is implemented by ++ examples: Ueelem "a" += sattr "href" "page.html" += sattr "name" "here" += txt "look here"is the same as bmkelem [ sattr "href" "page.html" , sattr "name" "here" ] [ txt "look here" ]Nand results in the XML fragment: <a href="page.html" name="here">look here</a>advantage of the S operator is, that attributes and content can be added any time step by step. if tf computes a whole list of trees, e.g. a list of "td" or "tr" elements, the attributes or content is added to all trees. useful for adding "class" or "style" attributes to table elements.hxt\apply an arrow to the input and convert the resulting XML trees into a string representationhxt\apply an arrow to the input and convert the resulting XML trees into a string representationz     z     7%Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AChxtreset global error variable hxtset global error variable!hxt read current global error status"hxt=raise the global error status level to that of the input tree#hxtDset the error message handler and the flag for collecting the errors$hxt*error message handler for output to stderr%hxt9the default error message handler: error output to stderr&hxt+error message handler for collecting errors'hxt9error message handler for output to stderr and collecting(hxt)error message handler for ignoring errors)hxtif error messages are collected by the error handler for processing these messages by the calling application, this arrow reads the stored messages and clears the error message store+hxt7filter error messages from input trees and issue errors,hxtgenerate a warnig message-hxtgenerate an error message.hxt7generate a fatal error message, e.g. document not found/hxt@Default exception handler: issue a fatal error message and fail.<The parameter can be used to specify where the error occured0hxtadd the error level and the module where the error occured to the attributes of a document root node and remove the children when level is greater or equal to ; . called by 1) when the system state indicates an error1hxtcheck whether the error level attribute in the system state is set to error, in this case the children of the document root are removed and the module name where the error occured and the error level are added as attributes with 0 else nothing is changed2hxtUcheck whether tree is a document root and the status attribute has a value less than ; !"#$%&'()*+,-./0123 !"#$%&'()*+,-./0123&Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACu 4hxtwithTrace level- : system option, set the trace level, (0..4)5hxtwithSysAttr key value4 : store an arbitrary key value pair in system state6hxt'Specify the set of accepted mime types.[All contents of documents for which the mime type is not found in this list are discarded.7hxt<Specify a content handler for documents of a given mime type8hxtwithMimeTypeFile filename. : input option, set the mime type table for file:z documents by given file. The format of this config file must be in the syntax of a debian linux "mime.types" config file9hxt.Force a given mime type for all file contents.YThe mime type for file access will then not be computed by looking into a mime.types file:hxtwithWarnings yes/noZ : system option, issue warnings during reading, HTML parsing and processing, default is \;hxtwithErrors yes/no< : system option for suppressing error messages, default is ]<hxtwithRemoveWS yes/no[ : read and write option, remove all whitespace, used for document indentation, default is ]=hxtwithPreserveComment yes/noF : read option, preserve comments during canonicalization, default is ]>hxtwithParseByMimeType yes/noe : read option, select the parser by the mime type of the document (pulled out of the HTTP header).When the mime type is set to "text/html" the configured HTML parser is taken, when it's set to "text/xml" or "text/xhtml" the configured XML parser is taken. If the mime type is something else, no further processing is performed, the contents is given back to the application in form of a single text node. If the default document encoding is set to isoLatin1, this even enables processing of arbitray binary data.?hxtwithParseHTML yes/no+: read option, use HTML parser, default is ] (use XML parser)@hxtwithValidate yes/no9: read option, validate document against DTD, default is \AhxtwithSubstDTDEntities yes/noF: read option, substitute general entities defined in DTD, default is \. switching this option and the validate option off can lead to faster parsing, because then there is no need to access the DTDBhxtwithSubstHTMLEntities yes/noK: read option, substitute general entities defined in HTML DTD, default is ]. switching this option on and the substDTDEntities and validate options off can lead to faster parsing because there is no need to access a DTD, but still the HTML general entities are substitutedChxtwithCheckNamespaces yes/no,: read option, check namespaces, default is ]DhxtwithCanonicalize yes/no2 : read option, canonicalize document, default is \Ehxt withIgnoreNoneXmlContents yes/noE : input option, ignore document contents of none XML/HTML documents.This option can be useful for implementing crawler like applications, e.g. an URL checker. In those cases net traffic can be reduced.FhxtwithStrictInput yes/noM : input option, input of file and HTTP contents is read eagerly, default is ]GhxtwithEncodingErrors yes/no8 : input option, ignore all encoding errors, default is ]HhxtwithInputEncoding encodingName : input optionSet default document encoding (4, F, 6, D, ... , 7, ...). Only XML, HTML and text documents are decoded, default decoding for XML/HTML is utf8, for text iso latin1 (no decoding).IhxtwithDefaultBaseURI URI) , input option, set the default base URIThis option can be useful when parsing documents from stdin or contained in a string, and interpreting relative URIs within the documentLhxtwithRedirect yes/noB : input option, automatically follow redirected URIs, default is \MhxtwithProxy "host:port"G : input option, configure a proxy for HTTP access, e.g. www-cache:3128NhxtwithIndent yes/no< : output option, indent document before output, default is ]OhxtwithOutputEncoding encoding^ , output option, default is the default input encoding or utf8, if input encoding is not setPhxt withOutputXML! : output option, default writingDefault is writing XML: quote special XML chars >,<,",',& where neccessary, add XML processing instruction and encode document with respect to OQhxt`Write XHTML: quote all special XML chars, use HTML entity refs or char refs for none ASCII charsRhxtWrite XML: quote only special XML chars, don't substitute chars by HTML entities, and don't generate empty elements for HTML elements, which may contain any contents, e.g.  scriptsrc=... /script instead of  script src=... /Shxt+suppreses all char and entitiy substitutionZhxtConfigure compression and decompression for binary serialization/deserialization. First component is the compression function applied after serialization, second the decompression applied before deserialization.[hxt/Strict input for deserialization of binary data*456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]*456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]'Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC^hxt%commonly useful options for XML input5can be used for option definition with haskell getoptdefines options: , ,  a_use_curl, a_do_not_use_curl, a_options_curl, , {, k, , , z, l, , , q, e, i,_hxt&commonly useful options for XML outputdefines options: y, ,  and others`hxtcommonly useful optionsdefines options: , tahxtdefines  optionbhxtdebug output optionshxt<select options from a predefined list of option descriptions:^_`abcdefghijklmnopqrstuvwxyz{|}~:^_`abcdefghijklmnopqrstuvwxy{z|}~(Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC GhxtRead a serialied value from a file, optionally decompress it and decode the value In case of an error, the error message is issued and the arrow failshxtSerialize a value, optionally compress it, and write it to a file. In case of an error, the error message is issued and the arrow fails)#Copyright (C) 2005-2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC!DhxtDtest whether an attribute node contains an XML Namespace declarationhxtkget the namespace prefix and the namespace URI out of an attribute tree with a namespace declaration (see ') for all other nodes this arrow failshxt:collect all namespace declarations contained in a documentapply  to a whole XmlTreehxt8collect all (namePrefix, namespaceUri) pairs from a treeall qualified names are inspected, whether a namespace uri is defined, for these uris the prefix and uri is returned. This arrow is useful for namespace cleanup, e.g. for documents generated with XSLT. It can be used together with  to hxtgenerate unique namespaces and add all namespace declarations to all top nodes containing a namespace declaration Usually the top node containing namespace declarations is the root node, but this isn't mandatory.Calls  with hxtmgenerate unique namespaces and add all namespace declarations for all prefix-uri pairs in all qualified names@useful for cleanup of namespaces in generated documents. Calls  with 0 collectNamespaceDecl <+> collectPrefixUriPairs hxt)does the real work for namespace cleanup.TThe parameter is used for collecting namespace uris and prefixes from the input treeHhxt;auxiliary arrow for processing with a namespace environmentprocess a document tree with an arrow, containing always the valid namespace environment as extra parameter. The namespace environment is implemented as a ^D. Processing of attributes can be controlled by a boolean parameterhxtmprocess a document tree with an arrow, containing always the valid namespace environment as extra parameter..The namespace environment is implemented as a ^hxtprocess all element nodes of a document tree with an arrow, containing always the valid namespace environment as extra parameter. Attribute lists are not processed. See also: hxtOattach all valid namespace declarations to the attribute list of element nodes.This arrow is useful for document processing, that requires access to all namespace declarations at any element node, but which cannot be done with a simple .hxtepropagate all namespace declarations "xmlns:ns=..." to all element and attribute nodes of a document.SThis arrow does not check for illegal use of namespaces. The real work is done by I.2The arrow may be applied repeatedly if neccessary.Ihxthattaches the namespace info given by the namespace table to a tag node and its attributes and children.hxt3validate the namespace constraints in a whole tree.@Result is the list of errors concerning namespaces. Predicates , ,  and 8 are applied to the appropriate elements and attributes.Jhxt'a single node for namespace constrains.  *Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableSafe2=?@ACQhxt"Data type for regular expressions.hxt1Constructs a regular expression for an empty set.#1.parameter errMsg : error message-returns : regular expression for an empty sethxt6Constructs a regular expression for an empty sequence.2returns : regular expression for an empty sequencehxt6Constructs a regular expression for accepting a symbol,1.parameter sym : the symbol to be accepted3returns : regular expression for accepting a symbolhxt?Constructs a regular expression for accepting any singel symbol<returns : regular expression for accepting any singel symbolhxt=Constructs an optional repetition (*) of a regular expression41.parameter re_a : regular expression to be repeted returns : new regular expressionKhxtremove redundant nested *'s in RE theoretically this is unneccessary, but without this simplification the runtime can increase exponentally when computing deltas, e.g. for a** or (a|b*)* which is the same as (a|b)*hxt3Constructs a repetition (+) of a regular expression41.parameter re_a : regular expression to be repeted returns : new regular expressionhxt0Constructs an option (?) of a regular expression51.parameter re_a : regular expression to be optional returns : new regular expressionhxt4Constructs a sequence (,) of two regular expressions81.parameter re_a : first regular expression in sequence92.parameter re_b : second regular expression in sequence returns : new regular expressionhxt8Constructs an alternative (|) of two regular expressions;1.parameter re_a : first regular expression of alternative<2.parameter re_b : second regular expression of alternative returns : new regular expressionhxt:Checks if a regular expression matches the empty sequence.nullable e == [] `in` L(e)GThis check indicates if a regular expression fits to a sentence or not.21.parameter re : regular expression to be checked`returns : true if regular expression matches the empty sequence, otherwise falseLhxt8Derives a regular expression with respect to one symbol.L(delta e x) = x L(e)21.parameter re : regular expression to be derivedH2.parameter sym : the symbol on which the regular expression is applied(returns : the derived regular expressionhxt8Derives a regular expression with respect to a sentence.$1.parameter re : regular expressionD2.parameter s : sentence to which the regular expression is applied(returns : the derived regular expressionhxt^Checks if an input matched a regular expression. The function should be called after matches.Was the sentence used in matchesA in the language of the regular expression? -> matches e s == s `in` L(e)?01.parameter re : the derived regular expressionureturns : empty String if input matched the regular expression, otherwise an error message is returnedhxt;Constructs a string representation of a regular expression.&1.parameter re : a regular expression=returns : the string representation of the regular expression+Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACVhxt7infix operator for applying an arrow to a list of trees1.parameter f : the arrow#2.parameter ts : the list of treesreturns : list of resultshxtcreate an error message !" #$%&'()*+,- .0123456789:;<=>?@ABCDEF # !" &$%'()-6*+,./012345789:;>?<=@]^_`abcd'()*abcdefghijklmnopqrstuvwxyz{|}~" !#$%&'()*+,-./0123456789:;<     !0,Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableSafe2=?@ACbMhxticheck whether file exists, if not try to unescape filename and check again return the existing filename-Safe2=?@ACf%hxtZTry to extract charset spec from Content-Type header e.g. "text/html; charset=ISO-8859-1"JSometimes the server deliver the charset spec in quotes these are removed.Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableSafe2=?@ACn hxt parse a single Unicode characterhxtparse a XML name characterhxt parse a XML name start characterhxtparse a XML NCName characterhxt"parse a XML NCName start characterhxtparse a XML letter characterhxtWhite Space (2.3)8end of line handling (2.11) will be done before or with  parserhxtWhite Space NormalizationAend of line handling (2.11) #x0D and #x0D#x0A are mapped to #x0A/Safe2=?@ACohxt<list of predefined XML entity names and their unicode values0Safe2=?@ACqhxtAtable with all XHTML entity refs and corresponding unicode values1Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACs89      !"#$%&'()*+,-.9      !"#$%&'(*+,-).2Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACv/0123456/01234563Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC Khxtthe inverse function to {, (for XML content).=the string parameter is parsed with the XML content parser. result is the list of trees or in case of an error a single element list with the error message as node. No entity or character subtitution is done here, but the XML parser can do this for the predefined XML or the char references for performance reasons see also: MMhxtthe filter version of KNhxta more general version of M<. The parser to be used and the context are extra parameterQhxt;general parser for parsing arbitray parts of a XML documentRhxtParser for parts of a DTDShxtParser for general entitesThxt6Parser for entity substitution within attribute valuesUhxtParser for NMTOKENsVhxtParser for XML namesWhxt!try to parse a xml encoding spec.81.parameter encParse : the parser for the encoding decl#2.parameter root : a document rootreturns : the same tree, but with an additional attribute "encoding" in the root node in case of a valid encoding spec else the unchanged tree#789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY#789:;<=>?@ABCDEFGHIJKLMYORWXTSQNUVP4Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC3ZhxtHChecks if the attribute value meets the lexical constraints of its type.+1.parameter dtdPart : the children of the DOCTYPE nodeE2.parameter attrDecl : the declaration of the attribute from the DTDreturns : a function which takes an element (XTag or XDTD ATTLIST), checks if the attribute value meets the lexical constraints of its type and returns a list of errorsNhxt4Dispatches the attibute check by the attribute type.%1.parameter typ : the attribute type+2.parameter dtdPart : the children of the DOCTYPE nodeE3.parameter attrValue : the normalized attribute value to be checkedE4.parameter attrDecl : the declaration of the attribute from the DTDreturns : a functions which takes an element (XTag or XDTD ATTLIST), checks if the attribute value meets the lexical constraints of its type and returns a list of errorsOhxtGChecks the value of Enumeration attribute types. (3.3.1 / p.27 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedPhxtBChecks the value of ENTITY attribute types. (3.3.1 / p.26 in Spec)+1.parameter dtdPart : the children of the DOCTYPEB node, to get the unparsed entity declarationsE2.parameter attrDecl : the declaration of the attribute from the DTDE3.parameter attrValue : the normalized attribute value to be checkedQhxtDChecks the value of ENTITIES attribute types. (3.3.1 / p.26 in Spec)+1.parameter dtdPart : the children of the DOCTYPEB node, to get the unparsed entity declarationsE2.parameter attrDecl : the declaration of the attribute from the DTDE3.parameter attrValue : the normalized attribute value to be checkedRhxtCChecks the value of NMTOKEN attribute types. (3.3.1 / p.26 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedShxtDChecks the value of NMTOKENS attribute types. (3.3.1 / p.26 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedThxt>Checks the value of ID attribute types. (3.3.1 / p.25 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedUhxtAChecks the value of IDREF attribute types. (3.3.1 / p.26 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedVhxtBChecks the value of IDREFS attribute types. (3.3.1 / p.26 in Spec)E1.parameter attrDecl : the declaration of the attribute from the DTDE2.parameter attrValue : the normalized attribute value to be checkedWhxt.Checks if the value of an attribute is a name.,1.parameter msg : error message, should be Entity or "Attribute value"E2.parameter attrDecl : the declaration of the attribute from the DTDE3.parameter attrValue : the normalized attribute value to be checked[hxtNNormalizes an attribute value with respect to its type. (3.3.3 / p.29 in Spec)1.parameter attrDecl : the declaration of the attribute from the DTD. Expected is a list. If the list is empty, no declaration exists.92.parameter value : the attribute value to be normalizedreturns : the normalized valueXhxtvNormalization of CDATA attribute values. is already done when parsing during entity substituion for attribute valuesYhxt3Normalization of attribute values other than CDATA.Zhxt3Reduce whitespace sequences to a single whitespace.Z[Z[5Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC7[hxtnLookup-table which maps element names to their validation functions. The validation functions are XmlFilters.\hxt Perform the validation of the IDIDREFIDREFS constraints.,1.parameter dtdPart : the DTD subset (Node DOCTYPE) of the XmlTree52.parameter doc : the document subset of the XmlTreereturns : a list of errors\hxt!Traverse the XmlTree in preorder.X1.parameter idEnv : lookup-table which maps element names to their validation functionsreturns : list of errors]hxtkReturns the value of an element's ID attribute. The attribute name has to be retrieved first from the DTD.D1.parameter dtdPart : list of ID attribute definitions from the DTDD2.parameter n : element which ID attribute value should be returned.returns : normalized value of the ID attribute^hxtVBuild collector functions which return XTag nodes with ID attributes from a document.+1.parameter dtdPart : the children of the DOCTYPE nodeKreturns : lookup-table which maps element names to their collector function_hxtdBuild validation functions for checking if IDREF/IDREFS values match a value of some ID attributes.+1.parameter dtdPart : the children of the DOCTYPE nodeC2.parameter idNodeList : list of all XTag nodes with ID attributesLreturns : lookup-table which maps element names to their validation function`hxtiValidate that all ID values are unique within a document. Validity constraint: ID (3.3.1 /p. 25 in Spec)C1.parameter idNodeList : list of all XTag nodes with ID attributes+2.parameter dtdPart : the children of the DOCTYPE nodereturns : a list of errorsahxt~Validate that all IDREF/IDREFS values match the value of some ID attribute. Validity constraint: IDREF (3.3.1 / p.26 in Spec)Z1.parameter idRefEnv : lookup-table which maps element names to their validation function+2.parameter doc : the document to validatereturns : a list of errors\\6Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACbhxtuLookup-table which maps element names to their transformation functions. The transformation functions are XmlArrows.]hxt%filter for transforming the document.,1.parameter dtdPart : the DTD subset (Node DOCTYPE) of the XmlTree52.parameter doc : the document subset of the XmlTreereturns : a list of errorschxt!Traverse the XmlTree in preorder._1.parameter transEnv : lookup-table which maps element names to their transformation functions(returns : the whole transformed documentdhxt#Build all transformation functions.C1.parameter dtdPart : the DTD subset, root node should be of type DOCTYPEQreturns : lookup-table which maps element names to their transformation functionsehxt.Build transformation functions for an element.+1.parameter dtdPart : the children of the DOCTYPE nodel1.parameter nd : element declaration for which the transformation functions are created$returns : entry for the lookup-tablefhxt9Sort the attributes of an element in lexicographic order.returns : a function which takes an element (XTag), sorts its attributes in lexicographic order and returns the changed elementghxtNormalize attribute values.returns : a function which takes an element (XTag), normalizes its attribute values and returns the changed elementhhxt1Set default attribute values if they are not set.returns : a function which takes an element (XTag), adds missing attribute defaults and returns the changed element]]7Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=>?@AC3^hxtValidate a DTD.returns : a functions which takes the DTD subset of the XmlTree, checks if the DTD is valid and returns a list of errorsihxtValidation of Notations, checks if all notation names are unique. Validity constraint: Unique Notation Name (4.7 / p.44 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodereturns : a list of errorsjhxtValidation of Entities. 9Issues a warning if entities are declared multiple times.&Optional warning: (4.2 / p.35 in Spec) =Validates that a notation is declared for an unparsed entity.=Validity constraint: Notation Declared (4.2.2 / p.36 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeK2.parameter notationNames : list of all notation names declared in the DTDreturns : a list of errorskhxt#Validation of Element declarations. 9Validates that an element is not declared multiple times.IValidity constraint: Unique Element Type Declaration (3.2 / p.21 in Spec) PValidates that an element name only appears once in a mixed-content declaration.<Validity constraint: No Duplicate Types (3.2 / p.21 in Spec) [Issues a warning if an element mentioned in a content model is not declared in the DTD.&Optional warning: (3.2 / p.21 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeF2.parameter elemNames : list of all element names declared in the DTDreturns : a list of errorslhxt%Validation of Attribute declarations. XIssues a warning if an attribute is declared for an element type not itself decared.&Optinal warning: (3.3 / p. 24 in Spec) Issues a warning if more than one definition is provided for the same attribute of a given element type. Fist declaration is binding, later definitions are ignored.&Optional warning: (3.3 / p.24 in Spec) wIssues a warning if the same Nmtoken occures more than once in enumerated attribute types of a single element type.(Optional warning: (3.3.1 / p.27 in Spec) JValidates that an element type has not more than one ID attribute defined.CValidity constraint: One ID per Element Type (3.3.1 / p.26 in Spec) PValidates that an element type has not more than one NOTATION attribute defined.IValidity constraint: One Notation per Element Type (3.3.1 / p.27 in Spec) -Validates that an ID attributes has the type  IMPLIED or  REQUIRED.@Validity constraint: ID Attribute Default (3.3.1 / p.26 in Spec) 5Validates that all referenced notations are declared.?Validity constraint: Notation Attributes (3.3.1 / p.27 in Spec) =Validates that notations are not declared for EMPTY elements.GValidity constraint: No Notation on Empty Element (3.3.1 /p.27 in Spec) NValidates that the default value matches the lexical constraints of it's type.CValidity constraint: Attribute default legal (3.3.2 / p.28 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeF2.parameter elemNames : list of all element names declared in the DTDK3.parameter notationNames : list of all notation names declared in the DTDreturns : a list of errors_hxtRemoves doublicate declarations from the DTD, which first declaration is binding. This is the case for ATTLIST and ENTITY declarations.returns : A function that replaces the children of DOCTYPE nodes by a list where all multiple declarations are removed.^__^8Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC@`fhxtparse a tokenized DTD declaration represented by a DTD tree. The content is represented by the children containing text and parameter entity reference nodes. The parameter entity reference nodes contain their value in the children list, consisting of text and possibly again parameter entity reference nodes. This structure is build by the parameter entity substitution. Output is again a DTD declaration node, but this time completely parsed and ready for further DTD processingmhxtcollect the tokens of a DTD declaration body and build a string ready for parsing. The structure of the parameter entity values is stll stored in this string for checking the scope of the parameter values`abcdeffed`abc9Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACB;ghijklmghijlmk:Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACDnopqrstuvwxyz{|nopqrstuvwxyz{|;Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACnhxtKescape XmlText, transform all special XML chars into char- or entity- refsohxt6Applies some "Canonical XML" rules to a document tree.MThe rules differ slightly for canonical XML and XPath in handling of commentsNote: This is not the whole canonicalization as it is specified by the W3C Recommendation. Adding attribute defaults or sorting attributes in lexicographic order is done by the  transform function of module !Text.XML.HXT.Validator.ValidationG. Replacing entities or line feed normalization is done by the parser.Not implemented yet:2Whitespace within start and end tags is normalizedaSpecial characters in attribute values and character content are replaced by character referencessee } and ~}hxt6Applies some "Canonical XML" rules to a document tree.LThe rule differ slightly for canonical XML and XPath in handling of commentsNote: This is not the whole canonicalization as it is specified by the W3C Recommendation. Adding attribute defaults or sorting attributes in lexicographic order is done by the  transform function of module !Text.XML.HXT.Validator.ValidationG. Replacing entities or line feed normalization is done by the parser.qRules: remove DTD parts, processing instructions, comments and substitute char refs in attribute values and textNot implemented yet:2Whitespace within start and end tags is normalizedaSpecial characters in attribute values and character content are replaced by character references~hxt$Canonicalize a tree for XPath Like }" but comment nodes are not removedsee }hxt'Canonicalize the contents of a documentsubstitutes all char refs in text and attribute values, removes CDATA section and combines all sequences of resulting text nodes into a single text nodesee }hxtCollects sequences of text nodes in the list of children of a node into one single text node. This is useful, e.g. after char and entity reference substitutionhxt"Applies collapseXText recursively. see also : hxtZapply an arrow to the input and convert the resulting XML trees into an XML escaped stringfThis is a save variant for converting a tree into an XML string representation that is parsable with P_. It is implemented with B, but xshow does no XML escaping. The XML escaping is done with ;` before xshow is applied.So the following law holds xshowEscapeXml f >>> xread == fhxt=convert a document into a Haskell representation (with show).3Useful for debugging and trace output. see also : , hxtOconvert a document into a text and add line numbers to the text representation.lResult is a root node with a single text node as child. Useful for debugging and trace output. see also : , hxt;convert a document into a text representation in tree form.3Useful for debugging and trace output. see also : , hxtremove a Comment nodehxt)remove all comments in a tree recursivelyhxt&simple filter for removing whitespace.Hno check on sigificant whitespace, e.g. in HTML <pre>-elements, is done. see also : , hxt4simple recursive filter for removing all whitespace.Aremoves all text nodes in a tree that consist only of whitespace. see also : , hxt3filter for removing all not significant whitespace.the tree traversed for removing whitespace between elements, that was inserted for indentation and readability. whitespace is only removed at places, where it's not significat preserving whitespace may be controlled in a document tree by a tag attribute  xml:space&allowed values for this attribute are default | preservehinput is root node of the document to be cleaned up, output the semantically equivalent simplified tree see also : , hxt9filter for indenting a document tree for pretty printing.Cthe tree is traversed for inserting whitespace for tag indentation.whitespace is only inserted or changed at places, where it isn't significant, is's not inserted between tags and text containing non whitespace chars.whitespace is only inserted or changed at places, where it's not significant. preserving whitespace may be controlled in a document tree by a tag attribute  xml:space&allowed values for this attribute are default | preserve.oinput is a complete document tree or a document fragment result is the semantically equivalent formatted tree. see also : hxt/converts a CDATA section into normal text nodeshxtEconverts CDATA sections in whole document tree into normal text nodeshxt-converts a character reference to normal texthxt<recursively converts all character references to normal texthxtNadd an <?xml version="1.0"?> processing instruction if it's not already therehxtHadd an encoding spec to the <?xml version="1.0"?> processing instructionhxt5add an XHTML strict doctype declaration to a document5add an XHTML strict doctype declaration to a documenthxt;add an XHTML transitional doctype declaration to a document5add an XHTML strict doctype declaration to a documenthxt7add an XHTML frameset doctype declaration to a document5add an XHTML strict doctype declaration to a documenthxt'add a doctype declaration to a documentHThe arguments are the root element name, the PUBLIC id and the SYSTEM id"}~"}~<Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxt@Derives a regular expression with respect to a list of elements.$1.parameter re : regular expressionO2.parameter list : list of elements to which the regular expression is applied(returns : the derived regular expressionphxt9Derives a regular expression with respect to one element.L(delta e x) = x L(e)21.parameter re : regular expression to be derivedH2.parameter el : the element on which the regular expression is applied(returns : the derived regular expression  =Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACqhxtmLookup-table which maps element names to their validation functions. The validation functions are XmlArrows.hxtValidate a document.,1.parameter dtdPart : the DTD subset (Node DOCTYPE) of the XmlTree52.parameter doc : the document subset of the XmlTreereturns : a list of errorsrhxt!Traverse the XmlTree in preorder.Z1.parameter valiEnv : lookup-table which maps element names to their validation functionsreturns : list of errorsshxtBuild all validation functions.?1.parameter dtdPart : DTD subset, root node should be of type DOCTYPEMreturns : lookup-table which maps element names to their validation functionsthxt@Build a validation function for the document root. By root node /= is meant, which is the topmost dummy created by the parser.?1.parameter dtdPart : DTD subset, root node should be of type DOCTYPE$returns : entry for the lookup-tableuhxt*Build validation functions for an element.+1.parameter dtdPart : the children of the DOCTYPE nodeg2.parameter nd : element declaration for which the validation functions are created$returns : entry for the lookup-tablevhxtvBuild validation functions for the content model of an element. Validity constraint: Element Valid (3 / p.18 in Spec)l1.parameter nd : element declaration for which the content validation functions are builtreturns : a function which takes an element (XTag), checks if its children match its content model and returns a list of errorswhxtkBuild a regular expression from the content model. The regular expression is provided by the module XmlRE.71.parameter nd : node of the content model. Expected: CONTENT or NAME1returns : regular expression of the content modelxhxt<Build validation functions for the attributes of an element.+1.parameter dtdPart : the children of the DOCTYPE nodep2.parameter nd : element declaration for which the attribute validation functions are createdreturns : a function which takes an element (XTag), checks if its attributes are valid and returns a list of errorsyhxtvValidate that all attributes of an element are unique. Well-formdness constraint: Unique AttSpec (3.1 / p.19 in Spec)returns : a function which takes an element (XTag), checks if its attributes are unique and returns a list of errorszhxtuValidate that all #REQUIRED attributes are provided. Validity constraint: Required Attributes (3.3.2 / p.28 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeI2.parameter nd : element declaration which attributes have to be checkedreturns : a function which takes an element (XTag), checks if all required attributes are provided and returns a list of errors{hxt}Validate that #FIXED attributes match the default value. Validity constraint: Fixed Attribute Default (3.3.2 / p.28 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeI2.parameter nd : element declaration which attributes have to be checkedreturns : a function which takes an element (XTag), checks if all fixed attributes match the default value and returns a list of errors|hxtValidate that an element has no attributes which are not declared. Validity constraint: Attribute Value Type (3.1 / p.19 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeI2.parameter nd : element declaration which attributes have to be checkedreturns : a function which takes an element (XTag), checks if all attributes are declared and returns a list of errors}hxtValidate that the attribute value meets the lexical constraints of its type. Validity constaint: Attribute Value Type (3.1 / p.19 in Spec)+1.parameter dtdPart : the children of the DOCTYPE nodeI2.parameter nd : element declaration which attributes have to be checkedreturns : a function which takes an element (XTag), checks if all attributes meet the lexical constraints and returns a list of errors>Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxtDMain validation filter. Check if the DTD and the document are valid.returns : a function which expects a complete document as XmlTree input and returns a list of all errors found.hxtCheck if the DTD is valid.returns : a function which expects an XmlTree from the parser as input and returns a list of all errors found in the DTD.hxt3Check if the document corresponds to the given DTD.returns : a function which expects a complete document as XmlTree input and returns a list of all errors found in the content part.hxtAfilter for transforming a document with respect to the given DTD.Validating parsers are expected to normalize attribute values and add default values. This function should be called after a successful validation.sreturns : a function which expects a complete XML document tree and returns the transformed XmlTreehxtRemoves doublicate declarations from the DTD which first declaration is binding. This is the case for ATTLIST and ENTITY declarations.returns : A function that replaces the children of DOCTYPE nodes by a list where all multiple declarations are removed.?Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC hxtset the global trace levelhxtread the global trace levelhxt@set the global trace command. This command does the trace outputhxt"acces the command for trace outputhxt`run an arrow with a given trace level, the old trace level is restored after the arrow executionhxt/apply a trace arrow and issue message to stderrhxt;trace the current value transfered in a sequence of arrows.~The value is formated by a string conversion function. This is a substitute for the old and less general traceString functionhxtan old alias for hxtissue a string message as tracehxtAissue the source representation of a document if trace level >= 3<for better readability the source is formated with indentDochxt?issue the tree representation of a document if trace level >= 4hxttrace a main computation step issue a message when trace level >= 1, issue document source if level >= 3, issue tree when level is >= 4  @Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC& hxtzset the base URI of a document, used e.g. for reading includes, e.g. external entities, the input must be an absolute URIhxt(read the base URI from the globale statehxtchange the base URI with a possibly relative URI, can be used for evaluating the xml:base attribute. Returns the new absolute base URI. Fails, if input is not parsable with parseURIReference see also: , hxtAset the default base URI, if parameter is null, the system base ( file:///<cwd>/ J) is used, else the parameter, must be called before any document is readhxtget the default base URIhxt`remember base uri, run an arrow and restore the base URI, used with external entity substitutionhxtparse a URI reference, in case of a failure, try to escape unescaped chars, convert backslashes to slashes for windows paths, and try parsing againhxt6compute the absolut URI for a given URI and a base URIhxtarrow variant of  , fails if  returns Nothinghxtnarrow for expanding an input URI into an absolute URI using global base URI, fails if input is not a legal URIhxtXarrow for selecting the scheme (protocol) of the URI, fails if input is not a legal URI."See Network.URI for URI componentshxt\arrow for selecting the registered name (host) of the URI, fails if input is not a legal URIhxtearrow for selecting the port number of the URI without leading ':', fails if input is not a legal URIhxtdarrow for selecting the user info of the URI without trailing '@', fails if input is not a legal URIhxtSarrow for computing the path component of an URI, fails if input is not a legal URIhxtTarrow for computing the query component of an URI, fails if input is not a legal URIhxtWarrow for computing the fragment component of an URI, fails if input is not a legal URIhxtSarrow for computing the path component of an URI, fails if input is not a legal URIACopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC/hxt apply an  to an empty root node with  () as initial state6the main entry point for running a state arrow with IO when running  runX f& an empty XML root node is applied to f . usually f? will start with a constant arrow (ignoring the input), e.g. a Ha arrow.for usage see examples with Eb+if input has to be feed into the arrow use ; like in  runIOSLA f emptyX inputDoc hxt@the default global state, used as initial state when running an  with ; or cCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC1qLM"#$ !"#%&'()+,-./012456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]qML !"#%&'()+,-./012$"#\]6V5DZCI[G;9ENHJK87UTOPQRS>?=ML<YXFABW4@:BCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACEhxtRead the content of a document.$This routine is usually called from Gd.0The input must be a root node (constructed with ), usually without children. The attribute list contains all input parameters, e.g. URI or source file name, encoding preferences, ... If the source name is empty, the input is read from standard input.The source is transformed into an absolute URI. If the source is a relative URI, or a file name, it is expanded into an absolute URI with respect to the current base URI. The default base URI is of protocol "file" and points to the current working directory.KThe currently supported protocols are "http", "file", "stdin" and "string".zThe latter two are internal protocols. An uri of the form "stdin:" stands for the content of the standard input stream.x"string:some text" means, that "some text" is taken as input. This internal protocol is used for reading from normal ~ values.CCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACIhxt substitution of general entities3input: a complete document tree including root nodeD Copyright (C) 2005-9 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACOhxtMWrite the contents of a document tree into an output stream (file or stdout).{If textMode is set, writing is done with Haskell string output, else (default) writing is done with lazy ByteString outputhxt5write the tree representation of a document to a filehxt0write a document with indentaion and line numersE Copyright (C) 2005-9 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxt%the main filter for writing documents5this filter can be configured by an option list like Hausage: & writeDocument optionList destination if  destination < is the empty string or "-", stdout is used as output devicefor available options see ce withOutputXML : (default) issue XML: quote special XML chars >,<,",',& where neccessary add XML processing instruction and encode document with respect to output encoding,withOutputHTML : issue HTML: translate all special XML chars and all HTML chars with a corresponding entity reference into entity references. Do not generate empty elements, e.g.  script.../a for HTML elements, that are allowed to contain a none empty body. Result is for the example is  script... /script9. The short form introduces trouble in various browsers.withOutputXHTML : same as withOutputHTML>, but all none ASCII chars are substituted by char references.withOutputPLAINw : Do not substitute any chars. This is useful when generating something else than XML/HTML, e.g. Haskell source code.withXmlPi yes/no : Add a  ?xmlversion=... encoding=... ?J processing instruction to the beginning of the document. Default is yes.withAddDefaultDTD : if the document to be written was build by reading another document containing a Document Type Declaration, this DTD is inserted into the output document (default: no insert)withShowTree yes/no= : show DOM tree representation of document (for debugging)withShowHaskell yes/no; : show Haskell representaion of document (for debugging)Ka minimal main program for copying a document has the following structure: module Main where import Text.XML.HXT.Core main :: IO () main = do runX ( readDocument [] "hello.xml" >>> writeDocument [] "bye.xml" ) return ()an example for copying a document from the web to standard output with global trace level 1, input trace level 2, output encoding isoLatin1, and evaluation of error code is: ,module Main where import Text.XML.HXT.Core import Text.XML.HXT.Curl -- or -- import Text.XML.HXT.HTTP import System.Exit main :: IO () main = do [rc] <- runX ( configSysVars [ withTrace 1 -- set the defaults for all read-, , withCurl [] -- write- and other operations -- or withHTTP [] ] >>> readDocument [ withTrace 2 -- use these additional , withParseHTML yes -- options only for this read ] "http://www.haskell.org/" >>> writeDocument [ withOutputEncoding isoLatin1 ] "" -- output to stdout >>> getErrStatus ) exitWith ( if rc >= c_err then ExitFailure 1 else ExitSuccess )hxtbConvert a document into a string. Formating is done the same way and with the same options as in . Default output encoding is no encoding, that means the result is a normal unicode encode haskell string. The default may be overwritten with the &f. option. The XML PI can be suppressed by the gh option.This arrow fails, when the encoding scheme is not supported. The arrow is pure, it does not run in the IO monad. The XML PI is suppressed, if not explicitly turned on with an option  (a_no_xml_pi, v_0) hxtindent and format outputFCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxta filter for DTD processingbinclusion of external parts of DTD, parameter entity substitution conditional section evaluationAinput tree must represent a complete document including root nodeGCopyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC,hxt XML parserInput tree must be a root tree with a text tree as child containing the document to be parsed. The parser generates from the input string a tree of a wellformed XML document, processes the DTD (parameter substitution, conditional DTD parts, ...) and substitutes all general entity references. Next step is character reference substitution. Last step is the document validation. Validation can be controlled by an extra parameter.Example: xparseXmlDocument True -- parse and validate document parseXmlDocument False -- only parse document, don't validateHThis parser is useful for applications processing correct XML documents.hxt HTML parserInput tree must be a root tree with a text tree as child containing the document to be parsed. The parser tries to parse everything as HTML, if the HTML document is not wellformed XML or if errors occur, warnings are generated. The warnings can be issued, or suppressed. Example:  parseHtmlDocument True $ : parse document and issue warningsThis parser is useful for applications like web crawlers, where the pages may contain arbitray errors, but the application is only interested in parts of the document, e.g. the plain text.hxtDocument validationInput must be a complete document tree. The document is validated with respect to the DTD spec. Only useful for XML documents containing a DTD.If the document is valid, it is transformed with respect to the DTD, normalization of attribute values, adding default values, sorting attributes by name,...If no error was found, result is the normalized tree, else the error status is set in the list of attributes of the root node "/" and the document content is removed from the tree.hxtNamespace propagationInput must be a complete document tree. The namespace declarations are evaluated and all element and attribute names are processed by splitting the name into prefix, local part and namespace URI.?Naames are checked with respect to the XML namespace definitionIf no error was found, result is the unchanged input tree, else the error status is set in the list of attributes of the root node "/" and the document content is removed from the tree.hxt^creates a new document root, adds all options as attributes to the document root and calls .[If the document name is the empty string, the document will be read from standard input.For supported protocols see H#Copyright (C) 2005-2013 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AChxtthe main document input filterRthis filter can be configured by a list of configuration options, a value of type ij%for all available options see module ce withValidate yes/noW : switch on/off DTD validation. Only for XML parsed documents, not for HTML parsing.withSubstDTDEntities yes/nod : switch on/off entity substitution for general entities defined in DTD validation. Default is yes. Switching this option and the validation off can lead to faster parsing, in that case reading the DTD documents is not longer necessary. Only used with XML parsed documents, not with HTML parsing.withSubstHTMLEntities yes/noe : switch on/off entity substitution for general entities defined in HTML validation. Default is no. Switching this option on and the validation and substDTDEntities off can lead to faster parsing, in that case reading the DTD documents is not longer necessary, HTML general entities are still substituted. Only used with XML parsed documents, not with HTML parsing.withParseHTML yes/no : switch on HTML parsing.withParseByMimeType yes/nor : select XML/HTML parser by document mime type. text/xml and text/xhtml are parsed as XML, text/html as HTML.withCheckNamespaces yes/no5 : Switch on/off namespace propagation and checking!withInputEncoding <encoding-spec> : Set default encoding. withTagSoup : use light weight and lazy parser based on tagsoup lib. This is only available when package hxt-tagsoup is installed and the source contains an import Text.XML.HXT.TagSoup.withRelaxNG <schema.rng> : validate document with Relax NG, the parameter is for the schema URI. This implies using XML parser, no validation against DTD, and canonicalisation.withCurl [<curl-option>...] : Use the libCurl binding for HTTP access. This is only available when package hxt-curl is installed and the source contains an import Text.XML.HXT.Curl.withHTTP [<http-option>...] : Use the Haskell HTTP package for HTTP access. This is only available when package hxt-http is installed and the source contains an import Text.XML.HXT.HTTP. examples: readDocument [] "test.xml"greads and validates a document "test.xml", no namespace propagation, only canonicalization is performed ... import Text.XML.HXT.Curl ... readDocument [ withValidate no , withInputEncoding isoLatin1 , withParseByMimeType yes , withCurl [] ] "http://localhost/test.php"reads document "test.php", parses it as HTML or XML depending on the mimetype given from the server, but without validation, default encoding F". HTTP access is done via libCurl. ereadDocument [ withParseHTML yes , withInputEncoding isoLatin1 ] ""hreads a HTML document from standard input, no validation is done when parsing HTML, default encoding is F, readDocument [ withInputEncoding isoLatin1 , withValidate no , withMimeTypeFile "/etc/mime.types" , withStrictInput yes ] "test.svg"}reads an SVG document from "test.svg", sets the mime type by looking in the system mimetype config file, default encoding is F, $... import Text.XML.HXT.Curl import Text.XML.HXT.TagSoup ... readDocument [ withParseHTML yes , withTagSoup , withProxy "www-cache:3128" , withCurl [] , withWarnings no ] "http://www.haskell.org/".reads Haskell homepage with HTML parser, ignoring any warnings (at the time of writing, there were some HTML errors), with http access via libCurl interface and proxy "www-cache" at port 3128, parsing is done with tagsoup HTML parser. This requires packages "hxt-curl" and "hxt-tagsoup" to be installed readDocument [ withValidate yes , withCheckNamespaces yes , withRemoveWS yes , withTrace 2 , withHTTP [] ] "http://www.w3c.org/"read w3c home page (xhtml), validate and check namespaces, remove whitespace between tags, trace activities with level 2. HTTP access is done with Haskell HTTP package readDocument [ withValidate no , withSubstDTDEntities no ... ] "http://www.w3c.org/"read w3c home page (xhtml), but without accessing the DTD given in that document. Only the predefined XML general entity refs are substituted. readDocument [ withValidate no , withSubstDTDEntities no , withSubstHTMLEntities yes ... ] "http://www.w3c.org/"Psame as above, but with substituion of all general entity refs defined in XHTML."for minimal complete examples see Eb and 3, the main starting point for running an XML arrow.hxtthe arrow version of #, the arrow input is the source URIhxt9read a document that is stored in a normal Haskell Stringathe same function as readDocument, but the parameter forms the input. All options available for ? are applicable for readString, except input encoding options.Encoding: No decoding is done, the String argument is taken as Unicode string All decoding must be done before calling readString, even if the XML document contains an encoding spec.hxtthe arrow version of #, the arrow input is the source URIhxtparse a string as HTML content, substitute all HTML entity refs and canonicalize tree. (substitute char refs, ...). Errors are ignored.RThis arrow delegates all work to the parseHtmlContent parser in module HtmlParser.This is a simpler version of ; without any options, but it does not run in the IO monad.hxt<like hread, but accepts a whole document, not a HTML contenthxtparse a string as XML CONTENT, (no xml decl or doctype decls are allowed), substitute all predefined XML entity refs and canonicalize tree This xread arrow delegates all work to the xread parser function in module XmlParsechxta more general version of xread which parses a whole document including a prolog (xml decl, doctype decl) and processing instructions. Doctype decls remain uninterpreted, but are in the list of results trees.ISafe2=?@ACJ#Copyright (C) 2005-2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableSafe2=?@ACQhxt0Namespace of the W3C XML schema datatype library9      !"#$%&'()*+,-./0123459      !"#$%&'()*+,-./012345KCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AC#=hxt.The datatype for modelling the structure of anLhxt,test: is schema a simple XML Schema datatypeMhxt*test: is type a fixed value attribute typeVhxt0access an attribute of a descr of an atomic type667:98;<=EDCB?@A>KJIHGFLMNOPQRSTUVWXYZ[\]^_`abcdefghijk6=EDCB?@A>KJIHGF<;67:98LMNOPQRSTUVWXYZ[\]^_`abcdefghijkL#Copyright (C) 2005-2012 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@AC9phxtThe class for overloading q, the default picklerhxt Choice combinator for unpicklingZfirst 2 arguments are applied sequentially, but if the 1. one fails the 3. arg is appliedhxt,Lift a Maybe value into the Unpickler monad.(The 1. arg is the attached error messagehxt-Lift an Either value into the Unpickler monadhxt'Format the context of an error message.hxt;conversion of an arbitrary value into an XML document tree.xThe pickler, first parameter, controls the conversion process. Result is a complete document tree including a root nodehxt>Conversion of an XML document tree into an arbitrary data typeThe inverse of *. This law should hold for all picklers: ' unpickle px . pickle px $ v == Just v . Not every possible combination of picklers does make sense. For reconverting a value from an XML tree, is becomes neccessary, to introduce "enough" markup for unpickling the valuehxtULike unpickleDoc but with a (sometimes) useful error message, when unpickling failed.hxt4The main entry for unpickling, called by unpickleDochxt6Pickles a value, then writes the document to a string.hxtThe zero pickler/Encodes nothing, fails always during unpicklinghxt unit picklerhxtCheck EOF pickler.zWhen pickling, this behaves like the unit pickler. The unpickler fails, when there is some unprocessed XML contents left.hxt8Like xpCheckEmptyContents, but checks the attribute listhxt9Composition of xpCheckEmptyContents and xpCheckAttributeshxt Lift a Maybe value to a pickler.Nothing is mapped to the zero pickler, Just x is pickled with xpLift x.hxt"Combine two picklers sequentially.@If the first fails during unpickling, the whole unpickler failshxt4First apply a fixed pickler/unpickler, then a 2. oneIf the first fails during unpickling, the whole pickler fails. This can be used to check some properties of the input, e.g. whether a given fixed attribute or a namespace declaration exists (, G) or to filter the input, e.g. to ignore some elements or attributes (, ).When pickling, this can be used to insert some fixed XML pieces, e.g. namespace declarations, class attributes or other stuff.hxt"combine two picklers with a choiceRun two picklers in sequence like with xpSeq. If during unpickling the first one fails, an alternative pickler (first argument) is applied. This pickler is only used as combinator for unpickling.hxt5map value into another domain and apply pickler there$One of the most often used picklers.hxtlike >, but if the inverse mapping is undefined, the unpickler failsdMap a value into another domain. If the inverse mapping is undefined (Nothing), the unpickler fails>Deprecated: Use xpWrapEither, this gives better error messageshxtlike >, but if the inverse mapping is undefined, the unpickler failsMap a value into another domain. If the inverse mapping is undefined, the unpickler fails with an error message in the Left componenthxt$pickle a pair of values sequentially[Used for pairs or together with wrap for pickling algebraic data types with two componentshxtLike  but for tripleshxtLike  and  but for 4-tupleshxtLike  and  but for 5-tupleshxtLike  and  but for 6-tupleshxtLike  and  but for 7-tuples9Thanks to Tony Morris for doing xp7Tuple, ..., xp24Tuple.hxt"Hopefully no one needs a xp25Tuplehxt%Pickle a string into an XML text nodeZOne of the most often used primitive picklers. Attention: For pickling empty strings use A. If the text has a more specific datatype than xsd:string, use hxt%Pickle a string into an XML text nodevText pickler with a description of the structure of the text by a schema. A schema for a data type can be defined by W. In NkJ there are some more functions for creating simple datatype descriptions.hxt0Pickle a possibly empty string into an XML node.QMust be used in all places, where empty strings are legal values. If the content of an element can be an empty string, this string disapears during storing the DOM into a document and reparse the document. So the empty text node becomes nothing, and the pickler must deliver an empty string, if there is no text node in the document.hxtLPickle a possibly empty string with a datatype description into an XML node.Like 9 but with extra Parameter for datatype description as in .hxtXPickle an arbitrary value by applyling show during pickling and read during unpickling. Real pickling is then done with b. One of the most often used pimitive picklers. Applicable for all types which are instances of Read and Showhxt Pickle an Inthxt#Pickle an XmlTree by just adding it?Usefull for components of type XmlTree in other data structureshxtiPickle a whole list of XmlTrees by just adding the list, unpickle is done by taking all element contents.,This pickler should always be combined with - for taking the whole contents of an element.hxtePickle a string representing XML contents by inserting the tree representation into the XML document.4Unpickling is done by converting the contents with  into a string, this function will escape all XML special chars, such that pickling the value back becomes save. Pickling is done with hxtEncoding of optional data by ignoring the Nothing case during pickling and relying on failure during unpickling to recompute the Nothing case#The default pickler for Maybe typeshxt&Optional conversion with default value{The default value is not encoded in the XML document, during unpickling the default value is inserted if the pickler failshxtCEncoding of list values by pickling all list elements sequentially.Unpickler relies on failure for detecting the end of the list. The standard pickler for lists. Can also be used in combination with ' for constructing set and map picklershxt'Encoding of a none empty list of valueskAttention: when calling this pickler with an empty list, an internal error "head of empty list is raised".hxtStandard pickler for mapsThis pickler converts a map into a list of pairs. All key value pairs are mapped to an element with name (1.arg), the key is encoded as an attribute named by the 2. argument, the 3. arg is the pickler for the keys, the last one for the valueshxtPickler for sum data types.Every constructor is mapped to an index into the list of picklers. The index is used only during pickling, not during unpickling, there the 1. match is takenhxt8Pickler for wrapping/unwrapping data into an XML elementeExtra parameter is the element name given as a QName. THE pickler for constructing nested structuresExample: $xpElemQN (mkName "number") $ xpicklewill map an (42::Int) onto <number>42</number>hxtconvenient Pickler for xpElemQN xpElem n = xpElemQN (mkName n)hxtSconvenient Pickler for xpElemQN for pickling elements with respect to namespaces /xpElemNS ns px lp = xpElemQN (mkQName px lp ns)hxt[Pickler for wrapping/unwrapping data into an XML element with an attribute with given valueTo make XML structures flexible but limit the number of different elements, it's sometimes useful to use a kind of generic element with a key value structureExample: _<attr name="key1">value1</attr> <attr name="key2">value2</attr> <attr name="key3">value3</attr>'the Haskell datatype may look like this <type T = T { key1 :: Int ; key2 :: String ; key3 :: Double }-Then the picker for that type looks like this xpT :: PU T xpT = xpWrap ( uncurry3 T, \ t -> (key1 t, key2 t, key3 t) ) $ xpTriple (xpElemWithAttrValue "attr" "name" "key1" $ xpickle) (xpElemWithAttrValue "attr" "name" "key2" $ xpText0) (xpElemWithAttrValue "attr" "name" "key3" $ xpickle)hxt@Pickler for storing/retreiving data into/from an attribute valueHThe attribute is inserted in the surrounding element constructed by the  picklerhxtconvenient Pickler for xpAttrQN xpAttr n = xpAttrQN (mkName n)hxtconvenient Pickler for xpAttrQN -xpAttr ns px lp = xpAttrQN (mkQName px lp ns)hxtA text attribute.hxt:Add an optional attribute for an optional value (Maybe a).hxt*Add/Check an attribute with a fixed value.hxtAdd a namespace declaration.When generating XML the namespace decl is added, when reading a document, the unpickler checks whether there is a namespace declaration for the given namespace URI (2. arg)hxtnWhen unpickling, filter the contents of the element currently processed, before applying the pickler argumentXMaybe useful to ignore some stuff in the input, or to do some cleanup before unpickling.hxtSame as @ but for the attribute list of the element currently processed.oMaybe useful to ignore some stuff in the input, e.g. class attributes, or to do some cleanup before unpickling.kpqrstuvwxy|{z}~k}~xy|{zwtuvsrpqMCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@AChxt!convert a DTD descr into XmlTreeshxt)convert a pickler schema into a DTD descrNCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone2=?@ACB hxt4store an arbitray value in a persistent XML documentIThe pickler converts a value into an XML tree, this is written out with Pb. The option list is passed to Pb%An option evaluated by this arrow is . If  is set (?), the pickler DTD is added as an inline DTD into the document.hxt=Option for generating and adding DTD when document is pickledhxt+read an arbitray value from an XML documentThe document is read with Pa. Options are passed to Pa8. The conversion from XmlTree is done with the pickler.> xpickleDocument xp al dest >>> xunpickleDocument xp al' dest  is the identity arrow when applied with the appropriate options. When during pickling indentation is switched on, the whitespace must be removed during unpickling.hxt4Write out the DTD generated out of a pickler. Calls  xpicklerDTDhxt1The arrow for generating the DTD out of a picklercA DTD is generated from a pickler and check for consistency. Errors concerning the DTD are issued.hxtAn arrow for checking picklers6A value is transformed into an XML document by a given pickler, the associated DTD is extracted from the pickler and checked, the document including the DTD is tranlated into a string, this string is read and validated against the included DTD, and unpickled. The last step is the equality with the input.@If the check succeeds, the arrow works like this, else it fails.hxt)The arrow version of the pickler functionhxt+The arrow version of the unpickler function hxt'Compute the associated DTD of a picklerW6;=pqxyz{| W xyz{|pq=;6l#Copyright (C) 2006-2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone2=?@ACԱp !" #$%&'()*+,- .0123456789:;<=>?@ABCDEF # !" &$%'()-6*+,./012345789:;>?<=@WXYZ[\]^_`abcd     '()*789:;<=NOPabcdefghijklmnopqrstuvwxyz{|}~" !#$%&'()*+,-./0123456789:;<LM"#$      !"#%&'()+,-./012456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~}~6;=pqxyz{| mnopqrstuvwxyz{|}~O]\^                                    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY,-./01Z234567[9\]^_`ab!GHcIJddefghijklmnopqrsttuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~[j      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk l m n o p q r s t u v w x y z { | } ~                                                                   !!!!"""""""""""""""""""""""""""##$$$$$$$$$$$$$$$$$$$$Q$m$n$o$p$q$r$s$$t$v$w$x$u$$$$$$$$$$$$$y$z${$|$}$~$$$$$$$$$$$$ $ $ $ $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $!$"$#$$$$$%$&$'$($)$*$+%,%-%.%/%0%1%2%3%4%5%6%7%8%9%:%;%<%=%>%?%@%A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&[&\&f&]&^&_&`&a&b&c&d&e&f&g&h&i&j'k'l'm'n'o'p'q'r's't'u'v'w'x'y'z'{'|'}'~'''''''''''''''h'''''''''''''''''''''''(()))))))))))V)**************************+++++++++++++++++++++++++++++++++,,-................/011111111111 1 1 1 1 11111 1 111111111111111 1!1"1#1$1%1&1'1(1)1*1+1,1-1.1/1011121314152627282922 2:2;3<3=3>3?3@3A3B3C3D3E3F3G3H3I3J3K3L3M3N3O3Z3P3Q3R3S3T3U3V3W3X3Y3Z3[3\3]4^4_5`6a7b7c8d8e8f8g8h8i8j9k9l9m9n9o9p9q:r:V:s:P:]:\:T:i:j:h:W:X:t:u:v;w;x;y;z;{;|;};~;;;;;;;;;;;;;;;;;;;;;;;;;;<=>>b>>a>c>>?????????????@@@@@@@@@@@@@@@@@@AAAAAAAAAAAAAAAAAAAABBBBBBCDDDDDEbEEEFFGSGGlGGGGdHaHHHHuHvHZHPIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ J J J J JJJJJJJJJJJJJJJJJJJ J!K"K#K$K%K&K'K(KkK)K*K+K,K-K.K/K0K1K2K3K4K5K6K7K8K9K:K;K<K=K>K?K@KAKBKCKDKEKFKGKHKIKJKKKLKMKNKOKPKQKRKSKTKUKVKWKXKYKZL[L\L]L^L_L`LaLbLcLcLdLeLfLgLgLhLiLjLkLlLmLnLoLpLLqLrLsLtLuLvLwLxLyLzL{L|L}L~LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNN          !"#$%&'()*+,-./012(3)4)5)6*7*,8494:4;4<4=4>4?4@4A4B4C4D4E5F5G5H5I5J5K5L6M6G6N6O6P6Q6R7S7T7U7V8W;X;Y<=Z=G=[=\=]=^=_=`=a=b=c=d=efgh#hxt-9.3.1.18-3kJPYCWO0Xm1tldqY0LXyAControl.Arrow.ArrowIOControl.Arrow.ArrowExcControl.Arrow.ArrowListControl.Arrow.ArrowIfControl.Arrow.ArrowStateControl.FlatSeqControl.Arrow.ArrowNFData.AssocList Data.AtomData.Function.SelectorData.Tree.ClassControl.Arrow.ArrowTreeData.Tree.NTree.TypeDefsData.Tree.NTree.EditData.Tree.NavigatableTree.Class#Data.Tree.NavigatableTree.XPathAxisData.Tree.NTree.Zipper.TypeDefs"Control.Arrow.ArrowNavigatableTreeControl.Arrow.StateListArrowControl.Arrow.ListArrowControl.Arrow.NTreeEditControl.Arrow.IOStateListArrowControl.Arrow.IOListArrow!Text.XML.HXT.DOM.MimeTypeDefaultsText.XML.HXT.DOM.MimeTypesText.XML.HXT.DOM.UtilText.XML.HXT.DOM.XmlKeywordsText.XML.HXT.DOM.QualifiedNameText.XML.HXT.DOM.TypeDefs$Text.XML.HXT.Arrow.XmlState.TypeDefs)Text.XML.HXT.Arrow.XmlState.MimeTypeTableText.XML.HXT.DOM.XmlNodeText.XML.HXT.DOM.ShowXmlText.XML.HXT.Arrow.XmlRegexText.XML.HXT.DOM.FormatXmlTreeText.XML.HXT.Arrow.XmlArrow)Text.XML.HXT.Arrow.XmlState.ErrorHandling(Text.XML.HXT.Arrow.XmlState.SystemConfigText.XML.HXT.Arrow.XmlOptionsText.XML.HXT.Arrow.BinaryText.XML.HXT.Arrow.NamespaceText.XML.HXT.DTDValidation.RE#Text.XML.HXT.DTDValidation.TypeDefsText.XML.HXT.IO.GetFILE'Text.XML.HXT.Parser.ProtocolHandlerUtil!Text.XML.HXT.Parser.XmlCharParserText.XML.HXT.Parser.XmlEntities!Text.XML.HXT.Parser.XhtmlEntities"Text.XML.HXT.Parser.XmlTokenParser%Text.XML.HXT.Parser.XmlDTDTokenParserText.XML.HXT.Parser.XmlParsec3Text.XML.HXT.DTDValidation.AttributeValueValidation'Text.XML.HXT.DTDValidation.IdValidation,Text.XML.HXT.DTDValidation.DocTransformation(Text.XML.HXT.DTDValidation.DTDValidation Text.XML.HXT.Parser.XmlDTDParserText.XML.HXT.Parser.HtmlParsec"Text.XML.HXT.Arrow.ParserInterfaceText.XML.HXT.Arrow.Edit Text.XML.HXT.DTDValidation.XmlRE(Text.XML.HXT.DTDValidation.DocValidation%Text.XML.HXT.DTDValidation.Validation)Text.XML.HXT.Arrow.XmlState.TraceHandling'Text.XML.HXT.Arrow.XmlState.URIHandling+Text.XML.HXT.Arrow.XmlState.RunIOStateArrow Text.XML.HXT.Arrow.DocumentInput,Text.XML.HXT.Arrow.GeneralEntitySubstitution!Text.XML.HXT.Arrow.DocumentOutput Text.XML.HXT.Arrow.WriteDocument Text.XML.HXT.Arrow.DTDProcessing"Text.XML.HXT.Arrow.ProcessDocumentText.XML.HXT.Arrow.ReadDocumentText.XML.HXT.Version*Text.XML.HXT.XMLSchema.DataTypeLibW3CNames Text.XML.HXT.Arrow.Pickle.SchemaText.XML.HXT.Arrow.Pickle.XmlText.XML.HXT.Arrow.Pickle.DTDText.XML.HXT.Arrow.PickleisAText.XML.HXT.ArrowArrowXmlControlFlatSeqDeepSeqControl.Arrow.ListArrowspropagateNamespacesText.XML.HXT.DOM.InterfaceText.XML.HXT.DOMMimeTypeDefaultsxreadXmlTreenonethis AssocList ReadDocument escapeXmlDoc readDocument writeDocumentText.XML.HXT.Arrow.XmlStategetDocumentContents SystemConfigwithOutputEncodingText.XML.HXT.XmlKeywords a_no_xml_piText.XML.HXT.XmlState.TypeDefs SysConfigSchemaText.XML.HXT.Core ArrowIOIfisIOAArrowIOarrIOarrIO0arrIO2arrIO3arrIO4ArrowExctryAcatchA ArrowListarr2arr3arr4arr2AarrLarr2LconstAconstL>>.>.listAunlistA withDefaultsingleapplyA$<$<<$<<<$<<<<$<$mergeAperformcatAseqAIfThen:->ArrowIfifAifPnegwhenwhenPwhenNotwhenNotPguardsguardsPfilterA containing notContainingorElsechoiceAtagAspanA partitionA ArrowState changeState accessStategetStatesetState nextStateWNFDatarwnfrwnf2$!!flatseqrlnf$fWNFData(,,,) $fWNFData(,,) $fWNFData(,) $fWNFData[]$fWNFDataWord64$fWNFDataWord32$fWNFDataWord16$fWNFDataWord8 $fWNFDataWord $fWNFData() $fWNFDataBool $fWNFDataChar$fWNFDataDouble$fWNFDataFloat$fWNFDataInteger $fWNFDataIntArrowWNFrwnfArwnf2AArrowNFrnfAstrictA lookupDeflookup1hasEntryaddEntry addEntriesdelEntry delEntriesAtomnewAtomshare $fNFDataAtom $fShowAtom $fReadAtom $fOrdAtom$fEqAtomComp3comp3Comp2comp2Comp1comp1SelectorSgetSsetSchgSchgM mkSelectoridS.&&&.$fCategoryTYPESelector $fComp1(,,)a $fComp1(,)a $fComp2(,,)b $fComp2(,)b $fComp3(,,)cTreemkTreemkLeafisLeafisInnergetNode getChildren changeNodechangeChildrensetNode setChildrenfoldTree nodesTree depthTreecardTree formatTree formatNTree' ArrowTreehasNodeprocessChildrenreplaceChildren/>//>Control.Category>>>GHC.Listspan Data.OldList partitiontheAtoms insertAtomnewAtom'leftApp^<<<<^>>^^>>returnAArrowarrfirstsecond***&&&Kleisli runKleisli ArrowZero zeroArrow ArrowPlus ArrowChoice|||+++leftright ArrowApplyapp ArrowMonad ArrowLooploop<<< theNameCache)hxt-unicode-9.0.2.4-4aBVq3Vady8oHFkmOPHWmData.String.EncodingNames unicodeStringutf16leutf16beutf16utf8ucs2usAscii iso8859_16 iso8859_15 iso8859_14 iso8859_13 iso8859_11 iso8859_10 iso8859_9 iso8859_8 iso8859_7 iso8859_6 iso8859_5 iso8859_4 iso8859_3 iso8859_2 iso8859_1 isoLatin1decodeBinaryValueprocessWithNsEnv1propagateNamespaceEnvvalidate1Namespacesrem_rep checkFile checkValuecheckValueEnumerationcheckValueEntitycheckValueEntitiescheckValueNmtokencheckValueNmtokens checkValueIdcheckValueIdrefcheckValueIdrefs checkForNamecdataNormalizationotherNormalizationreduceWSSequences IdEnvTable traverseTree getIdValuebuildIdCollectorFctsbuildIdrefValidationFctscheckForUniqueIdscheckIdReferences TransEnvTablebuildAllTransformationFunctionsbuildTransformationFunctionslexicographicAttributeOrdernormalizeAttributeValuessetDefaultAttributeValuesvalidateNotationsvalidateEntitiesvalidateElementsvalidateAttributes collectTextEntityRefTablecanonicalizeTree' ValiEnvTablebuildAllValidationFunctionsbuildValidateRootbuildValidateFunctionsbuildContentValidationcreateREbuildAttributeValidationnoDoublicateAttributescheckRequiredAttributescheckFixedAttributescheckNotDeclardAttributescheckValuesOfAttributesGHC.BaseString