Re: New syntax spec

 From: "Dave Beckett" <dave.beckett@bristol.ac.uk>
 
 
> > Also, I am confused. I thought the RDF WG had made rdf:_n elements,
> > but even the 6.31 attributes are removed. Is that correct?
> 
> The rdf:_<n> etc. attribute forms match the propAttr production and
> generate properties just like any other propAttr property.  They
> don't need to be a special case.  rdf:li as an *attribute* is a
> special case, which will need to be considered, and we have a
> decision:
 
Ah, so you are not defining the namespace for RDF in this "grammar".

That is pretty much opposite what I think is useful for validation:
the first thing I want to know for validation is "have I spelled the
element (and attribute) names correctly?"  

It is only a matter of clarifying what the "grammar" is supposed to do:
in this case, it is to define the infoset of an XML document, but not
define the namespace.  

Cheers
Rick Jelliffe

P.S. Here is a beta version of the validator for the refactored RDF,
which may help moving documents from the old syntax to the refactored syntax.  
You can use it with the Topologi Schematron Validator 
http://www.topologi.com/ for example.   I have been testing it with the
new test cases: this is very good, in the absense of a real schema.

-----------------------------------
<?xml version="1.0" ?>
<!--
 Copyright (c) 2001 Rick Jelliffe, Topologi Pty/ Ltd 

 This software is provided 'as-is', without any express or implied warranty. 
 In no event will the authors be held liable for any damages arising from 
 the use of this software.

 Permission is granted to anyone to use this software for any purpose, 
 including commercial applications, and to alter it and redistribute it freely,
 subject to the following restrictions:

 1. The origin of this software must not be misrepresented; you must not claim
 that you wrote the original software. If you use this software in a product, 
 an acknowledgment in the product documentation would be appreciated but is 
 not required.

 2. Altered source versions must be plainly marked as such, and must not be 
 misrepresented as being the original software.

 3. This notice may not be removed or altered from any source distribution.

-->
<schema xmlns="http://www.ascc.net/xml/schematron"
 xml:lang="en" 
 schemaVersion="2001/09/07" 
 >
   <title>Resource Description Framework (RDF and RDFS) in XML</title>
   <ns prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
   <ns prefix="rdfs" uri="http://www.w3.org/2000/01/rdf-schema#" />
   <p>The Resource Description Framework is the cornerstone
   of the W3C's Semantic Web Activity. This schema gives some
   constraints for XML data validation purposes.
   </p>
   
<p>This schema will valiate RDF elements and attributes
according to the "re-factored" syntax of
http://www.w3.org/TR/2001/WD-rdf-syntax-grammar-20010906/</p>
   <phase id="basic">
    <active pattern="elements"/>
    <active pattern="aboutAttributes"/>
    <active pattern="parseType"/>
   </phase>

   <pattern name="elements" >
      <rule id="RDF" context="rdf:RDF">
          <assert test="count(ancestor::*) =0">The rdf:RDF element can only appear at the top-level
           </assert>
          <report test="@rdf:*">An rdf:* attribute cannot go on rdf:RDF.</report>
      </rule>

     <rule id="obsolete" context="rdf:Bag | rdf:Set | rdf:Alt | rdf:li ">
        <report test="true()">The Bag, Set, Alt and li elements are obsolete.</report>
     </rule>
     
     <rule id="noAbbrev" context="rdf:*[starts-with('_', local-name())]">
        <report test="true()">This schema does not handle the abbreviated syntax.</report>
     </rule>

      <rule id="otherElements" context="*[ancestor::*[@rdf:parseType='parseOther']]">
           <assert test="rdf:* or *[@rdf:*]">Any rdf elements or attributes inside a parseOther section
            are not significant to the RDF document as rdf markup.</assert> 
      </rule>

      <rule id="descriptionElement" context="/* |  /rdf:RDF/* | rdf:Description |  *[not(@parseType)]/*">
              <assert test="true()">A description element can appear at the top-level,
              as the child of rdf:RDF, or the child of a property element with no parseType.
              </assert>
              <report test="@rdf:resource or @rdf:parseType"
                >Only property elements can have resource attributes or parseTypes</report>
      </rule>

      <rule id="propertyElement" context="/*/* | /rdf:RDF/*/* | rdf:Description/* | *[not(@parseType)]/*/*
          | *[normalize-space(@parseType)='Resource']/*  ">
            <assert test="true()">A property element appears as the child of a description element
                 or the child of an element with parseType of "Resource"</assert>
          <report test="rdf:bagID">A property element should not have any bagIDs.</report>
          <!--report test="??">A property element should not have any property attributes.</report-->
         <assert test="* or @rdf:resource"
       >A property element such as <name/> must either
       contain its resource or give them in a resource
       rdf:resource) attribute.</assert>

      </rule>

      <rule id="rdf-error" context="rdf:*">
             <report test="rdf:*">The only elements in the RDF namespace are RDF and Description         
            </report> 
      </rule>

      <rule id="error" context="*">
             <report test="*">This element is incorrect.</report> 
      </rule>
    </pattern>

   <pattern name="idAttributes" >
   <rule abstract="true" id="idCheck">
      <assert test="count(//*[@rdf:ID=current()/@rdf:ID])=1"
      >The rdf:ID attribute should have unique token values in a document.</assert>
   </rule>
   <rule abstract="true" id="bagIdCheck">   
    <assert test="count(//*[@rdf:bagID=current()/@rdf:bagID])=1"
    >The rdf:bagID attribute should have unique token values in a document.</assert>
   </rule>
   
   <rule context="*[@rdf:ID][@rdf:bagID]">
    <extends rule="idCheck"/>
    <extends rule="bagIdCheck" />
   </rule>
   
   <rule context="*[@rdf:ID]">
    <extends rule="idCheck"/>
   </rule>
   
   <rule context="*[@rdf:bagID]">
    <extends rule="bagIdCheck" />
   </rule>
  </pattern>
  
  <pattern name="parseType">
    <rule context="*[@parseType]">
  <report test="self::*[ @rdf:parseType='resource' or @rdf:parseType='literal' 
   or @rdf:parseType='RESOURCE' or @rdf:parseType='LITERAL' ]"
   diagnostics="checkSpelling"
   >The parseType attribute in a <name/> should be spelled either 'Literal' or 'Resource'.</report>
  <report test="self::*[@rdf:parseType='Literal']/*"
   >If the parseType attribute is 'Literal', the <name/> element
   should not contain child elements.</report>  
      </rule>
 </pattern>

  <pattern name="aboutAttributes"
 see="http://www.w3.org/TR/REC-rdf-syntax/" >

 <rule id="idAboutAttr" abstract="true">
  <assert test="@rdf:ID or @rdf:about or @rdf:aboutEach"
   >The <name/> element must have an rdf:ID or
   an rdf:about or an rdf:aboutEach attribute.</assert>
  <report test="self::*[@rdf:ID][@rdf:about] or self::*[@rdf:ID][@rdf:aboutEach] 
  or self::*[@rdf:about][@rdf:aboutEach] "
   >The <name /> element can only have one rdf:ID or
   an rdf:about or an rdf:aboutEach attribute.</report>
 </rule>
        
  <rule context="/rdf:RDF" >
  <report test="@rdf:*" >The rdf:RDF element should not have an attributes.</report>
 </rule>

  <rule context="rdf:Description | rdf:RDF/* | /*  |  *[@rdf:type]" >
  <extends rule="idAboutAttr" />
 </rule>

 <rule context="*">
  <report test="self::*[@rdf:_1][rdf:_1] | self::*[@rdf:_2][rdf:_2]"
   >The <name/> element should use only the
   abbreviated syntax or the full syntax but not both.</report>
         </rule>

</pattern>     
  
  <pattern name="SpellingErrors"
      see="http://www.w3.org/TR/2001/WD-rdf-syntax-grammar-20010906/" >
 <!-- these rules test basic namespace and capitalization-->

 <rule context="rdf | RDF" >
  <report test="true()" diagnostics="fixRdfNs"
   >A <name/> element should be in the RDF Namespace.</report>
 </rule>

 <rule context="rdf:rdf  |
  rdf:description | rdf:DESCRIPTION | 
  rdf:Subject | rdf:SUBJECT | rdf:Predicate | rdf:PREDICATE  |
  rdf:Object | rdf:OBJECT | rdf:Type | rdf:TYPE |
  rdf:Value | rdf:VALUE  |
  rdf:property | rdf:PROPERTY ">
  <report test="true()" diagnostics="checkSpelling"
   >The element <name/> is not the correct capitalization.
   XML is case-sensitive.</report>
 </rule>

       <rule context="rdf:BAG | rdf:Bag | rdf:bag 
  | rdf:SET | rdf:Set | rdf:set 
  |       rdf:ALT | rdf:Alt | rdf:alt
  |  rdf:LI | rdf:Li | rdf:li">
  <report test="true()">The <name /> element is not part of the refactored RDF syntax.</report>
 </rule>

 <rule   context="rdfs:class | rdfs:CLASS | rdfs:Label |
  rdfs:LABEL | rdfs:Comment | rdfs:COMMENT |
  rdfs:Range | rdfs:RANGE | rdfs:Domain | rdfs:DOMAIN |
  rdfs:subpropertyof | rdfs:SUBPROPERTYOF |
  rdfs:subclassof | rdfs:SUBCLASSOF  |
  rdfs:seealso | rdfs:SEEALSO | 
  rdfs:isdefinedby | rdfs:ISDEFINEDBY |
  rdfs:contraintresource | rdfs:CONSTRAINTRESOURCE |
  rdfs:constraintproperty | rdfs:CONSTRAINPROPERTY |
  rdfs:resource | rdfs:RESOURCE ">
  <report test="true()" diagnostics="checkSpelling"
   >The element <name/> is not the correct capitalization.
   XML is case-sensitive.</report>
 </rule>
  </pattern>
  
 <diagnostics>
 <diagnostic id="fixRdfNs"
 >Add xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 to the element.</diagnostic>
 <diagnostic id="checkSpelling"
 >Check the spelling and capitalization</diagnostic>
 </diagnostics>
</schema>

Received on Friday, 14 September 2001 05:51:02 UTC