[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A non-XML syntax for RELAX NG
- From: Rick Jelliffe <ricko@allette.com.au>
- To: XML Developers' List <xml-dev@lists.xml.org>
- Date: Fri, 17 Aug 2001 20:26:30 +1000
Another approach would be to have a mixed syntax with the content model and names using
an abbreviated syntax, but XML elements elsewhere (i.e. mixed content). That would
still allow terseness (people can write in terms of content models), allow nice formating
with a stylesheet and ids.
<grammar xmlns="slightlyRelaxed">
<prolog>
<defaultNamespace rng = "http://relaxng.org/ns/structure/0.9"/>
<namespace local = "" />
<datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" />
</prolog>
<rules>
<start>pattern</pattern>
<rule for="pattern">
<element name="element">(nameQName | nameClass), (common & pattern+)</element>
| <element name="attribute>(nameQName | nameClass), (common & pattern?)</element>
| <element name="group|interleave|choice|optional
|zeroOrMore|oneOrMore|list|mixed">common & pattern+</element>
| <element name="ref|parentRef">nameNCName, common </element>
| <element name="empty|notAllowed|text">common </element>
| <element name="data">type, param*, (common & exceptPattern?) </element>
| <element name="value">commonAttributes, type?, xsd:string </element>
| <element name="externalRef">href, common </element>
| <element name="grammar">common & grammarContent* </element>
</rule>
<rule for="param">
<element name="param">commonAttributes, nameNCName, xsd:string</element>
</rule>
<rule for="exceptPattern">
<element name="excep">common & pattern+ </element>
</rule>
<rule for="grammarContent">
definition
| <element name="div">common & grammarContent* </element>
| <element name="include">href, (common & includeContent*) </element>
</rule>
<rule for="includeContent">
definition
| <element name="div">common & includeContent* </element>
</rule>
<rule for="definition">
<element name="start">combine?, (common & pattern+) </element>
| <element name="define">nameNCName, combine?, (common & pattern+) </element>
</rule>
<rule for="combine">
<attribute name="combine">"choice" | "interleave" </attribute>
</rule>
<rule for="nameClass">
<element name="name">commonAttributes, xsd:QName</element>
| <element name="anyName">common & exceptNameClass?</element>
| <element name="nsName">common & exceptNameClass?</element>
| <element name="choice">common & nameClass+ </element>
</rule>
<rule for="exceptNameClass">
<element name="except">common & nameClass+</element></rule>
<rule for="nameQName">
<attribute name="name">xsd:QName </attribute></rule>
<rule for="nameNCName">
<attribute name="name">xsd:NCName </attribute></rule>
<rule for="href">
<attribute name="href">xsd:anyURI </attribute></rule>
<rule for="type">
<attribute name="type">xsd:NCName </attribute></rule>
<rule for="common">commonAttributes, foreignElement*</rule>
<rule for="commonAttributes">
<attribute name="ns">xsd:anyURI</attribute>?,
<attribute name="datatypeLibrary">xsd:anyUR</attribute>?,
foreignAttribute*</rule>
<rule for="foreignElement">
<element name="* - rng:*">(anyAttribute | text | anyElement)* </element></rule>
<rule for="foreignAttribute">
<attribute name="* - (rng:*|local:*)">text </attribute></rule>
<rule for="anyElement">
<element name="*">(anyAttribute | text | anyElement)*</element></rule>
<rule for="anyAttribute">
<attribute name="*">text </attribute></rule>
</rules>
</grammar>
Cheers
Rick Jelliffe