<?xml version="1.0" encoding="Windows-1250" ?>
<!--

  History: 2005-03-08 string[@maxlength]
           2005-03-09 +oop features (class,interface,iref,cref)
                      +collections
                      set (typo fixed)

-->
<schema xmlns     = "http://schemas.rozsnyo.com/schema"
        namespace = "http://schemas.rozsnyo.com/mdfs/type"
        desc      = "Definition of datatypes in the XML programming for MDFS">

  <!-- USER DATA TYPES -->

  <element id="typedef" type="elements" desc="Registration of a type under user defined identifier">
   <list>Any type</list>
   <string id="id" uniq="global" />
  </element>

  <elementlist id="Any type" desc="All data types defined in the schema">
   <elem>function</elem>
   <elem>class</elem>
   <elem>interface</elem>
   <list>Expression</list>
  </elementlist>

  <elementlist id="Expression" desc="Data type which can be found in the semantic tree of an expression">
   <list>Simple data type</list>
   <list>Extended data type</list>
   <list>OOP expression</list>
  </elementlist>

  <elementlist id="Simple data type" desc="The basic data types">
   <elem>bool</elem>
   <elem>enum</elem>
   <elem>numeric</elem>
   <elem>text</elem>
   <elem>character</elem>
   <elem>date</elem>
   <elem>time</elem>
   <elem>datetime</elem>
   <elem>timestamp</elem>
  </elementlist>

  <elementlist id="Extended data type" desc="Extended data types - operators applied to another data types">
   <elem>optional</elem>
   <elem>set</elem>
   <elem>array</elem>
   <elem>map</elem>
   <elem>list</elem>
   <elem>container</elem>
   <elem>struct</elem>
   <elem>collection</elem>
  </elementlist>

  <elementlist id="OOP expression" desc="Object oriented resources">
   <elem>cref</elem>
   <elem>iref</elem>
  </elementlist>

  <!-- SIMPLE DATA TYPES -->

    <!-- BOOL -->
    <element id="bool" type="none" desc="Boolean value" />

    <!-- ENUM -->
    <element id="enum" type="elements" desc="Enumerated value">
     <elem>option</elem>
    </element>

    <element id="option" type="text" desc="An option in the enumeration" />

    <!-- NUMERIC -->
    <element id="numeric" abstract="1" desc="Abstraction over the numeric types">
<!--
     FORMATING SHOULD BE IMPLEMENTED HERE?

     <integer id="width"     null="1" desc="Number width in characters" />
     <integer id="decimals"  null="1" desc="Number of numbers after the decimal separator" />
     <boolean id="fillzeros" null="1" desc="Fill the output with zeros or spaces" />
     <enum    id="cut"       null="1" desc="Alignment settings" list="Number cutting" />
     <integer id="base"      null="1" desc="Base, minimal is 2, max. is 36 (as 10 numbers and 26 letters)" />
     <boolean id="uppercase" null="1" desc="Hexadecimal characters should be uppercase or lowercase?" />
     <integer id="intgroup"  null="1" desc="Integer part grouping, use 3 for normal numbers, 4 for hexadecimal and so on" />
     <string  id="decsep"    null="1" desc="Decimal separator, usually a comma or a dot" />
     <string  id="intsep"    null="1" desc="Separator of the integer part, usually space or a dot" />
     <string  id="continue"  null="1" desc="When the cutting is applied, this text must appear in the output, e.g. &quot;...&quot;" />
-->
    </element>

<!--
    <valuelist id="Number cutting" desc="A flag representing the alignment and the more important side of a string">
     <value desc="The output can be longer than width">no</value>
     <value desc="Cut the left characters, also means aligning to right">left</value>
     <value desc="Cut the right characters, also means aligning to left">right</value>
    </valuelist>
-->

    <element id="int" type="none" desc="Generic integer number" extends="numeric">
     <integer id="size"   null="1" desc="The size of the number in bits (with the sign bit)" />
     <boolean id="signed" null="1" desc="Is the number signed?" />
     <boolean id="autoincrement" null="1" default="0" desc="Automatically incremented value" />
    </element>

    <element id="range" type="none" desc="Integer number from a specified range" extends="numeric">
     <integer id="min" desc="The lowest value from the range" />
     <integer id="max" desc="The highest value from the range" />
    </element>

    <element id="float" type="none" desc="Generic floating point number" extends="numeric">
     <enum id="size" null="1" list="Float size" desc="Precision requirement, size in bits" />
    </element>

    <valuelist id="Float size" desc="Standardized lengths of the floating point data (by IEEE)">
     <!-- descriptions taken from http://webster.cs.ucr.edu/AoA/Windows/HTML/MoreDataRepresentation.html -->
     <value desc="Single precision">32</value>
     <value desc="Double precision">64</value>
     <value desc="Extended precision">80</value>
    </valuelist>

    <!-- STRING -->
    <element id="text" type="none" abstract="1" desc="Abstract element which implements the common attributes of the strings">
     <enum id="char" null="1" list="Character size" />
     <integer id="size" null="1" desc="Length limit for a string - in characters (not the 0 in asciiz)" />
     <reference id="charset" null="1" list="Character set" refns="http://schemas.rozsnyo.com/mdfs/charset" ref="charset" />
    </element>

    <valuelist id="Character size" desc="Choices for the size of the character in a string">
     <value desc="Standard characters (8 bit)"  >ansi</value>
     <value desc="Multibyte characters (16 bit)">wide</value>
    </valuelist>

    <element id="asciiz" extends="text" desc="Zero ended string, can not contain zero value" />
    <element id="string" extends="text" desc="An universal string type, can store any data in the selected character set" />

    <!-- CHARACTERS -->
    <element id="character" type="none" abstract="1">
     <reference id="charset" null="1" list="Character set" refns="http://schemas.rozsnyo.com/mdfs/charset" ref="charset" />
    </element>

    <element id="ansichar" desc="An 8 bit character" extends="character" />
    <element id="widechar" desc="A 16 bit character" extends="character" />

    <!-- DATE AND TIME -->
    <element id="date" type="none" desc="Date in a CCYY-MM-DD form">
     <enum id="precision" null="1" default="day" list="Date precision" />
    </element>

      <valuelist id="Date precision">
       <value desc="CC"        >century</value>
       <value desc="CCYY"      >year</value>
       <value desc="CCYY-MM"   >month</value>
       <value desc="CCYY-MM-DD">day</value>
      </valuelist>

    <element id="time" type="none" desc="Time in a HH:MM:SS form">
     <enum id="precision" null="1" default="second" list="Time precision" />
    </element>

      <valuelist id="Time precision">
       <value desc="HH"          >hour</value>
       <value desc="HH:MM"       >minute</value>
       <value desc="HH:MM:SS"    >second</value>
       <value desc="HH:MM:SS.MMM">milisecond</value>
      </valuelist>

    <element id="datetime" type="none" desc="Time in a CCYY-MM-DD HH:MM:SS form">
     <enum id="precision" null="1" default="second" list="DateTime precision" />
    </element>

      <valuelist id="DateTime precision">
       <value desc="CC"                     >century</value>
       <value desc="CCYY"                   >year</value>
       <value desc="CCYY-MM"                >month</value>
       <value desc="CCYY-MM-DD"             >day</value>
       <value desc="CCYY-MM-DD HH"          >hour</value>
       <value desc="CCYY-MM-DD HH:MM"       >minute</value>
       <value desc="CCYY-MM-DD HH:MM:SS"    >second</value>
       <value desc="CCYY-MM-DD HH:MM:SS.MMM">milisecond</value>
      </valuelist>

    <element id="timestamp" type="none" desc="Time in a UNIX timestamp form" />

  <!-- FUNCTIONAL TYPE -->

    <!-- FUNCTIONS -->
    <element id="function" type="elements" desc="Function prototype">
     <elem max="1">return</elem>
     <elem>parameter</elem>
    </element>

    <element id="return" type="elements" max="1" desc="Return type of the function">
     <list>Expression</list>
    </element>

    <element id="parameter" type="elements" max="1" desc="A function parameter specification">
     <list>Expression</list>
     <string id="id" uniq="local" desc="Parameter name" />
    </element>

  <!-- EXTENDED DATA TYPES -->

    <element id="optional" type="elements" min="1" max="1" desc="Optional value">
     <list>Expression</list>
     <enum id="hint" list="Implementation hint" null="1" desc="How should be the type implemented?" />
    </element>

        <valuelist id="Implementation hint" desc="Implementation hint for optional extension">
         <value desc="Implement as a dynamically allocated value"  >pointer</value>
         <value desc="Implement as a structure with a boolean flag">flag</value>
        </valuelist>

    <element id="set" type="elements" min="1" max="1" desc="Make a set from an enumerated value">
     <elem>enum</elem>
    </element>

    <element id="array" type="elements" min="1" max="1" desc="Definition of constant sized array">
     <list>Expression</list>
     <integer id="min"  null="1" desc="The first item's ID" default="0" />
     <integer id="max"  null="1" desc="The last item's ID"  />
     <integer id="size" null="1" desc="The number of items (optional, if you use this, then use only one of the min/max)" />
    </element>

    <element id="map" type="elements" desc="Mapping of a simple type to another value">
     <elem min="1" max="1">index</elem>
     <elem min="1" max="1">value</elem>
    </element>

        <element id="index" type="elements" min="1" max="1" desc="Index to a map">
         <list>Simple data type</list>
        </element>

        <element id="value" type="elements" min="1" max="1" desc="Type of the value stored in a map">
         <list>Expression</list>
        </element>

    <element id="list" type="elements" min="1" max="1" desc="Linked list">
     <list>Expression</list>
     <boolean id="bidirectional" null="1" default="0" desc="Is the list bidirectional or unidirectional?" />
    </element>

    <element abstract="1" id="container" type="elements" min="1" max="1" desc="An abstract representation of stacks and buffers">
     <list>Expression</list>
     <integer id="size" null="1" desc="Maximal number of the items - limit" />
     <enum id="overflow" null="1" default="ignore" desc="Action taken when the limit is reached" list="Container overflow" />
    </element>

        <valuelist id="Container overflow">
         <value desc="Causes a fatal error"                                         >die</value>
         <value desc="Raises an exception"                                          >exception</value>
         <value desc="Ignores the writing command, so the content is protected"     >ignore</value>
         <value desc="Discards the last value and writes the new into the container">overwrite</value>
        </valuelist>

        <element extends="container" id="stack"  desc="A stack with push/pop operations" />
        <element extends="container" id="buffer" desc="A buffer with put/get operations" />

    <element id="struct" type="elements" desc="Structure definition">
     <elem min="1">elem</elem>
    </element>

        <element id="elem" type="elements" min="1" max="1" desc="Named structure element">
         <list>Expression</list>
         <string id="id" uniq="local" desc="Name of the element of a structure" />
         <boolean id="key" null="1" default="0" desc="Is the element a key for the nearest parent class/array?" />
        </element>

  <!-- OOP -->

    <!-- INTERFACES -->
    <element id="interface" type="elements" desc="Interface definition">
     <elem>icElement</elem>
     <string id="id" uniq="global" desc="Name of the interface" />
     <reference id="extends" null="1" desc="The base interface" ref="interface" />
    </element>

        <element id="icElement" abstract="1">
         <string id="id" uniq="local" desc="Name of the interface/class element" />
         <enum id="visibility" list="Class Item Visibility" null="1" defalt="public" />
        </element>

            <valuelist id="Class Item Visibility">
             <value desc="Can be accessed from any place">public</value>
             <value desc="Can be accessed from a descendant class">protected</value>
             <value desc="Can be accessed only from the current class">private</value>
            </valuelist>

            <element id="attribute" type="elements" min="1" max="1" desc="Named interface/class element" extends="icElement">
             <list>Expression</list>
             <boolean id="key" null="1" default="0" desc="Is the element in the primary key of the class?" />
            </element>

            <element id="method" type="none" desc="A method in an interface" extends="icElement">
             <string id="id" uniq="local" desc="Name of the method" />
             <reference id="type" desc="Reference to a type which is a function" ref="typedef" />
            </element>

    <!-- CLASSES -->
    <element id="class" type="elements" desc="Class definition">
     <elem>icElement</elem>
     <string id="id" uniq="global" desc="Name of the class" />
     <reference id="extends" null="1" desc="The base class" ref="class" />
     <boolean id="abstract" null="1" default="0" desc="Force the class to be abstract" />
     <boolean id="final" null="1" default="0" desc="Force the class to be final (can't be extended)" />
    </element>

    <!-- REFERECES -->
    <element id="iref" type="text" desc="A reference to an interface" ref="interface" />
    <element id="cref" type="text" desc="A reference to a class" ref="class" />

    <element id="collection" type="elements" min="1" max="1" desc="A collection of objects from the same class/interface">
     <list>Expression</list>
     <boolean id="ordered"  null="1" default="0" desc="Is the order important?" />
     <boolean id="multiple" null="1" default="0" desc="Can the object be present more than once?" />
    </element>

</schema>

