W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > July 2005

SPARQL Results format

From: Kevin D. Keck <kdkeck@lbl.gov>
Date: Tue, 5 Jul 2005 10:53:33 -0700
Message-Id: <60f012540c9d32e818ee2668623f1492@lbl.gov>
To: public-rdf-dawg-comments@w3.org

I rather liked the December draft of the Variable Binding Results XML 
(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=""

   <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:results rdf:parseType="Collection">

	<x rdf:nodeID="r1"/>
	<hpage rdf:resource="http://work.example.org/alice/"/>
xmlns="http://www.w3.org/1999/xhtml">My name is 
	<friend rdf:nodeID="r2"/>

	<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"/>



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 

@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 

@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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:52:06 UTC