Simplified Syntax for RDF

This is a complementary proposal for a simplified RDF syntax inspired by Tim's strawman draft. A reference implementation is available.

Requirements for the syntax:

  1. simplicity: self-explanatory
  2. as context-free as possible
  3. allow mixing XML with RDF
XML attributes controlling the behavior of the RDF processor that are used in this document are: rdf:instance cannot be used together with rdf:for or rdf:resource.

Pure RDF

RDF follows a property-centric approach. Let the syntax reflect it. Every XML tag encountered during processing is considered to be a property name, unless explicitly overriden. For a tag to be a class name, it must carry the XML attribute rdf:instance. Example:

<person rdf:instance="uuid:...">
  <name>
     <firstname>Poo</firstname>
     <lastname>Strawman</lastname>
  </name>
  <birthday>1999-05-24</birthday>
  <address>
    <city>Boston</city>
    <street>Who knows</street>
  </address>
</person>

The RDF model of the example is:

Tag interpretation does not switch back and forth between class name and property name. Instead, RDF processor can determine in a context-free fashion that the tag name is a class iff it carries rdf:instance. In all other cases, tag name denotes a property.

Complete parsing algorithm

Definition: The function "URI getUniqueURI(Element el)"  is a one-to-one function that returns a unique URI for a given XML element (relative to the URI of the document). The function could be based on the XPath specs.

Definition: The function "Resource getSubject(Element el)" is defined as follows:

In the subsequent definition, PCDATA is used interchangeably with "PCDATA or CDATA".

Definition: The function "RDFNode getObject(Element el)"  is defined as follows:

Algorithm: For a given XML subtree with the root element el, the corresponding RDF model is generated according to the following algorithm:

void generateRDF(Element el) {

  if hasRDFInstanceAtt(el) {

    createTriple( valueOfRDFInstanceAtt(el), rdf:type, el.getTagName() ); // ***

  } else { // has no rdf:instance

    if hasRDFForAtt(el)
       subject = valueOfRDFForAtt(el);
    else
       subject = getSubject(el.getParent());

    createTriple( subject, el, getObject(el) );
  }

  for every ch in children(el)
    generateRDF(ch);
}

***: do not explicitly generate triples of the kind (subject, rdf:type, rdfs:Resource)
FIXME: shoud we prohibit that both child and parent have rdf:instance?

Examples

Example: Serialization for figure 1 in RDF M&S

<Creator rdf:for="http://www.w3.org/Home/Lassila">Ora Lassila</Creator>

is equivalent to

<rdfs:Resource rdf:instance="http://www.w3.org/Home/Lassila">
  <Creator>Ora Lassila</Creator>
</rdfs:Resource>

Example: Serialization for figure 2 in RDF M&S

<Creator rdf:for="http://www.w3.org/Home/Lassila">
  <Name>Ora Lassila</Name>
  <Email>lassila@w3.org</Email>
</Creator>

Example: Serialization for figure 3 in RDF M&S

<Creator rdf:for="http://www.w3.org/Home/Lassila" rdf:resource="http://www.w3.org/staffId/85740">
  <Name>Ora Lassila</Name>
  <Email>lassila@w3.org</Email>
</Creator>

Notes

Mixing RDF with XML

THIS SECTION IS OBSOLETE: see "Bridging the Gap between RDF and XML"

To mix RDF with XML the parser needs a clue wrt whether the XML elements under consideration are RDF-transparent or should be evaluated as RDF. It would be helpful to have a mechanism for the parser to make this distinction based on the namespace of the element (I'm tempted to say something like "rdfns:dc=..." albeit I'm aware of the problems of this approach).

If there is such mechanism, the above algorithm can be modified to "see through" all non-RDF tags (we are talking about hints for the parser, so what about (mis)using processing instructions for that purpose a la <?rdfns http://... ?rdfns>).

Example:

<t:WebPage xmlns="<HTML namespace>" xmlns:rdf="..." xmlns:t="..." xmlns:dc="..."
           rdf:instance="<URL of this page>">
<html>
    <head>
      <title>
        <dc:Title>My homepage</dc:Title>
      </title>
    </head>
    <h1>...</h1>
    ...
    <p/><hr/>
    Last modified by: <dc:Creator>Me</dc:Creator>
</html>

</t:WebPage>



Sergey Melnik, Nov 19, 1999. Last change: Dec 16, 1999