pldn / LDWizard

🧙 LDWizard: A generic framework for simplifying the creation of linked data. Supported by the PLDN community.
European Union Public License 1.2
13 stars 7 forks source link

Issue when using different SPARQL endpoints #8

Closed vemonet closed 1 year ago

vemonet commented 2 years ago

Hi, I am trying to use a different SPARQL endpoint than TriplyDB for predicate and class completion

Unfortunately it seems that the LDWizard expect the SPARQL endpoint to return JSON by default (for example see: https://api.data.netwerkdigitaalerfgoed.nl/datasets/ld-wizard/sdo/services/sparql/sparql?query=select%20*%20where%20{?s%20?p%20?o%20.}%20limit%2010 )

If I try to use a Ontotext GraphDB or a Virtuoso triplestore I am getting

It's because by default GraphDB returns CSV, and Virtuoso returns XML!

It should be fixed by adding an Accept header to the HTTP query executed by fetch here: https://github.com/netwerk-digitaal-erfgoed/LDWizard-Core/blob/master/src/config/sparqlSearch.ts#L100

The problem is that currently LDWizard supports a simple, but non-standard JSON serialization for the SPARQL results:

[
  {
    "iri": "https://w3id.org/pnv#Person",
    "description": "A Person is a human being whose individual existence can somehow be documented"
  },

But it should use application/sparql-results+json that looks like this:

{ "head": { "link": [], "vars": ["iri", "description"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "iri": { "type": "uri", "value": "https://w3id.org/pnv#Person" }  , "description": { "type": "literal", "xml:lang": "en", "value": "A Person is a human being whose individual existence can somehow be documented"

I implemented a fix to use the standard SPARQL results JSON format, and make the sparqlAutocomplete work with most SPARQL endpoints. I tested it on GraphDB and the default TriplyDB. I'll make a pull request asap

GerwinBosch commented 2 years ago

@vemonet I've released a new version with the merge request. Could you check if the issue still applies?

vemonet commented 2 years ago

Thanks a lot @GerwinBosch !

We are going to present our use of the ldwizard at a conference about digital story telling next week. I will try to update our instance to use directly your code asap and will close the issue if it works as expected

wouterbeek commented 2 years ago

@mightymax Let's test whether this bug is now solved, and if so then close.