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

(* $Id: mapping.mli,v 1.5 2002/11/15 05:29:23 simeon Exp $ *)

(***********************************************************************)
(* this interface is the toplevel of the mapping from Full XQuery      *)
(* expression to the Core XQuery Expreession.                          *)
(***********************************************************************)

(* Maps context information into a new namespace environment and
   additional sort declarations *)

val map_context : Xquery_ast.context_decl list -> Namespace.nsenv * Xquery_ast.sort_decl_list

(* Maps sort declarations and compiles a new schema *)

val map_sort : Namespace.nsenv -> Xquery_ast.sort_decl_list -> Schema.schema

(* Maps datatypes into models *)

val map_resolved_datatype_to_model : Xquery_ast.datatype -> Xquery_ast.model

(* Separate mapping functions:
     o one for the context
     o one for a single expression *)


val map_prolog  : Xquery_ast.query_module -> Namespace.nsenv * Xatenv.tenv * Xquery_ast.cquery_module

val map_expr    : Namespace.nsenv         -> Xatenv.tenv -> Xquery_ast.expr -> Xquery_ast.cexpr

(* The toplevel mapping functions *)

(* Note:

     These functions:
     1. Build the top-level namespace environment
     2. Compile the top-level sort declarations into a schema
     3. Map all the XQuery expressions into the core
     4. Returns the core, compiled schema and namespace environment
   - Jerome
*)

val mapFXQuery :
    Xquery_ast.query_module -> Namespace.nsenv * Schema.schema * Xquery_ast.cquery_module

val mapFXQueryWithEnv :
    Xquery_ast.query_module -> Namespace.nsenv -> Xatenv.tenv -> Namespace.nsenv * Xatenv.tenv * Xquery_ast.cquery_module
