Here is a first cut of a RelaxNG grammer for QMF Schemas. It includes a
couple of enhancements I would like to see to support code generation..
so I added them in to get comments. Specifically:
- class elements carry the hash value for the class.
- class elements have an extends element to denote a super type.
- created an outer element to make xml parsers happy.
Please take a look and let me know what you guys think.
-- bk
<?xml version="1.0"?>
<!--
Grammer for the AM3 version of the QMF Schema
-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="schemas" />
</start>
<define name="schemas">
<element name="schemas">
<zeroOrMore>
<ref name="schema" />
</zeroOrMore>
</element>
</define>
<define name="schema">
<element name="schema">
<attribute name="package">
<text />
</attribute>
<optional>
<attribute name="description">
<text />
</attribute>
</optional>
<zeroOrMore>
<ref name="class" />
</zeroOrMore>
</element>
</define>
<define name="class">
<element name="class">
<attribute name="name">
<text />
</attribute>
<attribute name="hash">
<data type="string">
<param name="pattern">[a-fA-F0-9]{8}\-[a-fA-F0-9]{8}\-[a-fA-F0-9]{8}\-[a-fA-F0-9]{8}</param>
</data>
</attribute>
<!-- extends is a class key package:class(hash) -->
<optional>
<attribute name="extends">
<data type="string">
<param name="pattern">[A-Za-z0-9_\.]+:[A-Za-z0-9_]+\([a-fA-F0-9]{8}-[a-fA-F0-9]{8}-[a-fA-F0-9]{8}-[a-fA-F0-9]{8}\)</param>
</data>
</attribute>
</optional>
<optional>
<attribute name="description">
<text />
</attribute>
</optional>
<interleave>
<zeroOrMore>
<ref name="method" />
</zeroOrMore>
<zeroOrMore>
<ref name="property" />
</zeroOrMore>
<zeroOrMore>
<ref name="statistic" />
</zeroOrMore>
</interleave>
</element>
</define>
<define name="method">
<element name="method">
<attribute name="name">
<text />
</attribute>
<optional>
<attribute name="description">
<text />
</attribute>
</optional>
<zeroOrMore>
<ref name="arg" />
</zeroOrMore>
</element>
</define>
<define name="arg">
<element name="arg">
<interleave>
<ref name="commonVariable" />
<attribute name="dir">
<choice>
<value>I</value>
<value>O</value>
<value>IO</value>
</choice>
</attribute>
</interleave>
</element>
</define>
<define name="property">
<element name="property">
<interleave>
<ref name="commonVariable" />
<attribute name="optional">
<choice>
<value>True</value>
<value>False</value>
</choice>
</attribute>
<attribute name="access">
<choice>
<value>ReadCreate</value>
<value>ReadWrite</value>
<value>ReadOnly</value>
</choice>
</attribute>
</interleave>
</element>
</define>
<define name="statistic">
<element name="statistic">
<ref name="commonVariable" />
</element>
</define>
<define name="commonVariable">
<interleave>
<attribute name="name">
<text />
</attribute>
<optional>
<attribute name="description">
<text />
</attribute>
</optional>
<attribute name="type">
<choice>
<value>uint8</value>
<value>uint16</value>
<value>uint32</value>
<value>uint64</value>
<value>bool</value>
<value>short-string</value>
<value>long-string</value>
<value>abs-time</value>
<value>delta-time</value>
<value>reference</value>
<value>boolean</value>
<value>float</value>
<value>double</value>
<value>uuid</value>
<value>field-table</value>
<value>int8</value>
<value>int16</value>
<value>int32</value>
<value>int64</value>
<value>object</value>
<value>list</value>
<value>array</value>
</choice>
</attribute>
<optional>
<attribute name="refPackage">
<data type="string">
<param name="pattern">[A-Za-z0-9_\.]+</param>
</data>
</attribute>
</optional>
<optional>
<attribute name="refClass">
<data type="string">
<param name="pattern">[A-Za-z0-9_]+</param>
</data>
</attribute>
</optional>
<optional>
<attribute name="unit">
<text />
</attribute>
</optional>
<optional>
<attribute name="min">
<data type="int" />
</attribute>
</optional>
<optional>
<attribute name="max">
<data type="int" />
</attribute>
</optional>
<optional>
<attribute name="maxlen">
<data type="int" />
</attribute>
</optional>
</interleave>
</define>
</grammar>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]