0

Given This RDF:

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE rdf:RDF [<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>]>
<rdf:RDF xmlns:xsd="http://www.w3.org/2001/XMLSchema#" 
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
         xml:base="http://www.example.org/" 
         xmlns:dnr="http://www.dotnetrdf.org/configuration#" 
         xmlns:nss="http://www.example.org/startTime" 
         xmlns:nse="http://www.example.org/endTime#" 
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 >
  <rdf:Description rdf:about="Fadi">
    <ns2914:be xmlns:ns2914="http://example.org/">May</ns2914:be>
    <nss:startTime>00:00:13</nss:startTime>
    <nse:endTime>00:00:16</nse:endTime>
  </rdf:Description>
  <rdf:Description rdf:about="Fadi">
    <ns194:not xmlns:ns194="http://example.org/">Good</ns194:not>
    <nss:startTime>00:00:19</nss:startTime>
    <nse:endTime>00:00:21</nse:endTime>
  </rdf:Description>
  <rdf:Description rdf:about="She">
    <ns195:be xmlns:ns195="http://example.org/">Good</ns195:be>
    <nss:startTime>00:00:21</nss:startTime>
    <nse:endTime>00:00:24</nse:endTime>
   </rdf:Description>
</rdf:RDF>

how to get the startTime and endTime with query about Object? i Tried to use:

 PREFIX nss: <http://www.example.org/startTime>
 PREFIX nse: <http://www.example.org/endTime#> 
 SELECT * 
 WHERE 
 { 
   ?s ?p ?o .
   FILTER(REGEX(?o, 'Good', 'i'))
   ?s nss:startTime ?startTime ;
      nse:endTime ?endTime .
 }

But it only gave me the first ?startTime and ?endTime For The Subject it find for Object Good.

I need The following answers:

?s,?p,?o,?startTime,?endTime
Fadi,not,Good,00:00:19,00:00:21
She,be,Good,00:00:21,00:00:24
RobV
  • 28,022
  • 11
  • 77
  • 119
Hasan Sarraj
  • 92
  • 1
  • 8
  • 2
    @Hassan Sarraj Clearly you are new to SPARQL and don't really understand it yet, I would recommend going and reading a good SPARQL tutorial such as http://www.cambridgesemantics.com/semantic-university/sparql-by-example – RobV May 06 '13 at 16:42
  • Your document contains a description of one resource with three distinct data properties. The triples here are: `It be 'May'`, `It startTime '00:00:13'` and `It endTime '00:00:16'`. The way you query and filter them, the first one is bound to be the only result. Is this what you want: `SELECT ?s ?p ?o WHERE { ?s ns2914:be ?month. ?s ?p ?o. FILTER(regex(?month, 'May', 'i')) }` ??? – toniedzwiedz May 06 '13 at 16:43
  • no i need to query about may.. and from this query i need to get the startTime and endTime. – Hasan Sarraj May 06 '13 at 16:47
  • i edited the question, i hope u understand me now. @Tom – Hasan Sarraj May 06 '13 at 19:09
  • @Joshua Taylor Can you Help me? – Hasan Sarraj May 06 '13 at 21:35

1 Answers1

1

Your query doesn't select that data so why are you surprised it isn't returned? As I suggested in the comment go read a good SPARQL tutorial like SPARQL by Example or pick up a copy of the excellent Learning SPARQL book from O'Reilly

The query you wrote selects triples where the object matches a regular expression and only those triples. If you want to select the start and end times as well you need to add additional patterns to your queries e.g.

PREFIX nss: <http://www.example.org/startTime>
PREFIX nse: <http://www.example.org/endTime#>
SELECT *
WHERE
{
  ?s ?p ?o .
  FILTER(REGEX(?o, "May", "i"))
  ?s nss:startTime ?startTime ;
     nse:endTime ?endTime .
}
RobV
  • 28,022
  • 11
  • 77
  • 119
  • 2
    @HasanSarraj saying it doesn't work without an attempt at explaining what exactly makes it fail your expectations hardly counts as helpful. You have to elaborate a little. – toniedzwiedz May 06 '13 at 17:12