Re: Clarifying RDF #2: a Schematron schema

 From: "Jonathan Borden" <jborden@mediaone.net>

> Rick Jelliffe wrote:

> > I wonder how they wrote their RELAX schema (and also Michael's XML
Schema
> > schema).
>
> Err, "they" meaning I ...

Oops, sorry about that.  I did not mean to be rude or offhand; I had
forgotten that Jonathan wrote that
RELAX schema, not the RELAX group.

> ...simply:
>
> 1) sat down with a text editor, a copy of the RDF 1.0 M&S rec in one
window
> and a copy of the latest RELAXNG draft/tutorial in another window.
> 2) went through the M&S EBNF productions in section 6 in turn and
converted
> each production into RELAXNG.
> 3) used James Clark's validator against a few test cases and fixed the
> patterns until I didn't get any errors.

How does your grammar handle rdf:Property?   It is defined in RDFS
but put in the RDF namespace.  It makes sense, if one assumes that there
is _no_ schema for RDF and so one can pick any noun from the RDF
spec, and make an element from it in the RDF namespace, since then
one is saying "the X thing as defined in RDF".  (Well, since RDFS is
a W3C RDF activity, it is hardly "one", and I know Dan thinks RDF
and RDFS are intertwined, but this is the kind of practical difficulty I
faced when trying to figure out schemas.)

For example, does your RELAX schema handle the following RDFS-spec
fragment (from RDFS  7.1)?

<rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

<rdfs:Class rdf:ID="Person">
  <rdfs:comment>The class of people.</rdfs:comment>
  <rdfs:subClassOf
rdf:resource="http://www.w3.org/2000/03/example/classes#Animal"/>
</rdfs:Class>

<rdf:Property ID="maritalStatus">
  <rdfs:range rdf:resource="#MaritalStatus"/>
  <rdfs:domain rdf:resource="#Person"/>
</rdf:Property>

<rdf:Property ID="ssn">
  <rdfs:comment>Social Security Number</rdfs:comment>
  <rdfs:range
rdf:resource="http://www.w3.org/2000/03/example/classes#Integer"/>
  <rdfs:domain rdf:resource="#Person"/>
</rdf:Property>

<rdf:Property ID="age">
  <rdfs:range
rdf:resource="http://www.w3.org/2000/03/example/classes#Integer"/>
  <rdfs:domain rdf:resource="#Person"/>
</rdf:Property>

<rdfs:Class rdf:ID="MaritalStatus"/>

<MaritalStatus rdf:ID="Married"/>
<MaritalStatus rdf:ID="Divorced"/>
<MaritalStatus rdf:ID="Single"/>
<MaritalStatus rdf:ID="Widowed"/>

</rdf:RDF>

> > If they just rewrote my earlier DTD from 1999, they cannot be very good
> :-)
>
> DTDs are quite inadequate for capturing RDF syntax in any meaninful way
for
> a variety of reasons.

I disagree: I think the DTD I provide gives just as much help as most other
DTDs for other
languages can.

> The EBNF in the RDF 1.0 spec is also inadequate

Here here.

>  > ... But they both
> > share the same problem as DTDs: one needs to enumerate the element names
> > explicitly in the schema for all intents and purposes.
>
> err, no. not for RELAXNG

By "for all intents and purposes" I don't mean *:something nor something:*,
but regular-expressions inside of name parts, such as rdf:_*, which is where
the enumeration issue comes in for RDF. As you put it later:

> To me, a regular expression is a "pattern" which is why I was interested
to
> see if a tree regular expression can express XML patterns (i.e. RDF). With
> the sole exception of the ability to constrain element or attribute
_names_
> to the pattern "rdf:_1 ... rdf:_n" it seems to work surprisingly well.

I don't think we are disagreeing; pardon my clumsy expression.

> The question for the WG, which is why I will cc: rdf-comments, is what the
> role of such constraints on these names ought to be, for example a
container
> can have other properties than those named _n etc. This is an issue still
> under discussion. Similarly test cases that require such a constraint will
> fail under this schema.

Actually, the name of the rdf attribute is *never* written _n, because under
XML production 41, a name can never start with a _ character.  So it always
must be qualified and prefixed in any instance, even if when used on an
element which
already has a namespace qualifier.  This is unlike other rdf: attributes,
which
(as far as I can make out, and this is what my DTD is trying to capture)
act as if there is some rule that "if an attribute is used on an rdf:
qualified element,
it must not be prefixed, but if it is not it must be prefixed, unless it is
a _n
attribute, in which case it must always be prefixed."

That is the kind of rule which some spec should say somewhere, since that
seems to be the rule used.

> Another reason I like the RELAXNG schema is that they (being James Clark
and
> the TC) have produced a formal semantics for the language, which I suspect
> may help in the formal definition of the RDF language.

Yes, it is a great attempt to make grammars work better.

Cheers
Rick Jelliffe

Received on Wednesday, 20 June 2001 10:41:49 UTC