<!--      libgda-dict.dtd
          DTD for libgda
          Version 1.33
          Copyright (C) 2000 - 2005 Vivien Malerba
          Copyright (C) 2001 - 2002 Fernando Martins

	  Note: encoding of XML ID strings is done using a derivative of BASE64.
-->
<!ELEMENT gda_dict (gda_dsn_info?, gda_dict_types?, gda_dict_procedures?, gda_dict_aggregates?, gda_dict_database?, gda_queries*, gda_graphs?)>
<!ATTLIST gda_dict
	  with_functions (t|f) #IMPLIED>


<!--
          Datasource information for the dictionary, not mandatory. However the GdaDict object
	  will emit a warning if the datasource is not correct when assigning it a #GdaConnection
	  object to update the DBMS data.
-->
<!ELEMENT gda_dsn_info EMPTY>
<!ATTLIST gda_dsn_info
	  dsn NMTOKEN #REQUIRED
	  user CDATA #IMPLIED>

<!--      
          ID construction for:
             * data types: "DT" + encoded type name (ex: name="DTYm9vbA")
             * function:   "PR" + encoded oid       (ex: oid="PRMTcwNQ")
             * aggregate:  "AG" + encoded oid       (ex: oid="AGMjEwMQ")
-->

<!ELEMENT gda_dict_types (gda_dict_type*)>
<!ELEMENT gda_dict_type EMPTY>
<!ATTLIST gda_dict_type
	  id ID #REQUIRED
          name CDATA #REQUIRED
          owner CDATA #IMPLIED
          descr CDATA #IMPLIED
          nparam NMTOKEN #REQUIRED
          gdatype NMTOKEN #REQUIRED
	  synonyms CDATA #IMPLIED
	  custom (t|f) #IMPLIED>

<!ELEMENT gda_dict_procedures (gda_dict_function*)>
<!ELEMENT gda_dict_function (gda_func_param*)>
<!ATTLIST gda_dict_function
	  id ID #REQUIRED
          name CDATA #REQUIRED 
          owner CDATA #IMPLIED
          descr CDATA #IMPLIED>

<!ELEMENT gda_func_param EMPTY>
<!ATTLIST gda_func_param
          type IDREF #IMPLIED
          way (out|in) #REQUIRED>

<!ELEMENT gda_dict_aggregates (gda_dict_aggregate*)>
<!ELEMENT gda_dict_aggregate (gda_func_param*)>
<!ATTLIST gda_dict_aggregate
          id ID #REQUIRED
          name CDATA #REQUIRED
          owner CDATA #IMPLIED
          descr CDATA #IMPLIED>

<!--      Information specific to a database: GDA_DATABASE
          ID construction for:
             * tables:   "TV" + encoded table/view name (ex: name="TVY3VzdG9tZXJz")
             * fields:   table id + ":FI" + encoded field name (ex: name="TVY3VzdG9tZXJz:FIaWQ")
             * sequences:"SE" + encoded sequence name (ex: name="SEdG9tZX")
-->

<!ELEMENT gda_dict_database (gda_dict_tables?, gda_dict_sequences?, gda_dict_constraints?)>

<!ELEMENT gda_dict_tables (gda_dict_table*)>

<!ELEMENT gda_dict_table (gda_dict_parent_table*, gda_dict_field*)>
<!ATTLIST gda_dict_table
          id ID #REQUIRED
	  name CDATA #REQUIRED
          owner NMTOKEN #IMPLIED
          descr CDATA #IMPLIED
          is_view (t|f) #IMPLIED>

<!ELEMENT gda_dict_parent_table EMPTY>
<!ATTLIST gda_dict_parent_table
          table IDREF #REQUIRED
          order NMTOKEN #REQUIRED>

<!ELEMENT gda_dict_field EMPTY>
<!ATTLIST gda_dict_field
          id ID #REQUIRED
	  name CDATA #REQUIRED
	  owner NMTOKEN #IMPLIED
	  descr CDATA #IMPLIED
          type IDREF #REQUIRED
          length NMTOKEN #REQUIRED
	  scale NMTOKEN #REQUIRED
          default CDATA #IMPLIED
	  default_gda_type NMTOKEN #IMPLIED
	  extra_attr NMTOKENS #IMPLIED
          plugin NMTOKENS #IMPLIED>

<!ELEMENT gda_dict_constraints (gda_dict_constraint*)>

<!ELEMENT gda_dict_constraint (gda_dict_constraint_field* | gda_dict_constraint_pair*)>
<!ATTLIST gda_dict_constraint
	  name CDATA #IMPLIED
	  table IDREF #REQUIRED
	  user_defined (t|f) #IMPLIED
	  type NMTOKEN #REQUIRED
	  on_update NMTOKEN #IMPLIED
	  on_delete NMTOKEN #IMPLIED>

<!ELEMENT gda_dict_constraint_field EMPTY>
<!ATTLIST gda_dict_constraint_field
	  field IDREF #REQUIRED>

<!ELEMENT gda_dict_constraint_pair EMPTY>
<!ATTLIST gda_dict_constraint_pair
          field IDREF #REQUIRED
	  ref IDREF #REQUIRED>

<!ELEMENT gda_dict_sequences (gda_dict_sequence*)>
<!ELEMENT gda_dict_sequence (seq_link*)>
<!ATTLIST gda_dict_sequence
          name ID #REQUIRED
          comments CDATA #IMPLIED
          owner NMTOKEN #REQUIRED>

<!ELEMENT seq_link EMPTY>
<!ATTLIST seq_link
          field IDREF #REQUIRED>




<!--      Information specific to a queries
          ID construction for:
             * queries:  "QU" + query ident (ex: name="QU15")
	     * target: query id + ":T" + id of the target
             * field: Query id + ":QF" + element order in the list
                                            (ex: id = "QU15:QF2")
	     * condition: Query id + "C" + id of the condition
-->

<!ELEMENT gda_queries (gda_query*)>

<!ELEMENT gda_query (gda_param_sources?, ((gda_query_target*, (gda_query_ffield | gda_query_fall | gda_query_fagg | gda_query_ffunc | gda_query_fval)*, gda_query_join*, gda_query_cond?, gda_query_fields_order?, gda_query*) | gda_query_text?))>
<!ATTLIST gda_query
          id ID #REQUIRED
          name CDATA #IMPLIED
          descr CDATA #IMPLIED
	  query_type (SEL|INS|UPD|DEL|NION|ECT|XPT|TXT) #REQUIRED
	  distinct (t|f) #IMPLIED>

<!--
    use either entity_ref or table_name, not both at the same time (anyway entity_ref will take precedence)
-->
<!ELEMENT gda_query_target EMPTY>
<!ATTLIST gda_query_target
          id ID #REQUIRED
	  entity_ref IDREF #IMPLIED
	  table_name NMTOKEN #IMPLIED
	  occ CDATA #IMPLIED
	  alias NMTOKENS #IMPLIED>

<!-- For GdaQueryFieldField -->
<!ELEMENT gda_query_ffield EMPTY>
<!ATTLIST gda_query_ffield
          id ID #REQUIRED
          name CDATA #IMPLIED
	  descr CDATA #IMPLIED
          target IDREF #IMPLIED
          object IDREF #IMPLIED
	  target_name NMTOKEN #IMPLIED
	  object_name NMTOKEN #IMPLIED
          is_visible (t|f) #IMPLIED
          is_internal (t|f) #IMPLIED
          value_prov IDREF #IMPLIED
          alias CDATA #IMPLIED
	  plugin NMTOKENS #IMPLIED>

<!-- For GdaQueryFieldAll -->
<!ELEMENT gda_query_fall EMPTY>
<!ATTLIST gda_query_fall
          id ID #REQUIRED
          name CDATA #IMPLIED
          target IDREF #IMPLIED
          target_name NMTOKEN #IMPLIED
          is_visible (t|f) #IMPLIED
          is_internal (t|f) #IMPLIED>

<!-- For GdaQueryFieldAgg -->
<!ELEMENT gda_query_fagg (gda_query_field_ref*)>
<!ATTLIST gda_query_fagg
          id ID #REQUIRED
          name CDATA #IMPLIED
	  descr CDATA #IMPLIED
          agg IDREF #IMPLIED
	  agg_name NMTOKEN #IMPLIED
          is_visible (t|f) #IMPLIED
          is_internal (t|f) #IMPLIED
          alias CDATA #IMPLIED>

<!-- For GdaQueryFieldFunc -->
<!ELEMENT gda_query_ffunc (gda_query_field_ref*)>
<!ATTLIST gda_query_ffunc
          id ID #REQUIRED
          name CDATA #IMPLIED
	  descr CDATA #IMPLIED
          func IDREF #IMPLIED
	  func_name NMTOKEN #IMPLIED
          is_visible (t|f) #IMPLIED
          is_internal (t|f) #IMPLIED
          alias CDATA #IMPLIED>

<!-- For GdaQueryFieldValue 
     the @restrict attribute is the name of data model in gda_param_sources:col number-->
<!ELEMENT gda_query_fval EMPTY>
<!ATTLIST gda_query_fval
          id ID #REQUIRED
          name CDATA #IMPLIED
	  descr CDATA #IMPLIED
          is_visible (t|f) #IMPLIED
          is_internal (t|f) #IMPLIED
	  gda_type NMTOKEN #REQUIRED
          dict_type IDREF #IMPLIED
	  value CDATA #IMPLIED
          default CDATA #IMPLIED
	  default_gda_type NMTOKEN #IMPLIED
	  is_param (t|f) #IMPLIED
	  null_ok (t|f) #IMPLIED
          restrict NMTOKEN #IMPLIED
          alias CDATA #IMPLIED
	  plugin NMTOKENS #IMPLIED>

<!ELEMENT gda_query_field_ref EMPTY>
<!ATTLIST gda_query_field_ref
 	  object IDREF #REQUIRED
          order (ASC|DES) #IMPLIED>

<!ELEMENT gda_query_fields_order (gda_query_field_ref*)>

<!ELEMENT gda_query_cond (gda_query_cond*)>
<!ATTLIST gda_query_cond
          id ID #REQUIRED
          type (AND|OR|NOT|EQ|NE|SUP|ESUP|INF|EINF|LIKE|SIMI|REG|CREG|NREG|CNREG|IN|BTW) #REQUIRED
	  l_op IDREF #IMPLIED
	  r_op IDREF #IMPLIED
	  r_op2 IDREF #IMPLIED>

<!ELEMENT gda_query_join (gda_query_cond?)>
<!ATTLIST gda_query_join
          target1 IDREF #REQUIRED
          target2 IDREF #REQUIRED
	  join_type (INNER|LEFT|RIGHT|FULL|CROSS) #IMPLIED>

<!ELEMENT gda_query_text (#PCDATA)>

<!ELEMENT gda_param_sources ((gda_query|gda_array)*)>

<!--      Storage of some raw data
	  ID construction for:
	     * gda_array: "DA" + array ident (ex: id="DA15")
	     * gda_array_field: array id + ":FI" + id of the field (ex: id="DA15:FI1")
-->
<!ELEMENT gda_array (gda_array_field*,gda_array_data)>
<!ATTLIST gda_array
	  id ID #REQUIRED
	  name CDATA #IMPLIED>

<!ELEMENT gda_array_field EMPTY>
<!ATTLIST gda_array_field
          id ID #IMPLIED
	  name CDATA #REQUIRED
	  gdatype NMTOKEN #REQUIRED
	  title CDATA #IMPLIED
	  caption CDATA #IMPLIED
	  dbms_type IDREF #IMPLIED
	  size NMTOKEN #IMPLIED
	  scale NMTOKEN #IMPLIED
	  pkey (t|f) #IMPLIED
	  unique (t|f) #IMPLIED
	  nullok (t|f) #IMPLIED>

<!ELEMENT gda_array_data (gda_array_row*)>
<!ELEMENT gda_array_row (gda_value*)>
<!ELEMENT gda_value (#PCDATA)>


<!--      Information specific to the GUI part of the program 
	  ID construction for:
		* GnomeDbGraph: "GR" + graph ident (example: "GR10")
-->
<!ELEMENT gda_graphs (gda_graph*)>

<!ELEMENT gda_graph (gda_graph_item*)>
<!ATTLIST gda_graph
	  id ID #REQUIRED
	  name CDATA #IMPLIED
          descr CDATA #IMPLIED
	  type (R|Q|M) #IMPLIED
          object IDREF #IMPLIED>

<!ELEMENT gda_graph_item EMPTY>
<!ATTLIST gda_graph_item
          object IDREF #IMPLIED
	  xpos CDATA #IMPLIED
	  ypos CDATA #IMPLIED>
