(***********************************************************************)
(*                                                                     *)
(*                                 GALAX                               *)
(*                              XQuery Engine                          *)
(*                                                                     *)
(*  Copyright 2001-2003, Lucent Technologies.                          *)
(*  Distributed only by permission.                                    *)
(*                                                                     *)
(***********************************************************************)

(* $Id: nodeid.mli,v 1.9 2003/05/21 15:03:49 simeon Exp $ *)

(*****************)
(* Id structures *)
(*****************)

type docid

type prefix
type postfix

type nodeid
type nodeid_gen

(*********************************)
(* Document and node id creation *)
(*********************************)

(* create a new node id generator for a given document *)

val new_nodeid_gen : unit -> nodeid_gen

(* new prefix *)

val new_prefix : nodeid_gen -> prefix

(* new postfix *)

val new_postfix : nodeid_gen -> postfix

(* build node id *)

val build_nodeid : nodeid_gen -> prefix -> postfix -> nodeid

(* build node id, with a given ID value *)

val build_nodeid_with_ID : nodeid_gen -> prefix -> postfix -> Datatypes.xs_string -> nodeid

(* Convenience function to create ids for leaf nodes *)

val new_leaf_nodeid : nodeid_gen -> nodeid

(****************)
(* External ids *)
(****************)

(* Note:
     There are tables to store ID/IDREF values to node mappings.
   - J&M
*)

val clear_id_tables : unit -> unit


(**********************************)
(* Document and node id accessors *)
(**********************************)

(* get document id from doc_id_gen *)

val get_docid_from_nodeid_gen : nodeid_gen -> docid

(* get document id from a node *)

val get_docid : nodeid -> docid

(* node equality *)

val node_is : nodeid -> nodeid -> bool

(* preceding *)

val node_precedes : nodeid -> nodeid -> bool

(* following *)

val node_follows : nodeid -> nodeid -> bool

(* Node id compare function *)

val node_compare : nodeid -> nodeid -> int

(* accesses the node id from the document id and the IDREF *)

val node_lookup_from_IDREF : docid -> Datatypes.xs_string -> nodeid

(* Is there an external ID associated to that node ? *)

val lookup_external_identifier : nodeid -> (docid * Datatypes.xs_string) option

val string_of_nodeid : nodeid -> string

