W3C home > Mailing lists > Public > www-rdf-interest@w3.org > January 2002

Too simple, but maybe useful

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 11 Jan 2002 16:15:24 +0000
To: www-rdf-interest@w3.org
Message-ID: <f5b8zb4uan7.fsf@cogsci.ed.ac.uk>
A thread on xmlschema-dev@w3.org, started by Dave Beckett, led me to
the following.

It's a general approach which could serve as the starting point for a
template for anyone wishing to define a document type which provides
for RDF descriptions from a fixed vocabulary.

Please feel from to develop this further, and to forward it to other
appropriate list(s).

Note the example is not completely valid, intentionally -- banana is
not allowed -- it's there to illustrate that lax validation does get
to the embedded Description.

ht

restricted-rdf.xsd:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
                 "http://www.w3.org/2001/XMLSchema.dtd">
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  targetNamespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  <xs:element name="RDF">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="rdf:Description" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>     
    </xs:complexType>
  </xs:element>

  <xs:element name="Description">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="rdf:any" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>     
      <xs:attribute ref="rdf:about" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:attribute name="about" type="anyURI"/>
 
 <xs:element name="any" abstract="true">
  <xs:annotation>
   <xs:documentation>Import this into a schema, and put something into the
       substitution group of rdf:any to get a simple restricted version
       of rdf:RDF</xs:documentation>
  </xs:annotation>
 </xs:element>

</xs:schema>

simple-rdf-example.xml:

<?xml version='1.0'?>
<top xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns="http://purl.org/dc/elements/1.1/"
     xsi:schemaLocation="http://purl.org/dc/elements/1.1/
                       simple-rdf-xmpl.xsd">
 <rdf:RDF>
  <rdf:Description rdf:about="http://www.ltg.ed.ac.uk/~ht/xsv-status.html">
     <creator>Henry S. Thompson</creator>
     <subject>The XSV Schema Validator</subject>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.w3.org/">
    <creator>Tim Berners Lee</creator>
    <subject>
     <rdf:Description>
      <subject>this should break</subject>
      <banana>because this isn't allowed</banana>
     </rdf:Description>
    </subject>
  </rdf:Description>
 </rdf:RDF>
</top>

simple-rdf-example.xsd:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
                 "http://www.w3.org/2001/XMLSchema.dtd">
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        targetNamespace="http://purl.org/dc/elements/1.1/">

 <xs:import namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            schemaLocation="restricted-rdf.xsd"/>

 <xs:element name="top">
  <xs:annotation>
   <xs:documentation>
     Having this in the dc namespace is a bit off.
     At the expense of a further schema doc, it could be in a separate
     NS.
   </xs:documentation>
  </xs:annotation>
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="rdf:RDF"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 
  <xs:element name="any" abstract="true" substitutionGroup="rdf:any"/>

  <xs:element name="title" substitutionGroup="dc:any"/>

  <xs:element name="creator" substitutionGroup="dc:any"/>

  <xs:element name="subject" substitutionGroup="dc:any"/>

  <xs:element name="description" substitutionGroup="dc:any"/>

  <xs:element name="publisher" substitutionGroup="dc:any"/>

  <xs:element name="contributor" substitutionGroup="dc:any"/>

  <xs:element name="date" substitutionGroup="dc:any"/>

  <xs:element name="type" substitutionGroup="dc:any"/>

  <xs:element name="format" substitutionGroup="dc:any"/>

  <xs:element name="identifier" substitutionGroup="dc:any"/>

  <xs:element name="source" substitutionGroup="dc:any"/>

  <xs:element name="language" substitutionGroup="dc:any"/>

  <xs:element name="relation" substitutionGroup="dc:any"/>

  <xs:element name="coverage" substitutionGroup="dc:any"/>

  <xs:element name="rights" substitutionGroup="dc:any"/>
   
</xs:schema>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
Received on Friday, 11 January 2002 11:15:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:51:52 GMT