W3C home > Mailing lists > Public > w3c-rdfcore-wg@w3.org > December 2001

RDF/XML Syntax Revised WD for review

From: Dave Beckett <dave.beckett@bristol.ac.uk>
Date: Tue, 11 Dec 2001 17:32:25 +0000
To: w3c-rdfcore-wg@w3.org
Message-ID: <29621.1008091945@tatooine.ilrt.bris.ac.uk>
I attach a copy of the syntax document for your consideration
for publication as a working draft.  I think the following people
were actioned to review it (no minutes as of this date recording it)

  Jeremy Carroll
  Jos De Roo
  Patrick Stickler

but others, feel free :)

The attached files corresponds to CVS version 1.333 of 
  http://ilrt.org/discovery/2001/07/rdf-syntax-grammar/

(CVS http://cvs.ilrt.org/cvsweb/redland/rdfcore/syntax/index.html )

plus the attached relaxng which are for information, not part of
the document, but are intended to be published with the working draft.

I think I need to carry on trying to improve the very new section 2
but it could be published as is.

Dave


#
# RELAX NG Schema (non-XML) for RDF/XML Syntax
#
# This schema is for information only and NON-NORMATIVE
#
# It is based on one originally written by James Clark in
# http://lists.w3.org/Archives/Public/www-rdf-comments/2001JulSep/0248.html
# and updated with later changes.
#

namespace local = ""
namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

start = doc
doc = 
  RDF

RDF =
  element rdf:RDF { nodeElementList }

nodeElementList = 
  nodeElement*

  # Should be something like:
  #  ws* , (  nodeElement , ws* )*
  # but RELAXNG does this by default, ignoring whitespace separating tags.

nodeElement =
  element * - (local:*
               |rdf:RDF
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource
               |rdf:li ) {
      (idAttr | aboutAttr )?, bagIdAttr?, propertyAttr*, propertyEltList
  }

  # FIXME: Not sure if it is possible to say "and not things
  # beginning with _ in the rdf: namespace".

ws = 
  " "

  # Not used in this RELAX NG schema; but should be any legal XML
  # whitespace defined by http://www.w3.org/TR/2000/REC-xml-20001006#NT-S


propertyEltList = 
  propertyElt*

  # Should be something like:
  #  ws* , ( propertyElt , ws* )*
  # but RELAXNG does this by default, ignoring whitespace separating tags.

propertyElt = 
  resourcePropertyElt | 
  literalPropertyElt | 
  parseTypeLiteralPropertyElt |
  parseTypeResourcePropertyElt |
  parseTypeOtherPropertyElt |
  emptyPropertyElt

resourcePropertyElt = 
  element * - (local:*
	       |rdf:RDF|rdf:Description
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, nodeElement
  }

literalPropertyElt =
  element * - (local:*
               |rdf:RDF|rdf:Description
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, text 
  }

parseTypeLiteralPropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseLiteral, literal 
  }

parseTypeResourcePropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseResource, propertyEltList
  }

parseTypeOtherPropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseOther, any
  }

emptyPropertyElt =
   element * - (local:*
                |rdf:RDF|rdf:Description
                |rdf:ID|rdf:about
		|rdf:bagID|rdf:parseType|rdf:resource) {
       (idAttr | resourceAttr)?, bagIdAttr?, propertyAttr* 
   }

idAttr = 
  attribute rdf:ID { 
      IDsymbol 
  }

aboutAttr = 
  attribute rdf:about { 
      URI-reference 
  }

bagIdAttr = 
  attribute rdf:bagID {
      IDsymbol
  }

propertyAttr = 
  attribute * - (local:* 
                 |rdf:RDF|rdf:Description
                 |rdf:ID|rdf:about
		 |rdf:bagID|rdf:parseType|rdf:resource) {
      string
  }

resourceAttr = 
  attribute rdf:resource {
      URI-reference 
  }

parseLiteral = 
  attribute rdf:parseType {
      "Literal" 
  }

parseResource = 
  attribute rdf:parseType {
      "Resource" 
  }

parseOther = 
  attribute rdf:parseType {
      text
  }

URI-reference = 
  string

literal =
  any

IDsymbol = 
  xsd:NMTOKEN

any =
  mixed { element * { attribute * { text }*, any }* }


<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <start>
    <ref name="doc"/>
  </start>
  <define name="doc">
    <ref name="RDF"/>
  </define>
  <define name="RDF">
    <element name="rdf:RDF">
      <ref name="nodeElementList"/>
    </element>
  </define>
  <define name="nodeElementList">
    <zeroOrMore>
      <ref name="nodeElement"/>
    </zeroOrMore>
  </define>
  <define name="nodeElement">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
          <name>rdf:li</name>
        </except>
      </anyName>
      <optional>
        <choice>
          <ref name="idAttr"/>
          <ref name="aboutAttr"/>
        </choice>
      </optional>
      <optional>
        <ref name="bagIdAttr"/>
      </optional>
      <zeroOrMore>
        <ref name="propertyAttr"/>
      </zeroOrMore>
      <ref name="propertyEltList"/>
    </element>
  </define>
  <define name="ws">
    <value> </value>
  </define>
  <define name="propertyEltList">
    <zeroOrMore>
      <ref name="propertyElt"/>
    </zeroOrMore>
  </define>
  <define name="propertyElt">
    <choice>
      <ref name="resourcePropertyElt"/>
      <ref name="literalPropertyElt"/>
      <ref name="parseTypeLiteralPropertyElt"/>
      <ref name="parseTypeResourcePropertyElt"/>
      <ref name="parseTypeOtherPropertyElt"/>
      <ref name="emptyPropertyElt"/>
    </choice>
  </define>
  <define name="resourcePropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <ref name="idAttr"/>
      </optional>
      <ref name="nodeElement"/>
    </element>
  </define>
  <define name="literalPropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <ref name="idAttr"/>
      </optional>
      <text/>
    </element>
  </define>
  <define name="parseTypeLiteralPropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <ref name="idAttr"/>
      </optional>
      <ref name="parseLiteral"/>
      <ref name="literal"/>
    </element>
  </define>
  <define name="parseTypeResourcePropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <ref name="idAttr"/>
      </optional>
      <ref name="parseResource"/>
      <ref name="propertyEltList"/>
    </element>
  </define>
  <define name="parseTypeOtherPropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <ref name="idAttr"/>
      </optional>
      <ref name="parseOther"/>
      <ref name="any"/>
    </element>
  </define>
  <define name="emptyPropertyElt">
    <element>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <optional>
        <choice>
          <ref name="idAttr"/>
          <ref name="resourceAttr"/>
        </choice>
      </optional>
      <optional>
        <ref name="bagIdAttr"/>
      </optional>
      <zeroOrMore>
        <ref name="propertyAttr"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="idAttr">
    <attribute name="rdf:ID">
      <ref name="IDsymbol"/>
    </attribute>
  </define>
  <define name="aboutAttr">
    <attribute name="rdf:about">
      <ref name="URI-reference"/>
    </attribute>
  </define>
  <define name="bagIdAttr">
    <attribute name="rdf:bagID">
      <ref name="IDsymbol"/>
    </attribute>
  </define>
  <define name="propertyAttr">
    <attribute>
      <anyName>
        <except>
          <nsName ns=""/>
          <name>rdf:RDF</name>
          <name>rdf:Description</name>
          <name>rdf:ID</name>
          <name>rdf:about</name>
          <name>rdf:bagID</name>
          <name>rdf:parseType</name>
          <name>rdf:resource</name>
        </except>
      </anyName>
      <data type="string"/>
    </attribute>
  </define>
  <define name="resourceAttr">
    <attribute name="rdf:resource">
      <ref name="URI-reference"/>
    </attribute>
  </define>
  <define name="parseLiteral">
    <attribute name="rdf:parseType">
      <value>Literal</value>
    </attribute>
  </define>
  <define name="parseResource">
    <attribute name="rdf:parseType">
      <value>Resource</value>
    </attribute>
  </define>
  <define name="parseOther">
    <attribute name="rdf:parseType">
      <text/>
    </attribute>
  </define>
  <define name="URI-reference">
    <data type="string"/>
  </define>
  <define name="literal">
    <ref name="any"/>
  </define>
  <define name="IDsymbol">
    <data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" type="NMTOKEN"/>
  </define>
  <define name="any">
    <mixed>
      <zeroOrMore>
        <element>
          <anyName/>
          <zeroOrMore>
            <attribute>
              <anyName/>
              <text/>
            </attribute>
          </zeroOrMore>
          <ref name="any"/>
        </element>
      </zeroOrMore>
    </mixed>
  </define>
</grammar>


Received on Tuesday, 11 December 2001 12:32:33 EST

This archive was generated by hypermail pre-2.1.9 : Wednesday, 3 September 2003 09:43:02 EDT