1

From SPARQLwrapper I can successfully query and return results using SPARQL select. When I try to use the CONSTRUCT example from the website I get and error "ExpatError: no element found: line 1, column 0"

I've tested my code with a dbpedia example

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX sdo: <https://schema.org/>

    CONSTRUCT {
      ?lang a sdo:Language ;
      sdo:alternateName ?iso6391Code .
    }
    WHERE {
      ?lang a dbo:Language ;
      dbo:iso6391Code ?iso6391Code .
      FILTER (STRLEN(?iso6391Code)=2) # to filter out non-valid values
    }
    LIMIT 3
""")

results = sparql.queryAndConvert()

print("results")
print(results.serialize())
print("- - - - - - - - -")

the DBpedia example works fine.But, when trying the same on Uniprot like this ...

sparql = SPARQLWrapper("http://sparql.uniprot.org/sparql")
sparql.setQuery("""
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
CONSTRUCT
{
    ?protein a up:HumanProtein .
}
WHERE
{
    ?protein a up:Protein .
    ?protein up:organism taxon:9606 .
}
""")

results = sparql.queryAndConvert()

I get this error

"ExpatError: no element found: line 1, column 0"

scuffster
  • 51
  • 1

1 Answers1

0

Could you try going directly to https://sparql.uniprot.org as this might be the issue.

Jerven
  • 582
  • 3
  • 7