Go to the first, previous, next, last section, table of contents.


The Xpath_tree module

type node_type =
  | Root_node
  | Element_node
  | Attribute_node
  | Namespace_node
  | Pi_node
  | Comment_node
  | Text_node
module Type_test :
sig
  type t =
    | Text_test
    | Comment_test
    | Pi_test of string option
    | Node_test

  val of_string : string -> t
end
module Axis :
sig
  type t =
    | Ancestor
    | Ancestor_or_self
    | Attribute
    | Child
    | Descendant
    | Descendant_or_self
    | Following
    | Following_sibling
    | Namespace
    | Parent
    | Preceding
    | Preceding_sibling
    | Self
  type direction = Forward | Reverse
      
  val principal_type : t -> node_type
  val of_string : string -> t
  val direction : t -> direction
end

TREE specifies what is needed by the XPath evaluator to access the XML document tree

Notes: - node_value must be able to handle every node type except Element and Root - string_value must be able to handle every node type - document_order n1 n2 returns < 0 if n1 is before n2 in document order; > 0 if n1 is after n2 ...; 0 if n1 and n2 represent the same node (which does not imply n1 == n2) - unique_id n id returns the node corresponding to id in the same document as n, or raise Not_found

module
 type TREE =
sig

an abstract node type

  type node

a node set is list of nodes sorted by document order

  type node_set = node list
  val fusion : node_set -> node_set -> node_set

an axis_fun fold a function over the corresponding nodeset for this axis _in reverse document order_ (like List.fold_right)

  type 'a axis_fun = (node -> 'a -> 'a) -> node -> 'a -> 'a
  val axis_fun : Axis.t -> 'a axis_fun
  val compute_axis : 
    node_set axis_fun -> (node -> bool) -> node -> node_set

  val principal_type_test : Axis.t -> (node -> bool)
  val test_node_type : Type_test.t -> (node -> bool)

node accesors

  val node_type : node -> node_type
  val node_value : node -> string  
  val node_expanded_name : node -> Xpath_names.expanded_name
  val node_name : node -> string
  val node_lang : node -> string option
  val string_value : node -> string

  val node_parent : node -> node option
  val node_root : node -> node
  val node_following_sibling : node -> node option
  val node_preceding_sibling : node -> node option
  val node_children : node -> node list
  val node_attributes : node -> node list
  val node_namespaces : node -> node list

  val document_order : node -> node -> int
  val unique_id : node -> string -> node
end

DATA specifies a minimal set of node accessors from which the functor TREE_OF_DATA is able to create a TREE; when optional accessors are not provided, TREE_OF_DATA implements generic algorithms

module
 type DATA =
sig
  type node
  val node_expanded_name : node -> Xpath_names.expanded_name
  val node_value : node -> string
  val node_type : node -> node_type
  val node_parent : node -> node option
  val node_following_sibling : node -> node option
  val node_preceding_sibling : node -> node option
  val node_children : node -> node list
  val node_attributes : node -> node list
  val node_namespaces : node -> node list
  val document_order : node -> node -> int
  val unique_id : node -> string -> node

optional accesors

  val node_root : (node -> node) option

default: use node_parent recursively

  val node_name : (node -> string) option

default: try to rebuild the prefix with node_namespaces

  val node_lang : (node -> string option) option

default: use node_attribute and node_parent to find the corresponding xml:lang attribute

end
module TREE_OF_DATA  (Data : DATA) : (TREE with
 type node = Data.node)
							  


Go to the first, previous, next, last section, table of contents.