SPARQL Results format

I rather liked the December draft of the Variable Binding Results XML 
Format
(http://www.w3.org/TR/2004/WD-rdf-sparql-XMLres-20041221/), and am 
sorry to see that the latest draft is considerably more verbose and 
less RDF-like.  In thinking about how to make it more RDF-like, I came 
up with the following counterpart to the example <output.xml>:

<?xml version="1.0"?>
<qr:ResultSet rdf:about=""
	xmlns="#"
	xmlns:qr="http://purl.org/QueryResults/"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

   <qr:variables rdf:parseType="Collection">
     <qr:Variable rdf:ID="x"/>
     <qr:Variable rdf:ID="hpage"/>
     <qr:Variable rdf:ID="name"/>
     <qr:Variable rdf:ID="mbox"/>
     <qr:Variable rdf:ID="age"/>
     <qr:Variable rdf:ID="blurb"/>
     <qr:Variable rdf:ID="friend"/>
   </qr:variables>

   <qr:results rdf:parseType="Collection">

     <qr:Result>
	<x rdf:nodeID="r1"/>
	<hpage rdf:resource="http://work.example.org/alice/"/>
	<name>Alice</name>
	<mbox></mbox>
	<blurb 
rdf:datatype="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"><p 
xmlns="http://www.w3.org/1999/xhtml">My name is 
<b>alice</b></p></blurb>
	<friend rdf:nodeID="r2"/>
     </qr:Result>

     <qr:Result>
	<x rdf:nodeID="r2"/>
	<hpage rdf:resource="http://work.example.org/bob/"/>
	<name xml:lang="en">Bob</name>
	<mbox rdf:resource="mailto:bob@work.example.org"/>
	<age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">30</age>
	<friend rdf:nodeID="r1"/>
     </qr:Result>

   </qr:results>

</qr:ResultSet>



Note that by using RDF/XML syntax to indicate types, I have made this 
same XML file also parse as RDF.  If translated into N3, it would look 
like:

@prefix qr:	<http://purl.org/QueryResults/> .
@prefix rdf:	<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<> a qr:ResultSet ;
     qr:variables (:x :hpage :name :mbox :age :blurb :friend) ;
     qr:results (
	[a qr:Result ;
	 :x _:r1 ;
	 :hpage <http://work.example.org/alice/> ;
	 :name "Alice" ;
	 :mbox "" ;
	 :blurb "<p xmlns=\"http://www.w3.org/1999/xhtml\">My name is 
<em>Alice</em></p>"^^rdf:XMLLiteral ;
	 :friend _:r2 ]

	[a qr:Result ;
	 :x _r2 ;
	 :hpage <http://work.example.org/bob/> ;
	 :name "Bob"@en ;
	 :mbox <mailto:bob@work.example.org> ;
	 :age 30 ;
	 :friend _:r1 ]
     ) .

:x a qr:Variable .
:hpage a qr:Variable .
:name a qr:Variable .
:mbox a qr:Variable .
:age a qr:Variable .
:blurb a qr:Variable .
:friend a qr:Variable .



An RDF Schema for <http://purl.org/QueryResults/> would look something 
like:

@prefix qr: <http://purl.org/QueryResults/> .
@prefix rdf:        <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:	    <http://www.w3.org/2000/01/rdf-schema#> .

qr:ResultSet a rdfs:Class .
qr:variables a rdf:Property ;
	rdfs:domain qr:ResultSet ;
	rdfs:range rdf:List .
qr:results a rdf:Property ;
	rdfs:domain qr:ResultSet ;
	rdfs:range rdf:List .
qr:Variable rdfs:subClassOf rdf:Property .
qr:Result a rdfs:Class .

Received on Tuesday, 5 July 2005 18:24:05 UTC