-1

I should mention I'm beginner in the semantic web world. My turtle file has following structure:

@prefix ns0: <http://www.cws.org/ep/01#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .    
#...
        <file:///C:/Users/Anis/Downloads/usdl-editor-master/usdl-editor-master/index.html#OSZwMOW5JiZTlJXb7>
          a ns0:GuaranteedState ;
          ns0:executionParameterType [
            a ns0:executionParameterType ;
            dc:description "Description Inpuuut" ;
            ns0:hasVariable <file:///C:/index.html#ekHCp7iFi1aEWM7QQ>

          ] ;
          dc:title "Input" .

        <file:///C:/index.html#ekHCp7iFi1aEWM7QQ>
          a ns0:Variable ;
          ns0:hasDefault [
            a gr:QuantitativeValue ;
            gr:hasValue "document.csv" ;
            gr:hasUnitOfMeasurement "csv"
          ] ;
          rdfs:label "test1" .
    #...

I'm trying to Filter by dc:title = "Input".

This is my query, what shall I add?

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 ns0: <http://www.cws.org/ep/01#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX gr: <http://purl.org/goodrelations/v1#>
SELECT   *
WHERE   { 

          ?path  dc:title ?x

}

My query result displays always the "@".. I don't know what does it mean?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Anis Elloumi
  • 23
  • 1
  • 4

3 Answers3

1

If an exact match will get what you want, then specify that directly in the triple pattern, e.g.:

SELECT ?path
WHERE {
   ?path dc:title "Title" .
}

..which get any ?path that has the value "Title" for the dc:title property. E.g., <file:///C:/Users/Anis/Downloads/usdl-editor-master/usdl-editor-master/index.html#OSZwMOW5JiZTlJXb7> will match in your example.

If the match is not exact, then using a FILTER with regex() should work.

SELECT ?path
WHERE {
   ?path dc:title ?x .
   FILTER regex(?x, "Title", "i")
}

...which matches any dc:title property with "Title" in the string, ignoring case.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24
  • 1
    Rather than regex, I'd prefer `"title" = lcase(?title)` to match case insensitively. Otherwise,if the literal title has characters that are meaningful in a regular expression pattern, you'll be doing more matching than you planned on. E.g., any . would match any character, and $ and ^ would match line ends, etc. – Joshua Taylor Sep 20 '16 at 10:26
  • The assumption in the second example is that they are looking for an exact match, not a case-insensitive match. In this case it matches any string with "title" in it. – scotthenninger Sep 27 '16 at 15:11
  • If the assumption "is that they are looking for an exact match, not a case-insensitive match", then the ["i" flag](https://www.w3.org/TR/xpath-functions/#flags), which makes the match case-insensitive, should **not** be included. But even so, for a case insensitive containment match, isn't `contains(?x, "Title")` much clearer? And again, it avoids any issues with the regex matcher, like if the string literal contains regex-meaningful characters, like ".". – Joshua Taylor Sep 27 '16 at 15:51
0

This is just a thought, but I reckon a FILTER clause might be what you need:

 FILTER(?x = "Input") 

should do the trick.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
  • The problem is fixed .. I added @whatever (eg. "@en") in my structure file then I added the following line to my querry : FILTER(?x = "Input"@en) that's what I meant , in my case "@en" is required. – Anis Elloumi Sep 21 '16 at 13:39
-1

The problem is fixed.. In my case I must add @whatever (eg. "@en") to my structure file .. Then I added this line to my query : FILTER(?x = "Input"@en). The following my query:

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 ns0: <http://www.cws.org/ep/01#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX gr: <http://purl.org/goodrelations/v1#>
SELECT *
 WHERE { 
 ?path dc:title ?x .
FILTER (?x = "Input"@en)
}
Anis Elloumi
  • 23
  • 1
  • 4
  • Since the example data in your question doesn't contain a language tag, this doesn't actually answer the question you asked. – Jeen Broekstra Sep 21 '16 at 21:13
  • though i didn't have "@sth.." in my file , the query result display is always with "@" at the end. In addition,Just FILTER (?x = "Input"@) doesn't work , So In my case I added "@en" in my file structure then I applied FILTER (?x = "Input"@en) and it works. – Anis Elloumi Sep 22 '16 at 01:38