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

Based on your response, I'm including below my current best guess at a RELAX
NG schema for RDF.

The special treatment of rdf:type in propertyAttr now sticks out like a sore
thumb.  It seems very strange to distinguish it as a attribute name but name
as an element name.  I think it would be far cleaner to have rdf:type be
treated the same as any other non-syntactic RDF name (as I think you
suggested in an earlier message).

> Have you any thoughts on how to do
> the mapping to RDF statements with RelaxNG?

My knowledge of RDF is fairly superficial, but the general approach I would
suggest would be to identify a minimal subset of the syntax that is
suffificient to express any triple and can be mapped straightforwardly onto
triples, specify that syntax using RELAX NG, and then specify how to
transform the full syntax into this minimal subset.

Anyway here's the schema in non-XML format. This handles correctly the test
cases in the current test case zip file with the exception of
rdfms-difference-between-ID-and-about/error1.rdf, which requires detection
of duplicate IDs. (The problem here is that rdf:ID is specified as an
NMTOKEN.  RELAX NG DTD compatibility provides support for XML 1.0 compatible
IDs, but these have to be NCNames in accordance with the Namespaces Rec.)  I
have also attached the generated proper RELAX NG XML syntax.

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 { attribute xml:base { URI-reference }?, node* } |
node
node = description | typedNode
description = element rdf:Description {
                idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
              }
typedNode = element * - (local:*
                         |rdf:Description|rdf:RDF
                         |rdf:ID|rdf:about|rdf:aboutEach
                         |rdf:bagID|rdf:parseType|rdf:resource) {
              idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
            }
propertyElt = element * - (local:*
                           |rdf:Description|rdf:RDF
                           |rdf:ID|rdf:about|rdf:aboutEach
                           |rdf:bagID|rdf:parseType|rdf:resource) {
                (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:type|rdf:li
                          |rdf:Description|rdf:RDF
                          |rdf:ID|rdf:about|rdf:aboutEach
                          |rdf:bagID|rdf:parseType|rdf:resource) {
             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 }* }

James

Received on Tuesday, 18 September 2001 03:05:46 UTC