RDF Syntax Idea

Yeah, I'm sure others have probably suggested something like this already, but I figure that now there's a WG to deal with things, we might as well start discussing stuff with the knowledge that things could happen. If someone has pointers to similar work or comments on this piece, please feel free to send them to me or RDF Interest.

Here are my thoughts on improvements to the XML syntax of RDF. These are written with the intention to make it easier to migrate XML-based formats to RDF as well as making RDF easier to understand. They come from my experience in writing RDF modules for RSS and the confusions that people have when developing them. They are listed in order of importance.

Allow Attributes

RDF 1.0 allows the use of either attributes or element content, but it shouldn't be an either/or choice. Often time it makes sense to use both:

<price format="dollar">100</price>
    becomes
<#URIBeingDescribed> :price <#anon1>.
<#anon1> :format "dollar".
<#anon1> rdf:value "100" .

Automatic Parenting

Often XML depends a lot on it's tree structure, which RDF imposes certain restrictions on. It'd be nice to have things that behave like a list, act like it too:

<rdf:RDF>
  <rdf:Description rdf:about="#q">
     <item rdf:about="#q1">
        <!-- ... -->
     </item>
  </rdf:Description>
</rdf:RDF>
    becomes
<#q> rdf:_1 <#q1> .

(See, it's a list -- get it?)

In addition, this should also work if the item is replaced with a <rdf:li rdf:resource> element.

Element Content -> RDF Resource

Allow element content to be used as an RDF resource. I'm sure others can think of a better attribute for this, but it's useful for formats (like RSS) that want to remain backwards compatible.

<format rdf:parseType="resourceURI">http://example.org/format</format>
    becomes
<#URIBeingDescribed> :format <http://example.org/format> .

(that is, it's interpreted as a URI, not a literal)

Arbitrary Document Headers

Often times, you'll want to RDF-ize a format, but can't because of the requirement that rdf:RDF is the root. If you add in this element, the format will be incompatible with older tools. If you don't add it, no RDF parser will understand it. Solution: the rdf:content element, of course. ;-)

<rss rdf:content="rdf">
    <!-- everything here is interpreted as being inside an rdf:RDF tag -->
</rss>

Conclusion

For those of you who are clever, you'll have noticed that if all these changes are implemented, you'll be able to convert most XML data formats to RSS by the addition of just a few attributes. Specifically, you'll be able to convert RSS 0.91. (You knew I was going somewhere with this.) Here's an example:

<rss version="0.92+rdf" rdf:content="rdf">
  <channel rdf:about="#channelURI">
    <title>Title goes here...</tite>
    <link rdf:content="uri">http://example.org/</link>
    <!--...-->

    <item rdf:about="#itemID">
      <title>item name</title>
      <link rdf:content="uri">http://example.org/a</link>
      <newElement rdf:content="uri" name="value">http://a.com</newElement>
      <!--...-->
    </item>
  </channel>
</rss>

Of course, to make things even easier (and remove redundant elements) a DTD or some other external file could define the rdf:content attributes.

Part of LogicError. Powered by Blogspace, an Aaron Swartz project. Email the webmaster with problems.