Syntax.html 12.1 KB
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta name="generator" content=
    "HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 13), see www.w3.org" />
    <title>
      Strawman simpler syntax for RDF
    </title>
    <style type="text/css">
/*<![CDATA[*/
    detail { font-size: 10pt}
    .detail { }
    /*]]>*/
    </style>
    <link rel="stylesheet" href="di.css" type="text/css" />
    <!-- Changed by: tbl 19990524 -->
    <meta http-equiv="Content-Type" content="text/html" />
  </head>
  <body>
    <p>
      <a href="../"><img alt="W3" border="0" src=
      "/Icons/WWW/w3c_home" width="72" height="48" /></a>
    </p>
    <p>
      <em>Status: Obsolete.</em>
    </p>
    <p>
      This was written as part of the Semantic Web <a href=
      "Toolbox.html">Toolbox</a> page and spun off. It investigated
      a syntax for RDF/XML which would be simpler for users than
      the 'striped' syntax of RDF M&amp;S 1.0. It also looks at the
      rules for extracting RDF semantics from other non-RDF markup.
      In this sense it connects with the <a href=
      "XML.html">Top-down functional interpretation of XML</a> You
      can think of this syntax as Notation 2. A later syntax,
      <a href="Notation3.html">Notation 3</a>, was much more
      successful.
    </p>
    <hr />
    <h1>
      A strawman Unstriped syntax for RDF in XML
    </h1>
    <p>
      (Within this document, XML elements with namespace prefix are
      assumed to be defined as pointing to something the reader can
      figure out, and unprefixed element names are used for new
      features which are introduced in this document. ).
    </p>
    <p>
      The major difference between this syntax and <a href=
      "/TR/REC-rdf-syntax/">RDF 1.0 M&amp;S</a> is that RDF edges
      correspond to elements, and RDF nodes are implicit. It is
      basically as the M&amp;S syntax with
      <code>parseType=resource</code> is a default.
    </p>
    <h3>
      Syntax requirements
    </h3>
    <p>
      Basically the things which drove this particular syntax are
    </p>
    <ol>
      <li>A requirement to use XML as W3C policy for serialisations
      (except where excruciatingly painful)
      </li>
      <li>A non-requirement to have the "striping" of RDF M&amp;S
      1.0 where nested elements describe alternately nodes and
      arcs;
      </li>
      <li>RDF can be carried within other XML information and can
      have other XML information inserted within the syntax;
      </li>
      <li>It should be possible to make a document which
      efficiently expresses information and allows an RDF parser
      aware of the syntax to extract the RDF graph without needing
      to read the namespace schema.
      </li>
      <li>RDF can carry extensions which can be optional.
      </li>
    </ol>
    <h2>
      Assumed syntax
    </h2>
    <p>
      I assume for the purposes of the <a href=
      "Toolbox.html">Toolbox</a> page a syntax for data in XML in
      which XML elements be classified into the following
      categories.
    </p>
    <h3>
      RDF-Property element
    </h3>
    <p>
      The element introduces information about an arc in the graph.
      As nodes in RDF do not inherently have any information apart
      from their arcs, properties are the only way RDF information
      actually described. Property elements work as follows:
    </p>
    <ol>
      <li>XML elements may be declared in a schema to be RDF
      assertions and to therefore be treatable as such. These are
      known as <em>property elements</em>.
      </li>
      <li>At any point in an XML document there may by a
      <em>default subject</em> set. This is the subject of any
      property element where not indicated otherwise.
      </li>
      <li>An <code>rdf:for</code> attribute indicates otherwise for
      the subject for one property element. (This is a shortcut)
      </li>
      <li>An <code>rdf:about</code> attribute on any element sets
      the default subject for any contained elements. (Equivalent
      to RDF M&amp;S)
      </li>
      <li>An <code>rdf:fyi</code> attribute on an element removes
      any default subject for the element and its descendants
      unless otherwise specified. The RDF parser may ignore the
      element and its contents as far as RDF semantics go.
      </li>
      <li>An <code>rdf:extend</code> attribute on any element
      indicates that the semantics of the element are of relevance
      to the RDF parser and must be interpreted according to the
      specification, and where this cannot be done the RDF
      semantics are undefined (and typically an error condition
      will result from an attempt at evaluation). The element is
      known as an RDF-opaque element
      </li>
      <li>If a property element has an <code>rdf:value</code>
      attribute that indicates the value of the property. This is
      just a shortcut for having it in the element content.
      </li>
      <li>If a property element has atomic (string) content then
      that is the object of the statement. (If this and the
      previous exist they must match).
      </li>
      <li>If a property element has child elements then its value
      is an RDF node which becomes the default subject (unless the
      parsetype is used to declare the content to be literal XML)
      </li>
    </ol>
    <h3>
      RDF-Transparent
    </h3>
    <p>
      The Semantic context is not changed. And example might be all
      HTML tags, to make it simple to include RDF in HTML documents
      (and extract it).
    </p>
    <h3>
      RDF-Opaque
    </h3>
    <p>
      The RDF parser can deduce nothing about the element or its
      contents, unless it knows the semantics of the element.
      Example: &lt;sense:room-temperature/&gt;
    </p>
    <p>
      RDF-Opaque tags are understood by parsers conforming to the
      namespace they are in.
    </p>
    <p>
      In the <a href="Toolbox.html">toolbox</a> we will introduce
      new features which, while they indeed be expressed longhand
      in the existing XML-RDF notation, in practice need to
      available in a more concise form at a high level. These are
      therefore extensions to the RDF-XML syntax for logic.
      Example: &lt;not&gt;
    </p>
    <p>
      RDF-Opaque tags in the RDF space are understood by conforming
      parsers. Other tags are assumed to be property elements if
      there is subject defined (default or otherwise) and otherwise
      RDF-Transparent (by default) or Opaque (if specified).
      Information as to whether tags are RDF-Opaque may be given in
      the document using them or in a schema (or indeed in
      principle anywhere else). It may be done element by element,
      or if applicable, to an en entire namespace.
    </p>
    <p>
      This syntax was written as have something for examples, and
      part of the purpose of this is a feasibility of writing logic
      in XML. I apologise to the reader for the effort required to
      work in a strange syntax. There was later a call for a
      simpler syntax and so this was cleaned up a little as a
      strawman.
    </p>
    <hr />
    <h3>
      Examples for rdf:for and rdf:about
    </h3>
    <p>
      Sometimes the effort of creating an element just in order
      only to define the subject for a following assertion is a bit
      heavy. Making a standard well-known and mandatory understood
      attribute would make this easier. Suppose, for example that
      <code>rdf:about=foo</code> always sets the thing to which a
      contained property element refers by default, and
      <code>rdf:for=bar</code> overrode it for the element itself.
      (<code>rdf:for</code> would also imply that the element was
      an RDF property)
    </p>
    <pre>
&lt;dc:author rdf:for="thebook" value="Ora"/&gt;
</pre>
    <p>
      is an easier way of specifying a single property.
    </p>
    <pre>
&lt;frontm rdf:about="theBook"&gt;
   &lt;z:date&gt;sdfghjk&lt;/z:date&gt;
   &lt;z:title&gt;Makeing more pancakes&lt;/z:title&gt;
   &lt;z:obsoletes&gt; 
      &lt;!-- default subject is no longer theBook --!&gt;
      &lt;z:title&gt;Making pankakes&lt;/z:title&gt;
      &lt;z:price&gt;$3.00&lt;/z:price&gt;
   &lt;/z:obsoletes&gt;
   &lt;z:price&gt;$6.00&lt;/z:price&gt;
   &lt;z:price for="anotherBook"&gt;$78.00&lt;/z:price&gt;
&lt;/frontm&gt;
</pre>
    <p>
      (The only problem I have with <code>rdf:about</code> and
      <code>rdf:for</code> is that it becomes mandatory for any
      semantically aware parser to be able to handle this, as
      ignoring it is of course impossible.)
    </p>
    <h3>
      RDF:Description
    </h3>
    <p>
      When one wants to introduce information about an RDF node,
      this is basically done by any element with an rdf:about
      attribute. When there is no other element which conveniently
      provides a placeholder, the rdf:description element may be
      used.
    </p>
    <pre>
&lt;rdf:description rdf:about="theBook"&gt;
   &lt;dc:author&gt;Ralph&lt;/dc:author&gt;
   &lt;http:from&gt;swick@w3.org&lt;/http:from&gt;
&lt;/rdf:description&gt;
</pre>
    <p>
      If the <code>rdf:about</code> attribute is present it
      indicates that the node represents a resource (document)
      whose URI is that give. That attribute may be omitted.
    </p>
    <h3>
      RDF:Property
    </h3>
    <p>
      There are times when using an XML element name for a property
      may be difficult or impossible, such as when there are many
      properties to be listed, each from different namespaces, or
      when the property must take the value of the variable.
      <span class="detail">(Yes, I understand this takes RDF out of
      first order logic but our ability to quote statements and
      refer to them I think makes that step anyway).</span>
    </p>
    <pre>
&lt;rdf:property pname="http://dc.org/dc1#author"
   rdf:for="theBook"
   rdf:value="Ralph"&gt;
</pre>
    <p>
      This is also useful as a serialisation syntax when dumping
      the output of a parser, for example.
    </p>
    <hr />
    <h2>
      NOTES
    </h2>
    <p>
      See also
    </p>
    <p>
      <a href="Identity.html">Identifying things in RDF</a>
    </p>
    <h3>
      RDF in HTML - Transparent or not?
    </h3>
    <p>
      There are two ways to put RDF into HTML using these
      conventions. One could declare that all HTML elements are
      RDF-transparent, in which case RDF can be stuck in anywhere.
    </p>
    <p>
      One could bring them closer, so that the RDF subject is set
      to appropriate URI by convention by declaring them (in RDF
      schema code inserted into the XHTML schema) to be opaque. In
      this case, I would propose that HTML's HEAD (or maybe even
      the HTML document container) be considered as a Node element
      whose context is the document itself. I would propose that A
      switch context to the destination of the link - as one often
      wants a neat way of putting in information about it.
    </p>
    <p>
      Examples:
    </p>
    <table border="1">
      <tbody>
        <tr>
          <th>
            Element
          </th>
          <th>
            RDF subject (URI)
          </th>
        </tr>
        <tr>
          <td>
            HTML:HTML
          </td>
          <td>
            The document itself ("")
          </td>
        </tr>
        <tr>
          <td>
            HTML:HEAD
          </td>
          <td>
            The document itself ("")
          </td>
        </tr>
        <tr>
          <td>
            HTML:A
          </td>
          <td>
            The linked document (value of <em>href</em>)
          </td>
        </tr>
        <tr>
          <td>
            HTML:BLOCKQUOTE
          </td>
          <td>
            The quoted document
          </td>
        </tr>
      </tbody>
    </table>
    <p>
      References
    </p>
    <p>
      See also:
    </p>
    <ul>
      <li>
        <a href=
        "http://www-db.stanford.edu/~melnik/rdf/syntax.html">Sergy's
        proposal</a>
      </li>
    </ul>
    <p>
      So much for syntax: on to the <a href="Toolbox.html">semantic
      toolbox</a>.
    </p>
    <hr />
    <small>Last change $Id: Syntax.html,v 1.21 2007/03/22 20:31:40
    timbl Exp $</small>
    <address>
      Tim BL
    </address>
  </body>
</html>