[redland-dev] xpath query
Jagdev Bhogal
Jagdev.Bhogal at bcu.ac.uk
Mon Jun 21 21:09:19 CEST 2010
From the following extract we can see that AgeGroup is a descendant of GroupofPeople and GroupofPeople is a descendant of Group
<rdfs:Class rdf:about="&Content;AgeGroup"
rdfs:label="Content:AgeGroup">
<rdfs:comment>Documentation on AgeGroup(SUMO): A GroupOfPeople whose members all have the same age or have and age which is inside a certain age interval (example, perso
ns between 18 and 25 years)</rdfs:comment>
<rdfs:subClassOf rdf:resource="&Content;GroupOfPeople"/>
</rdfs:Class>
<rdfs:Class rdf:about="&Content;GroupOfPeople"
rdfs:label="Content:GroupOfPeople">
<rdfs:comment>Documentation on GroupOfPeople(SUMO): Any Group whose members are exclusively Humans. The instances of this class are used for annotation of groups of inte
rest for a certain news item. Examples of GroupOfPeople include age groups, religious groups, etc.</rdfs:comment>
<rdfs:subClassOf rdf:resource="&Content;Group"/>
</rdfs:Class>
QUESTION
How can I write the query so that it retrieves :
a) All childnodes of the class called Group
b) All parentnodes of the class called AgeGroup
Please point me in the right direction, or am I trying to achieve something that is not possible?
Is it possible to use TURTLE within a C program to achieve the above?
Many, many thanks
Jagdev
From: Joe Andrieu [mailto:joe at switchbook.com]
Sent: 20 June 2010 19:05
To: Jagdev Bhogal
Cc: redland-dev at lists.librdf.org
Subject: Re: [redland-dev] xpath query
I"m not sure which query module you're using, but with SPARQL, you would just get rid of the ?label term and use "City" instead. In fact, whatever the query engine, you can probably just use sprintf or something similar to construct the query clause with "City" in place of ?label.
Something like
char keyword[]="City";
char query_string[BIGENOUGHBUFFER];
sprintf(query_string, "select ?comment from <C:/datafile.rdf> where (?x rdf:type rdfs:Class) (?x rdfs:label \"%s\") (?x rdfs:comment ?comment) using rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://www.w3.org/1999/02/22-rdf-syntax-ns> , rdfs for <http://www.w3.org/2000/01/rdf-schema#> <http://www.w3.org/2000/01/rdf-schema> ", keyword);
I won't address the potential unicode and buffer overrun problems. I prefer c++ classes to deal with the buffer issues and haven't yet settled completely on how I'm handling unicode.
-j
Joe Andrieu
joe at switchbook.com
+1 (805) 705-8651
http://www.switchbook.com <http://www.switchbook.com/>
On 6/20/2010 4:11 AM, Jagdev Bhogal wrote:
Dear all
I have a c-program which currently parses an rdf file and retrieves all of the nodes using:
const char *query_string="select ?label, ?comment from <C:/datafile.rdf> where (?x rdf:type rdfs:Class) (?x rdfs:label ?label) (?x rdfs:comment ?comment) using rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,rdfs <http://www.w3.org/1999/02/22-rdf-syntax-ns#%3E,rdfs> for <http://www.w3.org/2000/01/rdf-schema#>";
Lets say I have a string defined as:
char keyword[]="City";
My question is can we have a where clause in the query, so that we only retrieve results where the strcmp(label, keyword) = 0 in other words only retrieve those results where the label is equal to the keyword which in this case is "City".
If further explanation is needed let me know.
Thank you
Jagdev
________________________________
Through our significant contribution to the creative industries and the city's cultural and artistic life,
Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013
http://birminghamculture.org <http://birminghamculture.org/>
http://www.bcu.ac.uk/about-us/excellent-arts
________________________________
_______________________________________________
redland-dev mailing list
redland-dev at lists.librdf.org
http://lists.librdf.org/mailman/listinfo/redland-dev
________________________________
Through our significant contribution to the creative industries and the city's cultural and artistic life,
Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013
http://birminghamculture.org <http://birminghamculture.org/>
http://www.bcu.ac.uk/about-us/excellent-arts
Through our significant contribution to the creative industries and the city's cultural and artistic life,
Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013
http://birminghamculture.org
http://www.bcu.ac.uk/about-us/excellent-arts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.librdf.org/pipermail/redland-dev/attachments/20100621/3c0f4cd2/attachment.htm
More information about the redland-dev
mailing list