DAP4 Commentary: DAP4 Grammar

[Version: 1.0]

At the end of this document are instructions for accessing and testing a formal grammar for the DAP4 DDX using the Relax-NG schema language. I constructed it initially without any reference to any other explicit or implicit grammars so I could record my ideas. I have since modified it based on examining James' implied grammar and from comments from others and from a comparison with the xsd grammar.

Differences with DAP4 xsd Grammar

I converted the xsd grammar to an equivalent relax-ng (rng) grammar.

One major difference I see is in dimension handling.

  • I just used the name "dimension" rather than "shareddimension". For me, all dimensions (except anonymous ones) are shared.

  • The xsd separates out scalars from arrays. I always allowed the dimensions for a variable to be optional to handle the scalar case.

  • I attempted to be as consistent as possible, so I allowed any type including sequences and structures to be dimensioned. (but see previous commentary).

  • The dimensions of a variable are currently specified in the rng grammar as a sequence of elements named "Dimension" contained in the "variables" element type.
Other differences:
  • The Dataset element in the xsd has a couple of extra attributes. I added these.

  • The xsd appears to allow attributes to themselves have attributes. This needs discussion.

  • The URL basetype is in the xsd. But I do not see the justification for keeping it.

  • It appears that the Dataset contains a top level declaration. I chose to treat the Dataset itself as the top-level group.

  • Attribute declarations appear to have their own "namespace" attribute. Not sure why this is needed.

  • I do not understand the purpose of the "NewAttribute" attribute.

  • There may still be some minor differences in representing coordinate variables.

  • The xsd represents attribute values thus:
    <attribute name="a"><value>...</value><value>...</value></attribute>
    I chose to use attributes in the multi-valued case because I prefer not to use elements with content unless really necessary. So I represented the above as this.
    <attribute name="a"><value value="..."/><value value="..."/></attribute>

  • There is an issue of interleaving of definitions, or equivalently, what elements must occur in a fixed order.

  • Where should attributes be legal? I think the rng grammar and the xsd grammar agree on this: putting them almost everywhere, but it needs discussion.
  • I dropped Blobtype. I fail to see the need for this.

 

Testing the Relax-NG Grammar

You will need to copy three files:
  1. dap4.rng - this is the grammar file. it uses the Relax-NG schema language This grammar file can be obtained from http://dl.dropbox.com/u/53929684/dap4.rng.

  2. test.xml - this is a test file that I am growing to cover the whole grammar. This can be obtained from http://dl.dropbox.com/u/53929684/test.xml.

  3. jing.jar - Jing is a validator that takes the grammar and a test file and checks that the test file conforms to the grammar. This can be obtained from http://dl.dropbox.com/u/53929684/jing.jar.
To use this jar file, do the command:

 

java -jar jing.jar dap4.rng test.xml
No output is produced if the validation succeeds, otherwise, error messages are produced.
Comments:

Post a Comment:
  • HTML Syntax: Allowed
Unidata Developer's Blog
A weblog about software development by Unidata developers*
Unidata Developer's Blog
A weblog about software development by Unidata developers*

Welcome

FAQs

News@Unidata blog

Recent Entries:
Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« November 2018
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
       
Today