DAP4: DDX Grammar

From OPeNDAP Documentation
Revision as of 23:05, 21 February 2012 by DennisHeimbigner (talk | contribs)

Version: 1.0

Below is the formal grammar for the DAP4 DXD, version 1.0. I constructed it without any reference to any other explicit or implicit grammars so I could record my proposal.

Now, having looked at the implied grammar in page DAP4: Data Model, I note at least the following differences.

Variable definitions

I use the notation:

<variable name="v1" type="int32">... 

as opposed to using the typename as the element tag.

<Int32 name="v1>...

I actually prefer the second notation, but it potentially interferes with my attempt to provide the equivalent of named user-defined types. That is, I want to give a name to, for example, a structure definition

<structure name="struct">...

so that I can allow that type name to be used in variable

<!-- Relax NG Grammar -->

<!--grammar datatypelibrary="http://opendap.org/DAP4/datatypes.xml"-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<start>
  <element name="dataset">
    <ref name="groupdef"/>
  </element>
</start>

<define name="groupdef">
  <attribute name="name"/>
  <zeroOrMore>
    <element name="attribute"><ref name="attributedef"/></element>
  </zeroOrMore>
  <optional>
    <element name="dimensions">
      <zeroOrMore>
        <element name="dimension"><ref name="dimdef"/></element>
      </zeroOrMore>
    </element>
  </optional>
  <zeroOrMore>
    <element name="variable"><ref name="variabledef"/></element>
  </zeroOrMore>
  <zeroOrMore>
    <element name="group"><ref name="groupdef"/></element>
  </zeroOrMore>
</define>

<define name="dimdef">
    <attribute name="name"/>
    <attribute name="size"/>
    <zeroOrMore>
      <element name="attribute"><ref name="attributedef"/></element>
    </zeroOrMore>
</define>

<define name="variabledef">
  <attribute name="name"/>  
  <zeroOrMore>
    <element name="dimension">
      <attribute name="name"/>
    </element>
  </zeroOrMore>
  <zeroOrMore>
    <element name="coordinatevar">
      <attribute name="name"/> 
    </element>
  </zeroOrMore>
  <choice>
  <attribute name="type"/>
  <element name="structure"><ref name="structuredef"/></element>
  <element name="sequence"><ref name="sequencedef"/></element>
  <element name="grid"><ref name="griddef"/></element>
  </choice>
  <zeroOrMore>
    <element name="attribute"><ref name="attributedef"/></element>
  </zeroOrMore>
</define>

<define name="structuredef">
  <attribute name="name"/>  
  <zeroOrMore>
    <element name="variable"><ref name="variabledef"/></element>
  </zeroOrMore>  
  <zeroOrMore>
    <element name="attribute"><ref name="attributedef"/></element>
  </zeroOrMore>
</define>

<define name="sequencedef">
  <attribute name="name"/>  
  <zeroOrMore>
    <element name="variable"><ref name="variabledef"/></element>
  </zeroOrMore>  
  <zeroOrMore>
    <element name="attribute"><ref name="attributedef"/></element>
  </zeroOrMore>
</define>

<define name="griddef">
  <attribute name="name"/>  
  <element name="array">
    <element name="variable"><ref name="variabledef"/></element>
  </element>
  <element name="maps">
    <zeroOrMore>
      <element name="variable"><ref name="variabledef"/></element>
    </zeroOrMore>  
  </element>
  <zeroOrMore>
    <element name="attribute"><ref name="attributedef"/></element>
  </zeroOrMore>
</define>

<define name="attributedef">
  <attribute name="name"/>
  <attribute name="type"/>
  <optional>
    <attribute name="namespace"/>
  </optional>
  <choice>
    <attribute name="value"/>
    <oneOrMore>
      <element name="value">
        <attribute name="value"/>
      </element>
    </oneOrMore>
  </choice>
</define>

</grammar>