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

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#>, rdfs for <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


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

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
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev

Reply via email to