<HTML dir=ltr><HEAD>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16588"></HEAD>
<BODY bgColor=#ffffff text=#006600>
<DIV dir=ltr id=idOWAReplyText30471>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>I have taken an rdf file and serialized it to turtle format (see extract of data in turtle format below): </FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT color=#ff0000 size=2 face=Arial>EXTRACT OF DATA IN TURTLE FORMAT</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial><A href="mailto:f@prefix">@prefix</A> rdf: <<A href="http://www.w3.org/1999/02/22-rdf-syntax-ns">http://www.w3.org/1999/02/22-rdf-syntax-ns</A>#> .<BR>@prefix Content: <<A href="http://www.news-project.com/Ontology/Content">http://www.news-project.com/Ontology/Content</A>#> .<BR>@prefix core: <<A href="http://www.w3.org/2004/02/skos/core">http://www.w3.org/2004/02/skos/core</A>#> .<BR>@prefix rdf__: <<A href="http://protege.stanford.edu/rdf">http://protege.stanford.edu/rdf</A>> .<BR>@prefix rdfs: <<A href="http://www.w3.org/2000/01/rdf-schema">http://www.w3.org/2000/01/rdf-schema</A>#> .</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>rdf__:KB_719208_Slot_4<BR> a rdf:Property;<BR> rdfs:label "rdf_:KB_719208_Slot_4";<BR> rdfs:range rdfs:Literal .</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Content:Abstract<BR> a rdfs:Class;<BR> rdfs:label "Content:Abstract";<BR> rdfs:comment "Documentation on Abstract(SUMO): Properties or qualities as d<BR>istinguished from any particular embodiment of the properties/qualities in a phy<BR>sical medium. Instances of Abstract can be said to exist in the same sense as ma<BR>thematical objects such as sets and relations, but they cannot exist at a partic<BR>ular place and time without some physical encoding or embodiment.";<BR> rdfs:subClassOf Content:Entity .</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Content:Address<BR> a rdfs:Class;<BR> rdfs:label "Content:Address";<BR> rdfs:comment "Documentation on Address(MILO): An Attribute that indicates a<BR>n address where an Agent can regularly be contacted. In NITF v3.2 the element \"<BR>postaddr\" can be used to annotate addresses in the item's content, for instance<BR>, inside a \"p\" element.";<BR> rdfs:subClassOf Content:Attribute .</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Content:AgeGroup<BR> a rdfs:Class;<BR> rdfs:label "Content:AgeGroup";<BR> rdfs:comment "Documentation on AgeGroup(SUMO): A GroupOfPeople whose member<BR>s all have the same age or have and age which is inside a certain age interval (<BR>example, persons between 18 and 25 years)";<BR> rdfs:subClassOf Content:GroupOfPeople .<BR></FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>My original program contained rdf query which stated the name of the data file and the uris for rdf and rdfs.</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>How can I change the query in the program to:</FONT></DIV>
<DIV dir=ltr>select ?childNode<BR>where { ?childNode rdfs:subClassOf :Group . }<BR></DIV>
<DIV dir=ltr><FONT color=#0000ff>will I have to include any prefix info into the query or will that be picked up from the data file?</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial> </DIV></FONT>
<DIV dir=ltr><FONT color=#ff0000 size=2 face=Arial>EXTRACT FROM ORIGINAL PROGRAM:</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>#include <stdio.h><BR>#include <rasqal.h><BR>#include <raptor.h></FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>main()<BR>{<BR> int i;<BR> rasqal_query *rq;<BR> rasqal_query_results *results;<BR> rasqal_literal *value;<BR> raptor_iostream *qo;<BR> 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 <<A href="http://www.w3.org/1999/02/22-rdf-syntax-ns">http://www.w3.org/1999/02/22-rdf-syntax-ns</A>#>, rdfs for <<A href="http://www.w3.org/2000/01/rdf-schema">http://www.w3.org/2000/01/rdf-schema</A>#>";<BR>const char *qfilename="queryoutput";<BR>rasqal_init();<BR>rq=rasqal_new_query("rdql",NULL);<BR>raptor_init();<BR>qo=raptor_new_iostream_to_filename(qfilename);</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>........</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Thank you for the help given so far</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Jagdev</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Joe Andrieu [mailto:joe@switchbook.com]<BR><B>Sent:</B> Mon 21/06/2010 20:29<BR><B>To:</B> Jagdev Bhogal<BR><B>Cc:</B> redland-dev@lists.librdf.org<BR><B>Subject:</B> Re: [redland-dev] xpath query<BR></FONT><BR></DIV>
<DIV>
<BLOCKQUOTE>Jagdev,<BR><BR>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.<BR><BR>If I rewrite your rdf as Turtle, I think I get something like this:<BR><BR>:AgeGroup rdfs:label "AgeGroup";<BR> 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)";<BR> rdfs:subClassOf :GroupOfPeople.<SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><BR><BR></SPAN>:GroupOfPeople rdfs:label "GroupOfPeople";<BR> 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.";<BR> rdfs:subClassOf :Group;<BR><BR>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).<BR><BR><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN>a)<SPAN style="LINE-HEIGHT: normal; FONT-VARIANT: normal; FONT-STYLE: normal; FONT-SIZE: 7pt; FONT-WEIGHT: normal; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">All childnodes of the class called Group</SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN><BR></SPAN></SPAN>select ?childNode<BR>where { ?childNode rdfs:subClassOf :Group . }<BR><BR><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN></SPAN></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN>b)<SPAN style="LINE-HEIGHT: normal; FONT-VARIANT: normal; FONT-STYLE: normal; FONT-SIZE: 7pt; FONT-WEIGHT: normal; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">All parentnodes of the class called AgeGroup<BR></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN>select ?parentNode<BR>where { :AgeGroup rdfs:subClassOf ?parentNode .}<BR><BR>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.<BR><BR>As for the question about using Turtle in c, that's what Redland is for. =)<BR><BR>-j<BR><BR></BLOCKQUOTE><PRE class=moz-signature cols="72">Joe Andrieu
<A class=moz-txt-link-abbreviated href="mailto:joe@switchbook.com">joe@switchbook.com</A>
+1 (805) 705-8651
<A class=moz-txt-link-freetext href="http://www.switchbook.com/">http://www.switchbook.com</A>
</PRE><BR>On 6/21/2010 12:09 PM, Jagdev Bhogal wrote:
<BLOCKQUOTE cite="" type="cite">
<DIV dir=ltr id=idOWAReplyText86059>
<DIV dir=ltr> </DIV></DIV>
<DIV dir=ltr><BR><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </DIV>
<DIV>
<BLOCKQUOTE cite="" type="cite">
<DIV class=WordSection1>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">From the following extract we can see that AgeGroup is a descendant of GroupofPeople and GroupofPeople is a descendant of Group</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><rdfs:Class rdf:about="&Content;AgeGroup"</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> rdfs:label="Content:AgeGroup"></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> <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</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">ns between 18 and 25 years)</rdfs:comment></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> <rdfs:subClassOf rdf:resource="&Content;GroupOfPeople"/></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></rdfs:Class></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><rdfs:Class rdf:about="&Content;GroupOfPeople"</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> rdfs:label="Content:GroupOfPeople"></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> <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</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">rest for a certain news item. Examples of GroupOfPeople include age groups, religious groups, etc.</rdfs:comment></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> <rdfs:subClassOf rdf:resource="&Content;Group"/></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></rdfs:Class></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">QUESTION</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">How can I write the query so that it retrieves :</SPAN></P>
<P style="TEXT-INDENT: -18pt" class=MsoListParagraph><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN>a)<SPAN style="LINE-HEIGHT: normal; FONT-VARIANT: normal; FONT-STYLE: normal; FONT-SIZE: 7pt; FONT-WEIGHT: normal; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">All childnodes of the class called Group</SPAN></P>
<P style="TEXT-INDENT: -18pt" class=MsoListParagraph><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"><SPAN>b)<SPAN style="LINE-HEIGHT: normal; FONT-VARIANT: normal; FONT-STYLE: normal; FONT-SIZE: 7pt; FONT-WEIGHT: normal; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">All parentnodes of the class called AgeGroup</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Please point me in the right direction, or am I trying to achieve something that is not possible?</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Is it possible to use TURTLE within a C program to achieve the above?</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Many, many thanks</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Jagdev</SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<P class=MsoNormal><SPAN style="COLOR: rgb(31,73,125); FONT-SIZE: 11pt"></SPAN> </P>
<DIV>
<DIV style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: rgb(181,196,223) 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<P class=MsoNormal><B><SPAN style="COLOR: windowtext; FONT-SIZE: 10pt" lang=EN-US>From:</SPAN></B><SPAN style="COLOR: windowtext; FONT-SIZE: 10pt" lang=EN-US> Joe Andrieu [<A class=moz-txt-link-freetext href="mailto:joe@switchbook.com">mailto:joe@switchbook.com</A>] <BR><B>Sent:</B> 20 June 2010 19:05<BR><B>To:</B> Jagdev Bhogal<BR><B>Cc:</B> <A class=moz-txt-link-abbreviated href="mailto:redland-dev@lists.librdf.org">redland-dev@lists.librdf.org</A><BR><B>Subject:</B> Re: [redland-dev] xpath query</SPAN></P></DIV></DIV>
<P class=MsoNormal> </P>
<P class=MsoNormal>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.<BR><BR>Something like</P>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt"><BR>char keyword[]="City";</SPAN></P></DIV>
<DIV>
<P style="MARGIN-BOTTOM: 12pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt">char query_string[BIGENOUGHBUFFER];<BR><BR>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 <A href="http://www.w3.org/1999/02/22-rdf-syntax-ns"><http://www.w3.org/1999/02/22-rdf-syntax-ns#></A>, rdfs for <A href="http://www.w3.org/2000/01/rdf-schema"><http://www.w3.org/2000/01/rdf-schema#></A>", keyword);</SPAN></P></DIV>
<P class=MsoNormal>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.<BR><BR>-j<BR><BR><BR></P><PRE>Joe Andrieu</PRE><PRE><A href="mailto:joe@switchbook.com">joe@switchbook.com</A></PRE><PRE>+1 (805) 705-8651</PRE><PRE><A href="http://www.switchbook.com/">http://www.switchbook.com</A></PRE>
<P class=MsoNormal><BR>On 6/20/2010 4:11 AM, Jagdev Bhogal wrote: </P>
<DIV>
<P class=MsoNormal><SPAN style="COLOR: black; FONT-SIZE: 10pt">Dear all</SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">I have a c-program which currently parses an rdf file and retrieves all of the nodes using:</SPAN></P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">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 <<A href="http://www.w3.org/1999/02/22-rdf-syntax-ns#%3E,rdfs">http://www.w3.org/1999/02/22-rdf-syntax-ns#>,rdfs</A> for <<A href="http://www.w3.org/2000/01/rdf-schema">http://www.w3.org/2000/01/rdf-schema</A>#>";</SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">Lets say I have a string defined as:</SPAN></P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">char keyword[]="City";</SPAN></P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">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". </SPAN></P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">If further explanation is needed let me know.</SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">Thank you</SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt">Jagdev</SPAN></P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<P class=MsoNormal> </P></DIV>
<DIV>
<DIV style="TEXT-ALIGN: center" class=MsoNormal align=center>
<HR align=center SIZE=2 width="100%">
</DIV>
<P class=MsoNormal>Through our significant contribution to the creative industries and the city's cultural and artistic life,<BR>Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013<BR><BR><A href="http://birminghamculture.org/">http://birminghamculture.org</A><BR><A href="http://www.bcu.ac.uk/about-us/excellent-arts">http://www.bcu.ac.uk/about-us/excellent-arts</A> </P></DIV><PRE> </PRE><PRE style="TEXT-ALIGN: center"><HR align=center SIZE=4 width="90%">
</PRE><PRE> </PRE><PRE>_______________________________________________</PRE><PRE>redland-dev mailing list</PRE><PRE><A href="mailto:redland-dev@lists.librdf.org">redland-dev@lists.librdf.org</A></PRE><PRE><A href="http://lists.librdf.org/mailman/listinfo/redland-dev">http://lists.librdf.org/mailman/listinfo/redland-dev</A></PRE></DIV>
<DIV>
<HR>
Through our significant contribution to the creative industries and the city's cultural and artistic life,<BR>Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013<BR><BR><A class=moz-txt-link-freetext href="http://birminghamculture.org/">http://birminghamculture.org</A><BR><A class=moz-txt-link-freetext href="http://www.bcu.ac.uk/about-us/excellent-arts">http://www.bcu.ac.uk/about-us/excellent-arts</A> </DIV></BLOCKQUOTE></DIV>
<DIV>
<HR>
Through our significant contribution to the creative industries and the city's cultural and artistic life,<BR>Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013<BR><BR><A class=moz-txt-link-freetext href="http://birminghamculture.org/">http://birminghamculture.org</A><BR><A class=moz-txt-link-freetext href="http://www.bcu.ac.uk/about-us/excellent-arts">http://www.bcu.ac.uk/about-us/excellent-arts</A> </DIV><PRE><HR SIZE=4 width="90%">
_______________________________________________
redland-dev mailing list
<A class=moz-txt-link-abbreviated href="mailto:redland-dev@lists.librdf.org">redland-dev@lists.librdf.org</A>
<A class=moz-txt-link-freetext href="http://lists.librdf.org/mailman/listinfo/redland-dev">http://lists.librdf.org/mailman/listinfo/redland-dev</A></PRE></BLOCKQUOTE></DIV>
<DIV><P><HR>
Through our significant contribution to the creative industries and the city's cultural and artistic life,<BR>
Birmingham City University is proud to support Birmingham's bid to be UK City of Culture in 2013<BR>
<BR>
http://birminghamculture.org<BR>
http://www.bcu.ac.uk/about-us/excellent-arts
</P></DIV>
</BODY></HTML>