HttpException error when I call SPARQL query (on DBPedia) in Java Code

前端 未结 1 1961
清歌不尽
清歌不尽 2021-01-29 06:38

I have a problem with SPARQL endpoint using Java Code.

In particular, I have this Java Class:

public class example {

    public static void main(String[         


        
相关标签:
1条回答
  • 2021-01-29 07:03

    You've got two queries here. At the end of your question, you use a query that has no filter, but that's different from the query that's embedded in your code. If you use the query embedded in your code on DBpedia's endpoint, you get a very clear error message:

    Virtuoso 22023 Error SL001: The SPARQL 1.1 function STRSTARTS() needs a string value as 2d argument
    
    SPARQL query:
    define sql:big-data-const 0 
    #output-format:text/html
    define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> prefix dbpediaont: <http://dbpedia.org/ontology/>
    prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    
    select ?resource where {
    ?mat rdf:type ?resource
    filter strstarts(str(?resource), dbpediaont:)
    }
    

    The key is

    The SPARQL 1.1 function STRSTARTS() needs a string value as 2d argument

    You need to write dbpediaont: with str() since it's an IRI, not a string:

    filter strstarts(str(?resource), str(dbpediaont:))
    
    0 讨论(0)
提交回复
热议问题