- From: Amit Krishna Joshi <joshi.35@wright.edu>
- Date: Fri, 12 Aug 2011 11:54:39 -0700
- To: 'Mischa Tuffield' <mischa.tuffield@garlik.com>, 'Andy Seaborne' <andy.seaborne@epimorphics.com>
- Cc: semantic-web@w3.org
I am not sure how expensive regex is compared to string comparison (for this type of query) but here's one using regex: Query and output saved at: http://www.s3space.com/?p=308 PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT * WHERE { ?x ?p "Grand Prix"@en. FILTER regex(str(?p), "^http://xmlns.com/foaf/0.1", "i") } limit 4 Regards, Amit Joshi http://www.s3space.com/ (Query the LOD) -----Original Message----- From: semantic-web-request@w3.org [mailto:semantic-web-request@w3.org] On Behalf Of Mischa Tuffield Sent: Friday, August 12, 2011 10:20 AM To: Andy Seaborne Cc: semantic-web@w3.org Subject: Re: SPARQL queries property or class from a schema Excuse the top-post. You can brutal about it in SPARQL 1.0 and use filter regex. Something like : .. FILTER ( regex( str(?p), "/http:\/\/xmlns\.com\/foaf/") ) It is kinda nasty, but will do the trick! Mischa Sent on the move On Aug 12, 2011, at 5:55 PM, Andy Seaborne <andy.seaborne@epimorphics.com> wrote: > > > On 12/08/11 17:36, Jitao Yang wrote: >> Dear all, >> >> suppose we have DATA: >> >> @prefix foaf: <http://xmlns.com/foaf/0.1/> . >> >> _:a foaf:name "Johnny Lee Outlaw" . >> _:a foaf:mbox <mailto:jlow@example.com <mailto:jlow@example.com>> . >> _:b foaf:name "Peter Goodguy" . >> _:b foaf:mbox <mailto:peter@example.org <mailto:peter@example.org>> . >> _:c foaf:mbox <mailto:carol@example.org <mailto:carol@example.org>> . >> >> >> can we write a SPARQL query like: >> >> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT *?property* >> >> WHERE{ >> ?x foaf:*?property* "Peter Goodguy". >> } >> >> if we can not, can we write an equivalent SPARQL query? Namely, can >> we decompose schema and Class(or Property) in SPARQL query? >> >> Thanks, >> Jitao > > SPARQL 1.1: > > PREFIX foaf: <http://xmlns.com/foaf/0.1/> > SELECT ( substr( str(?p), strlen(str(foaf:))+1 ) > AS ?property) > > WHERE{ > ?x ?p "Peter Goodguy". > } > > > > In SPARQL 1.0, you can't return anything not already in the graph : in SPARQL 1.1 you can do some manipulation of RDF terms. > > Because SUBSTR is fn:substring, indexes are 1-based. > > Andy >
Received on Monday, 15 August 2011 17:45:28 UTC