1
votes

I have a query which I run inside protege(owl version 3.4.2). I have an apostrophe in the middle.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wel: <http://www.semanticweb.org/dell/ontologies/2014/2/untitled-ontology-11#>
SELECT (strafter(str(?o), '#') AS ?gender) 
WHERE { wel:Grandmother's_house ?classOf  ?o . }

The query breaks from the apostrophe. I tried using \ in front of '. But it didn't work. I found this link. http://www.w3.org/TR/rdf-sparql-query/#QSynLiterals. After following that I did something like this, WHERE { wel:Grandmother< STRING_LITERAL1>s_house ?classOf ?o . } . Still no use. How can I escape the apostrophe in my query?

1
You should clarify that it's the apostrophe in wel:Grandmother's_house. I spent a while looking at earlier single quotes in strafter(str(?o), '#') for a while, thinking to myself "that looks OK…"Joshua Taylor
oh yes, sorry, I was concentrating on the apostrophe on wel:Grandmother's_house , that I forgot I have apostrophes before that also. My apologies.user3462940

1 Answers

6
votes

You can write wel:Grandmother\'s_house. That said, it was a fairly late addition to SPARQL 1.1 and you may be using a system with a before-the-final-spec version of the language.

Otherwise you need to write out the full URI in <>.