Alternative RDF/XML serializations

There have been quite a few criticisms of the official XML serialization
of RDF [1, 2, 3].  One common comment (to me, anyway) is that RDF/XML is
hard to read [3, 4].  Another criticism (that I can relate with) is that
generating HTML from the serialization using XSLT is complicated [5].
So, I started thinking about alternative representations in XML.

One idea, inspired by Dick McCullough [3], uses qualified names with a
vengeance:

<r:RDF
	xmlns:r="http://purl.org/jfc/2003/05/25/x-rdf-1#"
	xmlns:jfc="http://purl.org/jfc/2003/05/25/ex-1#"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
	
<jfc:myDocument>
	<r:type>
		<jfc:webPage />
	</r:type>
	<dc:creator>
		<r:Literal>Jimmy</r:Literal>
		<r:Literal>Jamie</r:Literal>
	</dc:creator>
</jfc:myDocument>

<r:Resource r:name="jfc:anotherDocument">
	<r:type><jfc:pdf /></r:type>
	<dc:creator><r:Literal>Jimmy</r:Literal></dc:creator>
</r:Resource>

<r:Resource r:uri="http://www.w3.org/TR/rdf-mt/">
	<r:type><jfc:w3cDocument /></r:type>
	<r:Property r:uri="http://www.w3.org#Editor">
		<r:Literal>Patrick Hayes</r:Literal>
	</r:Property>
	<r:Property r:uri="http://www.w3.org#Series%20Editor">
		<r:Literal>Brian McBride</r:Literal>
	</r:Property>
</r:Resource>

</r:RDF>

That example uses the element name to identify the thing being
described.  Exceptions are made for elements in the "r" namespace.
Since some things may not be able to be described with an element name
(such as literals and uris), the r:Resource, r:Property and r:Literal
elements are provided.  The attribute r:uri (for uris) and r:name (for
qualified names) indicates the thing being described in that case.

Each child of the r:RDF element is a subject of a RDF statement.  The
children in level 2 of the XML tree are predicates (or properties).
Finally, level 3 contains the objects for each statement.  If a property
contains more than one child, then they are described by a bag; for
instance in the first child of the r:RDF element above:

<jfc:myDocument>
	<dc:creator>
		<r:Literal>Jimmy</r:Literal>
		<r:Literal>Jamie</r:Literal>
	</dc:creator>
</jfc:myDocument>

...means, in the official serialization:

<rdf:Description
rdf:about="http://purl.org/jfc/2003/05/25/ex-1#myDocument">
	<dc:creator>
		<rdf:Bag>
			<rdf:li>Jimmy</rdf:li>
			<rdf:li>Jamie</rdf:li>
		</rdf:Bag>
	</dc:creator>
</rdf:Description>

Another possible serialization uses properties:

<r:RDF
	xmlns:r="http://purl.org/jfc/2003/05/25/x-rdf-1#"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
	<dc:creator
		r:of="http://www.foo.com/Document">
		<r:Literal>Jimmy</r:Literal>
	</dc:creator>
	<dc:creator
		r:of="http://www.foo.com/Document"
		r:is="http://www.foo.com/Mary" />
</r:RDF>

This serialization uses attributes to represent subjects (value of r:of)
and objects (value of r:is); the predicate is the parent element.
Literals are again wrapped in r:Literal elements and are also children
of the properties (unlike resources, which are referred to in r:of
attributes).

Tim Bray also came up with a simple serialization [1]:

<RPV xmlns="http://www.rdf.net/rpv/">
 <R id="Dave" pbase="http://www.example.com/terms/">
  <PV p="fullName">Dave Beckett</PV>
  <PV p="homePage" v="http://purl.org/net/dajobe" />
  </R>
 <R r="http://www.w3.org/TR/rdf-syntax-grammar">
  <PV p="http://www.example.com/terms/editor" v="#Dave" />
  <PV p="http://purl.org/dc/elements/1.1/title">
    RDF/XML Syntax Specification (Revised)
    </PV>
  </R>
 </RPV>

I personally don't like this representation.  The element names are not
very descriptive.  I suppose that it could be validated against a DTD;
however, and that is a significant positive aspect of his idea.

Other ideas - that I have - include adding id attributes to properties
so rdf statements can be talked about (called rectification, right?) and
adding conditional attributes to properties for scope and context.
Finally, attributes could be added to rdf:li elements to indicated roles
of "elements" (not XML elements, but mathematical/set-theory elements)
in a set or container.

--
Jimmy Cerra

] "I had to learn very early not to limit
]  myself due to others limited imagination."
]  - Dr. Mae C. Jemison

Notes:
[1] http://www.tbray.org/ongoing/When/200x/2003/05/21/RDFNet
[2] http://www.xml.com/pub/a/2002/11/27/rdf.html
[3] http://lists.w3.org/Archives/Public/www-rdf-logic/2003May/0036.html
[4] http://lists.xml.org/archives/xml-dev/200211/msg00750.html
[5] http://www.cee.hw.ac.uk/~alison/www9/paper.html

Received on Sunday, 25 May 2003 00:44:45 UTC