W3C SW Dev

version 0.5 draft syntax

Classes and Properties

The agent markup language syntax is XML using XML namespaces and RDF.

These documents will typically use elements and attributes from the RDF namespace(s) directly. The namespace for the base RDF model (defining statements and properties) and the namespace for RDF Schema (defining classes and constraints) are invoked with XML namespace declarations of the form:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:s="http://www.w3.org/2000/02/rdf-schema#">
  <!-- body of document -->
</RDF>

Classes (or categories) are simply RDF Classes. A class declaration is written in the following way:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:s="http://www.w3.org/2000/02/rdf-schema#">
  <s:Class ID="MyClass" />
</RDF>

Optionally, the RDF documentation properties can be used to include human-readable prose. Class hierarchies are declared using the RDF subClassOf property:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:s="http://www.w3.org/2000/02/rdf-schema#">
  <s:Class ID="MyClass">
    <s:comment>MyClass has no superclasses declared</s:comment>
  </s:Class>

  <s:Class ID="MySubClass">
    <s:subClassOf resource="#MyClass" />
    <s:comment>MyClass is a superclass of MySubClass</s:comment>
  </s:Class>
</RDF>

Properties (or relations) are simply RDF Propertys. A property declaration is written in the following way:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <Property ID="myProperty" />
</RDF>

XML Schema for Inference Rules

XML Schema provides a compact mechanism for describing the structure of a valid document. Inference rules are written using the wtr, and list RDF classes.

These markup elements are described in a schema for KIF using XML Schema as:

<schema xmlns="http://www.w3.org/1999/XMLSchema"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#"
	targetNamespace="http://www.w3.org/2000/07/hs78/KIF#"
	>

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

<element name="wtr" type="rdf:typedNodeType"
	 equivClass="rdf:typedNode" />

<element name="list" type="rdf:typedNodeType"
	 equivClass="rdf:typedNode" />

<!-- more to come -->

</schema>

Here, the type and equivClass arguments declare the permitted syntax for these elements. These declarations use XML type declarations from an XML Schema for RDF, reproduced in the next section.

The schema declaration for each of the elements above says that they have the syntax of an RDF typedNode. A typedNode element is a short-hand expression for declaring an instance of a Class. For example,

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#">
  <inf:list ID="myRuleBody"/>
</RDF>
is short-hand for
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#">
  <Description ID="myRuleBody">
    <type resource="http://www.w3.org/2000/07/hs78/KIF#list"/>
  </Description>
</RDF>

Note that the syntax for declaring classes and properties shown in the previous section is also an application of this same typedNode syntax. "MyClass" was declared to be an instance of the RDF class 'Class'; that is, it is a Class. And "myProperty" was declared to be an instance of the RDF class 'Property'; i.e. it is a Property.

The wtr class is a subclass of RDF Statement. Instances of the wtr class use the RDF predicate, subject, and object properties to identify the elements of the statement.

For example, the statement "there is a weakly true statement that Dan is the author of a program" would be written as:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#"/>
  <inf:wtr>
    <rdf:subject>Dan</rdf:subject>
    <rdf:predicate resource="http://...myOntology#isAuthorOf"/>
    <rdf:object>aProgram</rdf:object>
  </inf:wtr>
</RDF>

The list RDF Class and the RDF properties first and rest are used to declare the antecedents and conclusion(s) for an instance of a rule.

<schema xmlns="http://www.w3.org/1999/XMLSchema"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:s="http://www.w3.org/2000/01/rdf-schema#"
	xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#"
	targetNamespace="http://www.w3.org/2000/07/hs78/KIF#"
	>

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

<element name="wtr" type="rdf:typedNodeType"
	 equivClass="rdf:typedNode" />

<element name="list" type="rdf:typedNodeType"
	 equivClass="rdf:typedNode" />

<element name="null" type="rdf:typedNodeType"
	 equivClass="rdf:typedNode" />

<element name="first" type="rdf:propertyEltRef"
	 equivClass="rdf:propertyElt" />

<element name="rest" type="rdf:valueObj"
	 equivClass="rdf:propertyElt" />

</schema>

For example, a definitive list of authors of a program is written as:

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:l="http://www.w3.org/2000/07/hs78/KIF#">
  <myOntology:Program>
    <myOntology:authors>
      <l:List>
        <l:first>
	  <myOntology:Person>
	    <myOntology:givenName>Dan</myOntology:givenName>
  	  </myOntology:Person>
        </l:first>
	<l:rest>
	  <inf:null/>
	</l:rest>
      </l:List>
    </myOntology:authors>
  </myOntology:Program>
</RDF>

This says "there exists a program whose authors are a person whose given name is "Dan" and no others." (This English transcription is not precise about whether "Dan" is the name of the person or the name of the program. This is a common feature of "natural language", however the RDF is unambiguous.)

Variables in a expression are identifiers in a reserved part of the W3C Web address space; there is no special URI scheme that universally means 'this is the name of a variable'. URIs beginning with http://www.w3.org/2000/07/hs78/KIF?word=%3f serve as KIF individual variables. (%3f is the hex encoding of the character '?'.)

The wtr, and list classes are used with the properties predicate, subject, object, first, and rest and with the Operators => and and to declare the definitive list of antecedents for a rule.

For example, here is a simple inference rule:

<r:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
       xmlns:inf="http://www.w3.org/2000/07/hs78/KIF#"
       xmlns:shoeb="http://www.w3.org/2000/04shoe-swell/convert?in=http://www.cs.umd.edu/projects/plus/SHOE/onts/base1.0.html#" />

  <kif:wtr
   shoeb:description="Transitivity of Suborganizations. If subOrganizationOf(x,y) and subOrganizationOf(y,z) then subOrganizationOf(x,z)">

    <rdf:predicate
     resource="http://www.w3.org/2000/07/hs78/KIF?word=%3d%3e" />

    <rdf:subject>
      <kif:list>
        <kif:first
         resource="http://www.w3.org/2000/07/hs78/KIF?word=and" />

        <kif:rest>
          <kif:list>
            <kif:first>
              <rdf:Statement>
                <rdf:predicate
                 rdf:resource="http://www.w3.org/2000/04shoe-swell/#subOrganizationOf" />

                <rdf:subject
                 resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fx" />

                <rdf:object
                 resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fy" />
              </rdf:Statement>
            </kif:first>

            <kif:rest>
              <kif:list>
                <kif:first>
                  <rdf:Statement>
                    <rdf:predicate
                     rdf:resource="http://www.w3.org/2000/04shoe-swell/#subOrganizationOf" />

                    <rdf:subject
                     resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fy" />

                    <rdf:object
                     resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fz" />
                  </rdf:Statement>
                </kif:first>

                <kif:rest>
                  <kif:null />
                </kif:rest>
              </kif:list>
            </kif:rest>
          </kif:list>
        </kif:rest>
      </kif:list>
    </rdf:subject>

    <rdf:object>
      <kif:list>
        <kif:first
         resource="http://www.w3.org/2000/07/hs78/KIF?word=and" />

        <kif:rest>
          <kif:list>
            <kif:first>
              <rdf:Statement>
                <rdf:predicate
                 rdf:resource="http://www.w3.org/2000/04shoe-swell/#subOrganizationOf" />

                <rdf:subject
                 resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fx" />

                <rdf:object
                 resource="http://www.w3.org/2000/07/hs78/KIF?word=%3fz" />
              </rdf:Statement>
            </kif:first>

            <kif:rest>
              <kif:null />
            </kif:rest>
          </kif:list>
        </kif:rest>
      </kif:list>
    </rdf:object>
  </kif:wtr>
</r:RDF>

You can read this as "there exists an instance of a weakly true statement whose predicate is "=>" (implies), whose subject is the conjunction of the reified statements "x is subOrganizationOf y" and "y is subOrganizationof z", and whose object is the reified statement "x is subOrganizationOf z", where x, y, and z are variables."

Note that we have used a third namespace in this example, an example namespace corresponding to the SHOE base ontology, to incorporate a prose description of the rule intended for human consumption. This illustrates the ease with which an RDF expression can take advantage of properties defined by a variety of sources.

A graphical illustration of this rule for the transitivity of subOrganizationOf is shown below:

(=> (and (subOrganizationOf x y) (subOrganizationOf y z)) (subOrganizationOf x z)) ai

XML Schema for RDF

[RDF] uses BNF to specify the syntax of RDF XML expressions. A translation of that BNF into XML Schema completes the formal syntactic definition . An annotated version of this translation, sufficient our use, is:

<schema
        xmlns="http://www.w3.org/1999/XMLSchema"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        targetNamespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  <annotation>
    <documentation>
      

XML Schema for RDF

$Id: rdf.xsd,v 1.17 2000/08/04 14:37:44 swick Exp $

originally derived from Rick Jelliffe's work:

From: Rick JELLIFFE <ricko@allette.com.au> To: xml-dev@xml.org Subject: Re: new public working draft of XML Schema Date: Sat, 26 Feb 2000 23:05:20 +0800

then modified to match the RDF formal grammar

created 2000-12-25, Rick Jelliffe, Academia Sinica Computing Centre. Thanks to Henry Thompson for help.

RDF Specification at W3C.

</documentation> </annotation> <!-- Top-level of RDF Document --> <element name="RDF"> <complexType content="elementOnly" > <sequence maxOccurs="unbounded" > <group ref="rdf:obj"/> <!-- abstract --> </sequence> </complexType> </element> <group name="obj"> <choice> <element ref="rdf:typedNode"/> <group ref="rdf:container"/> </choice> </group> <!-- @@check this after doing typednode --> <element name="Description" type="rdf:typedNodeType" equivClass="rdf:typedNode" /> <group name="container"> <!-- @@ spec says you can subclass this, but that makes parsing depend on schema info. Bad. --> <choice> <element ref="rdf:Bag"/> <element ref="rdf:Seq"/> <element ref="rdf:Alt"/> </choice> </group> <attributeGroup name="idAboutAttrOpt"> <annotation><documentation source="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/#aboutAttr"/></annotation> <attributeGroup ref="rdf:aboutAttrOpt"/> <attributeGroup ref="rdf:idAttrOpt"/> <!-- @@leave out aboutEachAttr for now --> </attributeGroup> <attribute name="ID" type="ID" /> <attributeGroup name="idAttrOpt"> <attribute name="ID" use='optional' type="ID" /> <attribute ref="rdf:ID" use='optional'/> </attributeGroup> <attribute name="about" type="uriReference" /> <attributeGroup name="aboutAttrOpt"> <attribute name="about" use='optional' type="uriReference" /> <attribute ref="rdf:about" use='optional' /> </attributeGroup> <!-- leaving out aboutEachAttr for now @@--> <!-- leaving out bagIdAttr @@--> <!-- leaving out propAttr @@--> <!-- leaving out typeAttr @@--> <element name="propertyElt" abstract="true" type="rdf:propertyEltType" /> <complexType name="propertyEltType" base="rdf:item" derivedBy="restriction"> <annotation><documentation>this is a "union type"; use xsi:type in the instance to discriminate between concrete subtypes </documentation></annotation> </complexType> <complexType name="propertyEltValue" content="textOnly" base="rdf:propertyEltType" derivedBy="restriction"> <attributeGroup ref="rdf:idAttrOpt"/> </complexType> <complexType name="propertyEltLiteral" content="mixed" base="rdf:propertyEltType" derivedBy="restriction"> <any minOccurs="0" processContents="skip"/> <attributeGroup ref="rdf:idAttrOpt"/> <attributeGroup ref="rdf:parseLiteral"/> </complexType> <complexType name="propertyEltResource" content="elementOnly" base="rdf:propertyEltType" derivedBy="restriction"> <sequence maxOccurs="unbounded" > <element ref="rdf:propertyElt" /><!--abstract !--> </sequence> </complexType> <complexType name="propertyEltRef" content="empty" base="rdf:propertyEltType" derivedBy="restriction"> <attributeGroup ref="rdf:idRefAttrOpt"/> <!-- @@leaving out bagIdAttr? --> <!-- @@leaving out propAttr* --> </complexType> <element name="typedNode" abstract="true" type="rdf:typedNodeType"/> <complexType name="typedNodeType"> <sequence maxOccurs="unbounded"> <element ref="rdf:propertyElt"/> </sequence> <attributeGroup ref="rdf:idAboutAttrOpt"/> <!--@@leaving out bagidattr, propattr --> </complexType> <attributeGroup name="idRefAttrOpt"> <attributeGroup ref="rdf:idAttrOpt"/> <attributeGroup ref="rdf:resourceAttrOpt"/> </attributeGroup> <!--@@ can complex types be abstract? or just elements? --> <complexType name="value" abstract="true" base="rdf:propertyEltType" derivedBy="restriction"/> <complexType name="valueObj" base="rdf:value" derivedBy="restriction"> <group ref="rdf:obj"/> </complexType> <complexType name="valueString" base="rdf:value" content="mixed" derivedBy="restriction"> <sequence/> <!-- no subelements --> </complexType> <attribute name="resource" type="uriReference" /> <attributeGroup name="resourceAttrOpt"> <attribute name="resource" use='optional' type="uriReference" /> <attribute ref="rdf:resource" use='optional' /> </attributeGroup> <attributeGroup name="resourceAttr"> <!-- @@er... which one to require? --> <attribute name="resource" use='optional' type="uriReference" /> <attribute ref="rdf:resource" use='optional' /> </attributeGroup> <element name="Seq" type="rdf:members"/> <element name="Bag" type="rdf:members"/> <element name="Alt" type="rdf:members"/> <!-- @@restrict Alt to have at least one member --> <complexType name="members" content="elementOnly"> <sequence maxOccurs="unbounded"> <element name="li" type="rdf:item"/> </sequence> <attributeGroup ref="rdf:idAttrOpt"/> <!-- @@leaving out memberAttr* --> </complexType> <complexType name="item"> <annotation><documentation>this is a "union type"; use xsi:type in the instance to discriminate between concrete subtypes. @@hmm... can I mark this as "abstract" somehow? </documentation></annotation> </complexType> <complexType name="referencedItem" base="rdf:item" content="empty" derivedBy="restriction"> <attributeGroup ref="rdf:resourceAttr"/> </complexType> <!-- @@strictly speaking, inlineItem should be specified as subtypes, one of propertyEltValue, propertyEltLiteral, and propertyEltResource, with use="prohibited" on some attributes to get rid of them. But I'm gonna skip it for now --> <attribute name="parseType"/> <attributeGroup name="parseLiteral"> <attribute name="parseType" use='fixed' value="Literal" /> <attribute ref="rdf:parseType" use='fixed' value="Literal" /> </attributeGroup> <attributeGroup name="parseResource"> <attribute name="parseType" use='fixed' value="Resource" /> <attribute ref="rdf:parseType" use='fixed' value="Resource" /> </attributeGroup> <!-- so much for syntax structure. Now for the particular properties and classes... --> <element name="Statement" type="rdf:typedNodeType" equivClass="rdf:typedNode" /> <element name="Property" type="rdf:typedNodeType" equivClass="rdf:typedNode" /> <!-- these are is constrained to use resource="..."; use xsi:type to do something else --> <element name="subject" type="rdf:propertyEltRef" equivClass="rdf:propertyElt" /> <element name="predicate" type="rdf:propertyEltRef" equivClass="rdf:propertyElt" /> <element name="object" type="rdf:propertyEltRef" equivClass="rdf:propertyElt" /> <element name="type" type="rdf:propertyEltRef" equivClass="rdf:propertyElt" /> <!-- constrained to the <value>...</value> syntax --> <element name="value" type="rdf:valueString" equivClass="rdf:propertyElt" /> </schema>
With the two XML schemas above, tools such as XSV, XML Schema Validator, can be used to check the conformance of an XML document to this specification.
Ralph Swick
$Revision: 1.20 $ of $Date: 2000/08/22 03:21:30 $ by $Author: connolly $
change log