I have taken an rdf file and serialized it to turtle format (see extract of
data in turtle format below):
EXTRACT OF DATA IN TURTLE FORMAT
@prefix <mailto:f...@prefix> rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix Content: <http://www.news-project.com/Ontology/Content#> .
@prefix core: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdf__: <http://protege.stanford.edu/rdf> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
rdf__:KB_719208_Slot_4
a rdf:Property;
rdfs:label "rdf_:KB_719208_Slot_4";
rdfs:range rdfs:Literal .
Content:Abstract
a rdfs:Class;
rdfs:label "Content:Abstract";
rdfs:comment "Documentation on Abstract(SUMO): Properties or qualities as d
istinguished from any particular embodiment of the properties/qualities in a phy
sical medium. Instances of Abstract can be said to exist in the same sense as ma
thematical objects such as sets and relations, but they cannot exist at a partic
ular place and time without some physical encoding or embodiment.";
rdfs:subClassOf Content:Entity .
Content:Address
a rdfs:Class;
rdfs:label "Content:Address";
rdfs:comment "Documentation on Address(MILO): An Attribute that indicates a
n address where an Agent can regularly be contacted. In NITF v3.2 the element \"
postaddr\" can be used to annotate addresses in the item's content, for instance
, inside a \"p\" element.";
rdfs:subClassOf Content:Attribute .
Content:AgeGroup
a rdfs:Class;
rdfs:label "Content:AgeGroup";
rdfs:comment "Documentation on AgeGroup(SUMO): A GroupOfPeople whose member
s all have the same age or have and age which is inside a certain age interval (
example, persons between 18 and 25 years)";
rdfs:subClassOf Content:GroupOfPeople .
My original program contained rdf query which stated the name of the data file
and the uris for rdf and rdfs.
How can I change the query in the program to:
select ?childNode
where { ?childNode rdfs:subClassOf :Group . }
will I have to include any prefix info into the query or will that be picked up
from the data file?
EXTRACT FROM ORIGINAL PROGRAM:
#include <stdio.h>
#include <rasqal.h>
#include <raptor.h>
main()
{
int i;
rasqal_query *rq;
rasqal_query_results *results;
rasqal_literal *value;
raptor_iostream *qo;
const char *query_string="select ?label, ?comment from <file:/data.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 for
<http://www.w3.org/2000/01/rdf-schema#>";
const char *qfilename="queryoutput";
rasqal_init();
rq=rasqal_new_query("rdql",NULL);
raptor_init();
qo=raptor_new_iostream_to_filename(qfilename);
........
Thank you for the help given so far
Jagdev
________________________________
From: Joe Andrieu [mailto:[email protected]]
Sent: Mon 21/06/2010 20:29
To: Jagdev Bhogal
Cc: [email protected]
Subject: Re: [redland-dev] xpath query
Jagdev,
I'm not sure what your question is for Turtle. Turtle is a
serialization of RDF. It's probably the easiest way to put triples in an email.
SPARQL is a query language syntactically inspired by Turtle.
If I rewrite your rdf as Turtle, I think I get something like this:
:AgeGroup rdfs:label "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, persons between 18 and 25 years)";
rdfs:subClassOf :GroupOfPeople.
:GroupOfPeople rdfs:label "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 interest for a certain news item. Examples of
GroupOfPeople include age groups, religious groups, etc.";
rdfs:subClassOf :Group;
If that is a correct interpretation (I wasn't sure what you were doing
with &Content:), then these queries should work (they are SPARQL format, minus
prefixes).
a) All childnodes of the class called Group
select ?childNode
where { ?childNode rdfs:subClassOf :Group . }
b) All parentnodes of the class called AgeGroup
select ?parentNode
where { :AgeGroup rdfs:subClassOf ?parentNode .}
Basically, the trick is to determine the RDF triple(s) that would state
the relationship, then put the variable terms in place of what you're looking
for.
As for the question about using Turtle in c, that's what Redland is
for. =)
-j
Joe Andrieu
[email protected]
+1 (805) 705-8651
http://www.switchbook.com <http://www.switchbook.com/>
On 6/21/2010 12:09 PM, Jagdev Bhogal wrote:
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:[email protected]]
Sent: 20 June 2010 19:05
To: Jagdev Bhogal
Cc: [email protected]
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
[email protected]
+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
[email protected]
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://birminghamculture.org/>
http://www.bcu.ac.uk/about-us/excellent-arts
________________________________
_______________________________________________
redland-dev mailing list
[email protected]
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://www.bcu.ac.uk/about-us/excellent-arts
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev