revised gda-xml-query.dtd



Hi Vivien,

in the attachment you find the revised gda-xml-query.dtd and two examples.

new features:
- create/drop of table/view/sequence/index
- intersect/minus

As usual comments and suggestions appreciated.

Gerhard



<!ELEMENT query (target?, sources?, joins*, values?, qual?, chain*, sort?)>
<!ATTLIST query
          id NMTOKEN #IMPLIED
          op (select|insert|update|delete|create|drop) #REQUIRED>

<!ELEMENT target (table|view|sequence|index)*>

<!ELEMENT sources (table|view)*>

<!ELEMENT joins (and|or|not|eq|ne|lt|le|gt|ge)*>
<!ATTLIST joins
          type (inner|left|right) "inner"
          left  IDREF #REQUIRED
          right IDREF #REQUIRED>

<!ELEMENT values (const|query|field|func|aggregate)+>

<!ELEMENT qual (and|or|not|eq|ne|lt|le|gt|ge|null|like|between|in|exists)>

<!ELEMENT chain (sources, joins*, values, qual?)>
<!ATTLIST chain 
          type (union|unionall|intersect|minus) #REQUIRED>

<!ELEMENT sort (COLUMN)+>

<!ELEMENT table (fielddef*,primary?,foreign*)?>
<!ATTLIST table
          id      ID       #IMPLIED
          name    NMTOKEN  #REQUIRED
          columns NMTOKENS #IMPLIED
          temp (yes|no) "no">

<!ELEMENT view EMPTY EMPTY>
<!ATTLIST view
          id      ID       #IMPLIED
          name    NMTOKEN  #REQUIRED
          columns NMTOKENS #IMPLIED>

<!ELEMENT const EMPTY>
<!ATTLIST const
          value CDATA   #IMPLIED
          alias NMTOKEN #IMPLIED
          null (yes|no) "no">

<!ELEMENT field EMPTY>
<!ATTLIST field
          source IDREF   #REQUIRED
          name   NMTOKEN #REQUIRED
          alias  NMTOKEN #IMPLIED
          group (yes|no) "no">

<!ELEMENT func (field|const|func)*>
<!ATTLIST func 
          name  NMTOKEN #REQUIRED
          alias NMTOKEN #IMPLIED>

<!ELEMENT and (and|or|not|eq|ne|lt|le|gt|ge|null|like|between|in|exists)+>

<!ELEMENT or (and|or|not|eq|ne|lt|le|gt|ge|null|like|between|in|exists)+>

<!ELEMENT not (and|or|not|eq|ne|lt|le|gt|ge|null|like|between|in|exists)>

<!ELEMENT eq ((const|field|func),(const|query|field|func))>

<!ELEMENT ne ((const|field|func),(const|query|field|func))>

<!ELEMENT lt ((const|field|func),(const|query|field|func))>

<!ELEMENT le ((const|field|func),(const|query|field|func))>

<!ELEMENT gt ((const|field|func),(const|query|field|func))>

<!ELEMENT ge ((const|field|func),(const|query|field|func))>

<!ELEMENT null (const|field|func)>

<!ELEMENT like ((const|field|func),(const|query|field|func))>

<!ELEMENT between ((const|field|func),(const|field|func),(const|field|func))>

<!ELEMENT in (field,query)>

<!ELEMENT exists (query)>

<!ELEMENT column EMPTY>
<!ATTLIST column num  CDATA #REQUIRED
                 order (asc|desc) "asc">

<!ELEMENT fielddef EMPTY>
<!ATTLIST fielddef
          id   ID      #IMPLIED
          name NMTOKEN #REQUIRED
          type (int|float|varchar|fixedchar|datetime) #REQUIRED
          size CDATA   #IMPLIED
          notnull (yes|nos) "no">

<!ELEMENT primary EMPTY>
<ATTLIST  primary
          key IDREFS #REQUIRED>

<!ELEMENT foreign EMPTY>
<ATTLIST  key   IDREFS   #REQUIRED
          table NMTOKEN  #REQUIRED
          ref   NMTOKENS #REQUIRED>

<!ELEMENT sequence EMPTY>
<ATTLIST  sequence
          name  NMTOKEN #REQUIRED
          start CDATA   #IMPLIED
          inc   CDATA   #IMPLIED>

<!ELEMENT index EMPTY>
<ATTLIST  index
          name    NMTOKEN  #REQUIRED
          table   NMTOKEN  #REQUIRED
          columns NMTOKENS #REQUIRED
          unique  (yes|no) "no">

<?xml version="1.0"?>
<!DOCTYPE query SYSTEM "/home/gmd/xml/query/query.dtd">

<!--
create view vw_a (a,b,c)
as select fa, fb, fc 
     from table tab_a;
-->

<query op="create">
  <target>
    <view name="vw_a" columns="a b c"/>
  </target>
  <sources>
    <table id="t1" name="tab_a"/>
  </sources>
  <values>
    <field source="t1" name="fa"/>
    <field source="t1" name="fb"/>
    <field source="t1" name="fc"/>
  </values>
</query> 

<?xml version="1.0"?>
<!DOCTYPE query SYSTEM "/home/gmd/xml/query/query.dtd">

<!--
create table tab_a (
  ival   int2  not null,
  dval   float8,
  vval   varchar(100),
  cval   char(4),
  primary key (ival),
  foreign key (ival,cval) references tab_b(iival,ccval),
  foreign key (cval) references tab_c(cccval));
-->

<query op="create">
  <target>
    <table name="tab_a">
      <fielddef id="f1" name="ival" type="int"     size="2"  notnull="yes"/>
      <fielddef id="f2" name="dval" type="float"   size="8"/>
      <fielddef id="f3" name="vval" type="varchar" size="100"/>
      <fielddef id="f4" name="cval" type="char"    size="4"/>
      <primary key="f1"/>
      <foreign key="f1 f4" table="tab_b" key="iival ccval">
      <foreign key="f4" table="tab_c" key="cccval">
    </table>
  </target>
</query> 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]