Pregunta

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
¿Fue útil?

Solución

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 .
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top