W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2004

Re: draft XML query results format spec

From: Dave Beckett <dave.beckett@bristol.ac.uk>
Date: Tue, 28 Sep 2004 18:06:35 +0100
Cc: public-rdf-dawg@w3.org
Message-Id: <20040928180635.384cd68b@hoth.ilrt.bris.ac.uk>
On Tue, 28 Sep 2004 15:13:45 +0100, Dave Beckett <dave.beckett@bristol.ac.uk> wrote:

> I attach two possible result formats that vary in one design choice -
>   1) variable names are element names and hence the XML is schemaless

I've expanded this example to include an example query based on one
in the current rq23 draft, extended to add optionals so I can show
missing items and something with datatypes, XML literals and empty

So given the following query (example.rq23 attached)

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ex: <http://ns.example.org/#>

SELECT ?hpage ?name ?mbox ?age ?blurb
FROM <data.n3>

WHERE    ( ?x foaf:name ?name )
         ( ?x foaf:mbox ?mbox )
         ( ?x foaf:homepage ?hpage )
       [ ( ?x ex:ageInYears ?age ) ]
       [ ( ?x ex:blurb ?blurb ) ]

operating on the data (data.n3 attached)

@prefix foaf:       <http://xmlns.com/foaf/0.1/> .
@prefix rdf:        <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:	    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex:         <http://ns.example.org/#> .

_:a  foaf:name       "Alice" .
_:a  foaf:homepage   <http://work.example.org/alice/> .
_:a  foaf:mbox       "" .
_:a  ex:blurb       "<p xmlns=\"http://www.w3.org/1999/xhtml\">My name is <b>alice</b></p>"^^rdf:XMLLiteral .

_:b  foaf:name       "Bob"@en .
_:b  foaf:mbox       <mailto:bob@work> .
_:a  foaf:homepage   <http://work.example.org/bob/> .
_:b  ex:age          30 .

gives Query Result:

  ?hpage = <http://work.example.org/alice/>, ?name = "Alice", ?mbox = "",
  ?blurb = "<p xmlns = \"http://www.w3.org/1999/xhtml\">My name is <b>alice</b></p>"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>

  ?hpage = <http://work.example.org/bob/>, ?name = "Bob"@en,
  ?mbox = <mailto:bob@work>, ?age = 10

and XML version of that (result1.xml attached)

<results xmlns="http://www.w3.org/sw/2001/DataAccess/result1#">

    <hpage href="http://work.example.org/alice/"/>
    <blurb datatype="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral">&lt;p xmlns="http://www.w3.org/1999/xhtml"&gt;My name is &lt;b&gt;alice&lt;/b&gt;&lt;/p&gt;</blurb>

    <hpage href="http://work.example.org/bob/"/>
    <name xml:lang="en">Bob</name>
    <mbox href="mailto:bob@work"/>
    <age datatype="http://www.w3.org/2001/XMLSchema#integer">30</age>


The XML content I expect to be rare compared to the RDF datatyped
literals and rarer than RDF plain literals.  

However, it does look ugly as above.  The other choice I see is to
just include it inline - since there is no XML schema being used

    <blurb><p xmlns="http://www.w3.org/1999/xhtml">My name is <b>alice</b></p></blurb>

This is probably a good choice if XSLT and related tech are targets
since (XSLT at least) cannot easily transform an escaped XML literal
to a DOM tree.  It could be that it would need to be way to
distinguish a plain literal from non-mixed content with some flag,
but I think that's not the "XML Way".

So I'm leaning to making this last change too.


Received on Tuesday, 28 September 2004 17:09:30 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:00:45 UTC