W3C home > Mailing lists > Public > www-rdf-interest@w3.org > February 2004

RE: RDQL - How to read the content of a bag?

From: Seaborne, Andy <Andy_Seaborne@hplb.hpl.hp.com>
Date: Mon, 2 Feb 2004 17:44:41 -0000
Message-ID: <E864E95CB35C1C46B72FEA0626A2E80801450DB2@0-mail-br1.hpl.hp.com>
Cc: www-rdf-interest@w3.org


Querying the contents of a bag is tricky in RDQL: because the language only
has triple patterns, the way RDF represents bags with rdf:_1, rdf:_2 is
visible unfortunately.

The first thing to consider is whether you need bags at all: you could have
repeated properties:

  <dc:title>Practical digital libraries dbooks, bytes, and bucks</dc:title>
  <dc:subject>Special collections</dc:subject>

then the query part

	(?x, <dc:subject>, ?subj)

will range over the multiple occurrences of subject.

If you wish to pick the bag apart, you either ask for all properties and
then sieve out the ones that match the RDF syntax for member properties
(i.e. the property matches the regular expression

The other way is to use RDFS inference. In an RDFS model, you should be able
to query for rdfs:member.  (Note: this isn't in default settings in building
an RDFS inferencing model - you'll have to enable configure it - because it
needs to check every property in the model for the container member property
pattern and is expensive).


- - - -

For the bNodes, you can tell them apart either by looking at their
properties through the programmatic API (the objects returned in Jena for
RDQL results are the same underlying objects as the rest of the Model API)
or by additional parts to the query to distinguish the items.  At the
moment, the different bags al match the query pattern.  You may find you
need to ask more than one query if you wish to find items of different graph

There is a mailing list for Jena-specific questions:
jena-dev@groups.yahoo.com .


-------- Original Message --------
> From: carsten@spichal.com <mailto:carsten@spichal.com>
> Date: 2 February 2004 13:57
> Hi everybody!
> We are working with Jena 2.0. Right now we have some problems to
> retrieve the content of a RDF-bag. The RDF-data is build like this:
> <?xml version="1.0"?>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:dc="http://purl.org/dc/elements/1.1/"
> xmlns:dcterms="http://purl.org/dc/terms/"
> xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
> xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
> xmlns:unihi="http://www.uni-hildesheim.de/~semweb/submodel.rdf#">
> 	<rdf:Description>
> 	<dc:title>Practical digital libraries dbooks, bytes, and
> bucks</dc:title>
> 		<dc:creator>
> 			<vCard:N>
> 				<vCard:Family>Lesk</vCard:Family>
> 				<vCard:Given>Michael</vCard:Given>
> 			</vCard:N>
> 		</dc:creator>
> 		<dc:subject>
> 			<rdf:Bag>
> 			<rdf:li>Libraries</rdf:li>
> 			<rdf:li>Special collections</rdf:li>
> 			<rdf:li>Computer files</rdf:li>
> 			<rdf:li>United States</rdf:li>
> 			<rdf:li>Digital libraries</rdf:li>
> 			<rdf:li>Elektronische Bibliothek</rdf:li>
> 			</rdf:Bag>
> 		</dc:subject>
> 		<dc:subject>
> 			<rdf:Bag>
> 			<rdf:li>
> 				<unihi:hanke>
> 					<rdf:value/>
> 					<rdfs:label/>
> 				</unihi:hanke>
> 			</rdf:li>
> 			<rdf:li>
> 				<unihi:pica>
> 				<rdf:value>806.54</rdf:value>
> 		<rdfs:label>Bibliotheksautomatisierung</rdfs:label>
> 				</unihi:pica>
> 				</rdf:li>
> 				<rdf:li>
> 					<unihi:sachgruppe>
> 					<rdf:value>BUB 160</rdf:value>
> 					<rdfs:label/>
> 					</unihi:sachgruppe>
> 				</rdf:li>
> 			</rdf:Bag>
> 		</dc:subject>
> We have two questions:
> How can we retrieve a specific content of a bag?
> This is our query and the result! In line 6 of the query we try to
> recall the first element of the first bag. This works so far, but we
> would like to recall the whole bag. In the result we get also the b-node
> of the second bag. But we would like to avoid this because we are
> interested in retrieving the content of a specific bag (in this case the
> first bag).
> SELECT ?person,?title,?liste
> WHERE (?x, <dc:title>, ?title),
>       (?x, <dc:creator>, ?name),
>       (?name, <vCard:Family>, ?person),
>       (?x, <dc:subject>, ?bag),
>       (?bag, <rdf:_1>, ?liste)
> USING dc FOR <http://purl.org/dc/elements/1.1/>,
>       vCard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>,
>       rdf FOR <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> person       | title                       | liste
> =======================================================================
> "Lesk"       | "Practical digital ..."     | "Libraries"
> "Lesk"       | "Practical digital ..."     <15ac3c9:fa766df73b:-7ffc>
> And how can we distinguish between the two bags in the RDQL-Query?
> It would be nice if you could help us!
> A lot of greetings from Hildesheim, Germany!
> Carsten!
Received on Monday, 2 February 2004 12:46:59 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:07:49 UTC