Topic
  • 6 replies
  • Latest Post - ‏2009-11-08T16:16:02Z by SystemAdmin
SystemAdmin
SystemAdmin
32 Posts

Pinned topic SPARQL - Special characters

‏2009-11-04T15:04:33Z |
Hi,

How can I represent characters such as parenthesis in a SPARQL query? For example, how could I post this query without any errors:

PREFIX db: <http://dbpedia.org/resource/>
SELECT * WHERE {
db:Orange_(fruit) ?pf1 db:Fruit
}
Thank you,
Pedro
Updated on 2009-11-08T16:16:02Z at 2009-11-08T16:16:02Z by SystemAdmin
  • robertc
    robertc
    41 Posts

    Re: SPARQL - Special characters

    ‏2009-11-07T14:44:50Z  
    Hi Pedro. If you have a literal value you can enclose it in quotes, this query reports no syntax errors for me:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    "db:Orange_(fruit)" ?pf1 db:Fruit
    }

    Rob
  • SystemAdmin
    SystemAdmin
    32 Posts

    Re: SPARQL - Special characters

    ‏2009-11-07T22:12:53Z  
    • robertc
    • ‏2009-11-07T14:44:50Z
    Hi Pedro. If you have a literal value you can enclose it in quotes, this query reports no syntax errors for me:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    "db:Orange_(fruit)" ?pf1 db:Fruit
    }

    Rob
    The problem is it's not a literal value. It is a DBpedia resource: http://dbpedia.org/resource/Orange_(fruit)

    Any thoughts?

    Thanks
  • SystemAdmin
    SystemAdmin
    32 Posts

    Re: SPARQL - Special characters

    ‏2009-11-07T22:24:50Z  
    The problem is it's not a literal value. It is a DBpedia resource: http://dbpedia.org/resource/Orange_(fruit)

    Any thoughts?

    Thanks
    Actually, I would think that this should work: http://dbpedia.org/resource/Orange_%28fruit%29
    But apparently '%' isn't accepted either: 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '%'
  • robertc
    robertc
    41 Posts

    Re: SPARQL - Special characters

    ‏2009-11-08T01:21:13Z  
    The problem is it's not a literal value. It is a DBpedia resource: http://dbpedia.org/resource/Orange_(fruit)

    Any thoughts?

    Thanks
    Hi Pedro. So did you try putting that in quotes like the example I gave? Or is this resource appearing somewhere other than in the query you posted?

    Rob

    --Edit: OK, I'm seeing the same error as you now. Don't know why it worked for me earlier...

    Message was edited by: robertc
    Updated on 2009-11-08T01:21:13Z at 2009-11-08T01:21:13Z by robertc
  • robertc
    robertc
    41 Posts

    Re: SPARQL - Special characters

    ‏2009-11-08T01:49:20Z  
    Actually, I would think that this should work: http://dbpedia.org/resource/Orange_%28fruit%29
    But apparently '%' isn't accepted either: 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '%'
    Hi Pedro. I'm not sure if it's working, because I can't get it to return any data, but I think the correct syntax is to put angle brackets around the resource:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    <db:Orange_(fruit)> ?pf1 db:Fruit
    }

    When I use the above there are no errors, but all that appears on the results page is the column header pf1.

    Rob

    --edit Using the SPARQL Explorer I generated this example, which would imply a query like this is the correct form:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    <db:Orange_%28fruit%29> ?pf1 db:Fruit
    }

    Still no results for me, though.

    Message was edited by: robertc
    Updated on 2009-11-08T01:49:20Z at 2009-11-08T01:49:20Z by robertc
  • SystemAdmin
    SystemAdmin
    32 Posts

    Re: SPARQL - Special characters

    ‏2009-11-08T16:16:02Z  
    • robertc
    • ‏2009-11-08T01:40:35Z
    Hi Pedro. I'm not sure if it's working, because I can't get it to return any data, but I think the correct syntax is to put angle brackets around the resource:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    <db:Orange_(fruit)> ?pf1 db:Fruit
    }

    When I use the above there are no errors, but all that appears on the results page is the column header pf1.

    Rob

    --edit Using the SPARQL Explorer I generated this example, which would imply a query like this is the correct form:

    PREFIX db: <http://dbpedia.org/resource/>
    SELECT * WHERE {
    <db:Orange_%28fruit%29> ?pf1 db:Fruit
    }

    Still no results for me, though.

    Message was edited by: robertc
    It seems to me, after some testing against the dbpedia sparql endpoint, that substituting the parenthesis with %28 and %29 works only when prefixes are not used, and the resources are enclosed in ... Can anyone confirm this behavior?