WD-rdf-syntax-grammar-20010906 in RELAX NG

I translated the grammar in WD-rdf-syntax-grammar-20010906 into RELAX NG.
Here it is in my RELAX NG non-XML syntax
(http://www.thaiopensource.com/relaxng/nonxml/):

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

start = RDF
RDF = element rdf:RDF { node* } | node
node = description | typedNode
description = element rdf:Description {
                idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
              }
typedNode = element * - (local:*|rdf:*) {
              idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
            }
propertyElt = element * - (local:*|rdf:*) {
                (idAttr?, (node
                           | string
                           | (parseLiteral, literal)
                           | (parseResource, propertyElt*)
                           | (parseOther, any)
                           | (bagIdAttr?, propertyAttr*)))
                 | (resourceAttr, bagIdAttr?, propertyAttr*)
              }
idAboutAttr = idAttr | aboutAttr | aboutEachAttr
idAttr = attribute rdf:ID { IDsymbol }
aboutAttr = attribute rdf:about { URI-reference }
aboutEachAttr = attribute rdf:aboutEach { URI-reference }
bagIdAttr = attribute rdf:bagID { IDsymbol }
propertyAttr = typeAttr | propAttr
propAttr = attribute * - (local:*|rdf:*) { string }
typeAttr = attribute rdf:type { URI-reference }
resourceAttr = attribute rdf:resource { URI-reference }
parseLiteral = attribute rdf:parseType { "Literal" }
parseResource = attribute rdf:parseType { "Resource" }
parseOther = attribute rdf:parseType { token - ("Literal"|"Resource") }
URI-reference = string
IDsymbol = xsd:NMTOKEN
literal = any
any = mixed { element * { attribute * { text }*, any }* }

You can translate this into RELAX NG proper using the tool on the above Web
page.

With typedNode, propertyElt and propAttr, the WD actually specifies any
namespace URI is allowed.  I'm guessing that the intention is actually to
allow any namespace URI other than the absent namespace URI and the RDF
namespace URI.  Maybe this is supposed to be handled by the requirement in
the spec that in A|B priority is given to A.  I would strongly suggest that
this priority concept is not a good idea.  I think that making this rigorous
would be hard and would require getting into procedural details of the
parsing process, which it would be far better to avoid.

The grammar in the WD allows a typedNode to have an rdf:type attribute.  Is
that intentional?

James

Received on Monday, 17 September 2001 01:17:00 UTC