(***********************************************************************)
(*                                                                     *)
(*                                 GALAX                               *)
(*                            XML Query Engine                         *)
(*                                                                     *)
(*  Copyright 2001, Lucent Technologies.                               *)
(*  Distributed only by permission.                                    *)
(*                                                                     *)
(***********************************************************************)

(* $Id: namespace.mli,v 1.3 2002/12/10 16:50:37 simeon Exp $ *)

(***********************************************)
(* This module contains support for namespaces *)
(***********************************************)

(**************)
(* Name types *)
(**************)

(* Local name *)

type ncname = string

(* Uri *)

type uri =
  | NSUri of string
  | NSWildcardUri

val string_of_uri : uri -> string

(* Namespace prefix *)

type prefix =
  | NSDefaultElementPrefix
  | NSDefaultFunctionPrefix
  | NSWildcardPrefix
  | NSPrefix of ncname


(***********************)
(* Built-in namespaces *)
(***********************)

(* XML Schema namespaces *)

val xml_prefix : prefix
val xsd_prefix : prefix
val xs_prefix  : prefix

(* XQuery's prefix *)

val xq_prefix  : prefix

val empty_uri  : uri

val xml_uri    : uri
val xmlns_uri  : uri
val xsd_uri    : uri
val xs_uri     : uri
val xsi_uri    : uri
val fn_uri     : uri
val op_uri     : uri
val xq_uri     : uri
val glx_uri    : uri

val is_built_in_namespace : (prefix * uri) -> bool

(**********************************)
(* Operations on prefixes symbols *)
(**********************************)

(* Hashtable over all uri and their corresponding prefixes *)

val prefix_uri_table : (prefix, uri) Hashtbl.t
val add_uri_prefix   : uri -> prefix -> unit
val get_uri_prefix   : uri -> prefix


(*******************)
(* Qualified named *)
(*******************)

(* Unresolved qualified named *)

type uqname = prefix * ncname

(* special unresolved qualified names *)

val anyuqname : uqname

(* takes a string value containing a ':' and extract prefix and local name *)

val uqname_element_of_string          : string -> uqname
val uqname_function_of_string         : string -> uqname
val escaped_uqname_of_string  	      : string -> uqname
val wildcard_uqname_of_string 	      : string -> uqname

(* string value for a resolved qname *)

val string_of_uqname : uqname -> string

(* Resolved qualified named *)

type rqname = uri * ncname

(* special qualified names *)

val anyrqname : rqname

(* Subtagging between resolved qualified names *)

val subrqname : rqname -> rqname -> bool

(* string value for a resolved qname *)

val string_of_rqname : rqname -> string


(*************************)
(* Namespace environment *)
(*************************)

(* type for namespace environments *)

type nsenv

(* creates an empty environment *)

val empty_nsenv : unit -> nsenv

(* adds a new prefix,uri binding in a namespace environment *)

val add_ns : nsenv -> prefix -> uri -> nsenv

val add_all_ns : nsenv -> (prefix * uri) list -> nsenv

(* gets the namespace of a given prefix *)

val get_ns_of_prefix : nsenv -> prefix -> uri

(* adds a known schema target uri in the environment *)

val add_schema_ns : nsenv -> uri -> nsenv

(* is a namespace bound to a schema ? *)

val is_schema_ns : nsenv -> uri -> bool

(* build a new environment from a list of namespaces and schema uris *)

val build_ns : (prefix * uri) list -> uri list -> nsenv

(* Append two namespace environments *)

val append_nsenv : nsenv -> nsenv -> nsenv


