<?xml version="1.0"?>

<!-- JSDAI Query syntax specification Version 1                    -->
<!-- ------------------------------------------                    -->
<!-- Copyright (c) 2002 LKSoftWare GmbH                            -->
<!-- $Id$ -->

<!-- *************** Query ***************                         -->
<!--                    query                                      -->
<!--                    The top element of a query document        -->
<!ELEMENT  query        (domain | result)+                           >

<!--         xmlns      Namespace specification
             context    Execution context (local or remote)        -->
<!ATTLIST  query
             xmlns      CDATA
                        #FIXED "http://www.lksoft.com/SDAI/Query/V1" 
             context    (local|remote)                   "local"     >

<!-- *************** Domain ***************                        -->
<!-- Since domain is not supported this part of DTD is outdated    -->
<!--                    domain                                     -->
<!--                    Query domain on which query is
                        performed                                  -->
<!ELEMENT  domain       (repository | model | schema-instance)+      >

<!--                    repository                                 -->
<!--                    Repository where to query                  -->
<!ELEMENT  repository   (name | description | change-date | author |
                         organization | preprocessor-version |
                         originating-system | authorization |
                         default-language | context-identifiers)*    >

<!--                    model                                      -->
<!--                    Model where to query                       -->
<!ELEMENT  model        (name | underlying-schema | change-date |
                         default-language | context-identifiers)*    >

<!--                    schema-instance                            -->
<!--                    Schema instance where to query             -->
<!ELEMENT  schema-instance
                        (name | native-schema | change-date |
                         validation-date | validation-result |
                         validation-level | description | author |
                         organization | preprocessor-version |
                         originating-system | authorization |
                         default-language | context-identifiers)*    >

<!--                    name                                       -->
<!--                    Name of repository, model, or schema
                        instance                                   -->
<!ELEMENT  name         (#PCDATA)                                    >

<!--                    description                                -->
<!--                    Description of repository or schema
                        instance                                   -->
<!ELEMENT  description  (#PCDATA)                                    >

<!--                    change-date                                -->
<!--                    Date of recent modification of
                        repository, model, or schema
                        instance. String in ISO format             -->
<!ELEMENT  change-date  (#PCDATA)                                    >

<!--                    author                                     -->
<!--                    Author of repository or schema instance    -->
<!ELEMENT  author       (#PCDATA)                                    >

<!--                    organization                               -->
<!--                    Organization of repository or schema
                        instance                                   -->
<!ELEMENT  organization (#PCDATA)                                    >

<!--                    preprocessor-version                       -->
<!--                    Preprocessor version of repository or
                        schema instance                            -->
<!ELEMENT  preprocessor-version
                        (#PCDATA)                                    >

<!--                    originating-system                         -->
<!--                    Originating system of repository or
                        schema instance                            -->
<!ELEMENT  originating-system
                        (#PCDATA)                                    >

<!--                    authorization                              -->
<!--                    Authorization of repository or schema
                        instance                                   -->
<!ELEMENT  authorization
                        (#PCDATA)                                    >


<!--                    default-language                           -->
<!--                    Default language of repository, model, or
                        schema instance                            -->
<!ELEMENT  default-language
                        (#PCDATA)                                    >

<!--                    context-identifiers                        -->
<!--                    Context identifiers of repository, model,
                        or schema instance                         -->
<!ELEMENT  context-identifiers
                        (#PCDATA)                                    >

<!--                    underlying-schema                          -->
<!--                    Underlying schema of the model             -->
<!ELEMENT  underlying-schema
                        (#PCDATA)                                    >

<!--                    native-schema                              -->
<!--                    Native schema of the schema instance       -->
<!ELEMENT  native-schema
                        (#PCDATA)                                    >

<!--                    validation-date                            -->
<!--                    Validation date of the schema
                        instance. String in ISO format             -->
<!ELEMENT  validation-date
                        (#PCDATA)                                    >

<!--                    validation-result                          -->
<!--                    Validation result of the schema
                        instance. An integer                       -->
<!ELEMENT  validation-result
                        (#PCDATA)                                    >

<!--                    validation-level                           -->
<!--                    Validation level of the schema
                        instance. An integer                       -->
<!ELEMENT  validation-level
                        (#PCDATA)                                    >

<!-- *************** End domain ***************                    -->

<!-- *************** Constraints ***************                   -->
<!--                    set-operations                             -->
<!--                    List of all set operations                 -->
<!ENTITY % set-operations
                       "intersect | union | and | or | not"          >

<!--                    comparison-operations                      -->
<!--                    List of all comparison operations          -->
<!ENTITY % comparison-operations
                       "eq"                                          >

<!--                    constraints-list                           -->
<!--                    List of common constraints                 -->
<!ENTITY % constraint-list
                       "type | fwd | inv | val | %set-operations;"   >

<!--                    constraints                                -->
<!--                    Constraint list                            -->
<!-- Output: input instance subset that match child constraints    -->
<!ENTITY % constraints "(%constraint-list;)*"                        >

<!--                    Contraints or several compound constraint
                        groups                                     -->
<!ENTITY % constraints-or-group
                       "((%constraint-list; |
                        %comparison-operations;)+ | (grp)+)"         >

<!--                    Yes or no answer                           -->
<!--                    Defines values of boolean type attributes  -->
<!ENTITY % yes-no      "(yes | no | true | false)"                   >

<!--                    Entity name                                -->
<!ENTITY % ent         "ent NMTOKEN"                                 >

<!--                    Attribute name                             -->
<!ENTITY % attr        "attr NMTOKEN"                                >

<!--                    Aggregate member(s)                        -->
<!--                    Possible values: * or integer index        -->
<!ENTITY % aggr        "aggr CDATA"                                  >

<!--                    Aggregate size                             -->
<!--                    Value: an integer                          -->
<!ENTITY % aggr-size   "aggr-size CDATA"                             >

<!-- Query result definition                                       -->
<!--                    result                                     -->
<!--                    Query result definition                    -->
<!ELEMENT  result       %constraints;                                >
<!--         name       Name of the named query result             -->
<!ATTLIST  result
             name       NMTOKEN                            #IMPLIED  >

<!--                    type                                       -->
<!--                    (Sub)Type of entity constraint             -->
<!-- Output: input instance subset that match the specified type   -->
<!-- Child constraints can further restrict the output set.        -->
<!-- See: ENTITY % constraints                                     -->
<!ELEMENT  type         %constraints;                                >
<!--         ent        Entity type
             exact      If this is an exact (sub)type              -->
<!ATTLIST  type
             %ent;                                         #REQUIRED
             exact      %yes-no;                           #IMPLIED  >

<!--                    fwd                                        -->
<!--                    Forward reference (attribute value)        -->
<!-- Output: a set of instances that are attribute values of       -->
<!--         the input instance set                                -->
<!-- Child constraints can further restrinct the output set.       -->
<!-- See: ENTITY % constraints                                     -->
<!ELEMENT  fwd          %constraints;                                >
<!--         %ent;      Entity to which attribute belongs
             %attr;     Attribute of the reference
             %aggr;     Aggregate memeber(s)
             %aggr-size;Aggregate size(s). Only one of aggr or
                        aggr-size can be specified.
             target     Type of the target entity instance         -->
<!ATTLIST  fwd
            %ent;                                          #IMPLIED
            %attr;                                         #REQUIRED
            %aggr;                                         #IMPLIED
            %aggr-size;                                    #IMPLIED
             target     NMTOKEN                            #IMPLIED  >

<!--                    inv                                        -->
<!--                    Inverse reference                          -->
<!-- Output: a set of instances that reference (are users of)      -->
<!--         the input instance set                                -->
<!-- Child constraints can further restrinct the output set.       -->
<!-- See: ENTITY % constraints                                     -->
<!ELEMENT  inv          %constraints;                                >
<!--         %attr;     Attribute pointing to current entities
             %ent;      Entity to which attribute belongs
             %aggr;     Aggregate memeber(s)
             %aggr-size;Aggregate size(s). Only one of aggr or
                        aggr-size can be specified.                -->
<!ATTLIST  inv
            %attr;                                         #REQUIRED
            %ent;                                          #REQUIRED
            %aggr;                                         #IMPLIED
            %aggr-size;                                    #IMPLIED  >

<!--                    val                                        -->
<!--                    Value of the attribute which is not of
                        instance type. Use fwd for attributes that
                        are entity instances.                      -->
<!-- Output: input instance subset that matches specified value    -->
<!--         constraints or is set if child constraints are        -->
<!--         not specified                                         -->
<!ELEMENT  val          (%comparison-operations; | and | or)         >
<!-- Only %comparison-operations; can be used inside and/or but    -->
<!-- DTD is not restrictive enough                                 -->
<!--         %ent;      Entity to which attribute belongs
             %attr;     Attribute of the reference
             select     Select path
             %aggr;     Aggregate memeber(s)
             %aggr-size;Aggregate size(s). Only one of aggr or
                        aggr-size can be specified.                -->
<!ATTLIST  val
            %ent;                                          #IMPLIED
            %attr;                                         #REQUIRED
             select     NMTOKENS                           #IMPLIED
            %aggr;                                         #IMPLIED
            %aggr-size;                                    #IMPLIED  >

<!--                    intersect                                  -->
<!--                    Intersects resulting entity sets           -->
<!-- Output: intersection of output instance sets that are         -->
<!--         received at the end of each child constraint path     -->
<!ELEMENT  intersect    %constraints-or-group;                       >

<!--                    union                                      -->
<!--                    Unites resulting entity sets               -->
<!-- Output: union of output instance sets that are                -->
<!--         received at the end of each child constraint path     -->
<!ELEMENT  union        %constraints-or-group;                       >

<!--                    and                                        -->
<!--                    And operation on input instances           -->
<!-- Output: input instance subset that matches all                -->
<!--         child constraints                                     -->
<!ELEMENT  and          %constraints-or-group;                       >

<!--                    or                                         -->
<!--                    Or operation on input instances            -->
<!-- Output: input instance subset that matches at least one       -->
<!--         child constraint                                      -->
<!ELEMENT  or           %constraints-or-group;                       >

<!--                    not                                        -->
<!--                    Instances that don't match constrain.      -->
<!-- Output: input instance subset that does not match             -->
<!--         child constraint                                      -->
<!ELEMENT  not          %constraints;                                >
<!-- *************** End constraints ***************               -->

<!-- *************** value comparison ***************              -->
<!-- Comparison operators can be combined using and/or             -->
<!--                    eq                                         -->
<!--                    Equal match.                               -->
<!ELEMENT  eq           (#PCDATA)                                    >

<!--                    neq                                        -->
<!--                    Not equal match.                           -->
<!ELEMENT  neq          (#PCDATA)                                    >
<!-- *************** End value comparison ***************          -->

<!--                    grp                                        -->
<!--                    Group of several constraints as one
                        compound constraint                        -->
<!ELEMENT  grp          %constraints;                                >

<!-- *************** End query ***************                     -->

<!-- Change history: 
     $Log$
     Revision 1.5  2004/12/10 16:25:17  vaidas
     Fixed few issues.

     Revision 1.4  2003/01/24 10:49:12  vaidas
     Fixed typo in comments.

     Revision 1.3  2002/12/12 16:39:45  vaidas
     First real specification.
     Updates from query implementation prototype.
     Comments describing how constraints work added.

     Revision 1.2  2002/12/12 16:32:12  vaidas
     First incomplete draft dated 2002-11-21
-->
