[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: A non-XML syntax for RELAX NG

  • From: Rick Jelliffe <ricko@a...>
  • To: XML Developers' List <xml-dev@l...>
  • Date: Fri, 17 Aug 2001 20:26:30 +1000

local datatypes xml
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.