|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A non-XML syntax for RELAX NG
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








