Initial public import
[afterthought.git] / xpath_ext.ml
1 open Printf
2
3 (*module Names = Xpath_names*)
4
5 type node_type =
6   | Root_node
7   | Element_node
8   | Attribute_node
9   | Namespace_node
10   | Pi_node
11   | Comment_node
12   | Text_node
13
14 module Type_test =
15 struct
16   type t = 
17     | Text_test
18     | Comment_test
19     | Pi_test of string option
20     | Node_test
21
22   let of_string = function
23     | "comment" ->  Comment_test
24     | "text" -> Text_test
25     | "processing-instruction" ->  Pi_test None
26     | "node" -> Node_test
27     | s -> raise Not_found
28 end
29
30 module Axis =
31 struct
32   type t = 
33     | Ancestor
34     | Ancestor_or_self
35     | Attribute
36     | Child
37     | Descendant
38     | Descendant_or_self
39     | Following
40     | Following_sibling
41     | Namespace
42     | Parent
43     | Preceding
44     | Preceding_sibling
45     | Self
46
47   let principal_type = function
48     | Attribute -> Attribute_node
49     | Namespace -> Namespace_node
50     | _         -> Element_node
51
52   let of_string = function
53     | "ancestor" -> Ancestor
54     | "ancestor-or-self" -> Ancestor_or_self
55     | "attribute" -> Attribute
56     | "child" -> Child
57     | "descendant" -> Descendant
58     | "descendant-or-self" -> Descendant_or_self
59     | "following" -> Following
60     | "following-sibling" -> Following_sibling
61     | "namespace" -> Namespace
62     | "parent" -> Parent
63     | "preceding" -> Preceding
64     | "preceding-sibling" -> Preceding_sibling
65     | "self" -> Self
66     | s -> raise Not_found
67
68   type direction = Forward | Reverse
69
70   let direction = function
71     | (Ancestor | Ancestor_or_self | Preceding | Preceding_sibling) -> Reverse
72     | _ -> Forward
73 end