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

(* $Id: xml_ast.mli,v 1.6 2002/09/03 19:52:09 simeon Exp $ *)

(*************************************************)
(* 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 * Simple._text

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 Simple._text                                  (* Text content        : <a> This is text </a> *)
  | XPI of (Simple._ncName * Simple._text)                 (* Processing instruction: <? ... ?> *)
  | XComment of Simple._text                               (* Comment: <!-- ... --> *)

and xml_node_forest = xml_node list

type xml_prolog =
    { xml_decl: (Simple._text * Conf.encoding_kind option * Simple._text 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

