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

(* $Id: xml_ast.mli,v 1.2 2003/05/20 15:29:50 mff Exp $ *)

(* Module Xml_ast
   Description:
     This *interface* contains type declarations for XML document
     abstract syntax trees.
*)

(* Note:
     This module is mostly subsumed by the SAX parser and will soon be
     removed. The last dependency to that module is to XML Schema
     import and XML Schema validation.
   - Jerome
 *)

(*************************************************)
(* Simple Abstract Syntax Tree for XML documents *)
(*************************************************)

open Sym

(* This module contains data structures used to represent the abstract
   syntax tree corresponding to a parsed XML document *)

(* Note:
     The AST here has be designed to be minimalistic. The objective is
     to reduce the memory required to represent a given XML document.
   - Jerome
 *)

(***********)
(* XML AST *)
(***********)

type xml_attribute =
    attr_symbol * Datatypes.xdt_untyped

and xml_attribute_forest =
    xml_attribute list

type xml_node =
  | XElem of
      elem_symbol * xml_attribute_forest * xml_node_forest (* Element  : <a b1="">...</a> *)
  | XText of Datatypes.xdt_untyped                                  (* Text content        : <a> This is text </a> *)
  | XPI of (Namespace.ncname * Datatypes.xdt_untyped)                 (* Processing instruction: <? ... ?> *)
  | XComment of Datatypes.xdt_untyped                               (* Comment: <!-- ... --> *)

and xml_node_forest = xml_node list

type xml_prolog =
    { xml_decl: (Datatypes.xdt_untyped * Glx_pxp.encoding option * Datatypes.xdt_untyped option) option;
      xml_misc_prolog: xml_node_forest }

type xml_document =
    { xml_prolog: xml_prolog;
      xml_root: xml_node;
      xml_misc: xml_node_forest }

(******************)
(* XML Schema AST *)
(******************)

type xml_schema_document = xml_document

