diff --git a/demo/check.html b/demo/check.html index 6aaafc3..4710f00 100644 --- a/demo/check.html +++ b/demo/check.html @@ -48,41 +48,41 @@

SPARQL Endpoint Metadata Check

resultsDiv.innerHTML = ""; try { - const prefixesResults = await queryEndpoint( - endpoint, - `PREFIX sh: - SELECT DISTINCT ?prefix ?namespace - WHERE { [] sh:namespace ?namespace ; sh:prefix ?prefix} - ORDER BY ?prefix`, - ); + const checkPrefixesQuery = `PREFIX sh: +SELECT DISTINCT ?prefix ?namespace +WHERE { [] sh:namespace ?namespace ; sh:prefix ?prefix} +ORDER BY ?prefix`; + const prefixesResults = await queryEndpoint(endpoint, checkPrefixesQuery); if (prefixesResults.length === 0) { - resultsDiv.innerHTML += `

⚠️ No prefixes found

+ resultsDiv.innerHTML += `

⚠️ No prefixes found

Add prefix/namespace definitions to your endpoint using SHACL sh:namespace and sh:prefix properties.

Checkout the sparql-examples project - to help you generate prefix definitions alongside SPARQL queries examples and upload them to your endpoint.

`; + to help you generate prefix definitions alongside SPARQL queries examples and upload them to your endpoint.

+

We are running this query to retrieve prefixes:

+
${checkPrefixesQuery.replaceAll("<", "<").replaceAll(">", ">")}
`; } else { - resultsDiv.innerHTML += `

✅ Found ${prefixesResults.length} prefixes

`; + resultsDiv.innerHTML += `

✅ Found ${prefixesResults.length} prefixes

`; } - const exampleQueriesResults = await queryEndpoint( - endpoint, - `PREFIX sh: - PREFIX rdfs: - SELECT DISTINCT ?sq ?comment ?query - WHERE { - ?sq a sh:SPARQLExecutable ; - rdfs:comment ?comment ; - sh:select|sh:ask|sh:construct|sh:describe ?query . - } ORDER BY ?sq`, - ); + const checkExamplesQuery = `PREFIX sh: +PREFIX rdfs: +SELECT DISTINCT ?sq ?comment ?query +WHERE { + ?sq a sh:SPARQLExecutable ; + rdfs:comment ?comment ; + sh:select|sh:ask|sh:construct|sh:describe ?query . +} ORDER BY ?sq`; + const exampleQueriesResults = await queryEndpoint(endpoint, checkExamplesQuery); if (exampleQueriesResults.length === 0) { - resultsDiv.innerHTML += `

⚠️ No example SPARQL queries found

+ resultsDiv.innerHTML += `

⚠️ No example SPARQL queries found

Checkout the sparql-examples project - to help you generate SHACL representations of SPARQL queries and upload them to your endpoint.

`; + to help you generate SHACL representations of SPARQL queries and upload them to your endpoint.

+

We are running this query to retrieve examples:

+
${checkExamplesQuery.replaceAll("<", "<").replaceAll(">", ">")}
`; } else { - resultsDiv.innerHTML += `

✅ Found ${exampleQueriesResults.length} example SPARQL queries

`; + resultsDiv.innerHTML += `

✅ Found ${exampleQueriesResults.length} example SPARQL queries

`; } const voidResults = await queryEndpoint( @@ -90,33 +90,50 @@

SPARQL Endpoint Metadata Check

`PREFIX up: PREFIX void: PREFIX void-ext: - SELECT DISTINCT ?class1 + SELECT DISTINCT ?subjectClass WHERE { - ?cp void:class ?class1 ; + ?cp void:class ?subjectClass ; void:propertyPartition ?pp . ?pp void:property ?prop . OPTIONAL { { - ?pp void:classPartition [ void:class ?class2 ] . + ?pp void:classPartition [ void:class ?objectClass ] . } UNION { - ?pp void-ext:datatypePartition [ void-ext:datatype ?datatype ] . + ?pp void-ext:datatypePartition [ void-ext:datatype ?objectDatatype ] . } } }`, ); if (voidResults.length === 0) { - resultsDiv.innerHTML += `

⚠️ No VoID description found.

+ resultsDiv.innerHTML += `

⚠️ No VoID description found

Checkout the void-generator project to automatically generate a VoID description for the classes and predicates inside your endpoint, - and upload it to your endpoint.

`; + and upload it to your endpoint.

+

We are running this query to retrieve the VoID description:

+
PREFIX up: <http://purl.uniprot.org/core/>
+PREFIX void: <http://rdfs.org/ns/void#>
+PREFIX void-ext: <http://ldf.fi/void-ext#>
+SELECT DISTINCT ?subjectClass ?prop ?objectClass ?objectDatatype
+WHERE {
+    ?cp void:class ?subjectClass ;
+        void:propertyPartition ?pp .
+    ?pp void:property ?prop .
+    OPTIONAL {
+        {
+            ?pp  void:classPartition [ void:class ?objectClass ] .
+        } UNION {
+            ?pp void-ext:datatypePartition [ void-ext:datatype ?objectDatatype ] .
+        }
+    }
+}
`; return; } else { - resultsDiv.innerHTML += `

✅ Found VoID description for ${voidResults.length} classes

`; + resultsDiv.innerHTML += `

✅ Found VoID description for ${voidResults.length} classes

`; } } catch (error) { console.log("Error querying the endpoint", error); - resultsDiv.innerHTML += `

❌ Error querying the endpoint: ${error.message}

`; + resultsDiv.innerHTML += `

❌ Error querying the endpoint: ${error.message}

`; return; } } @@ -128,15 +145,24 @@

SPARQL Endpoint Metadata Check

justify-content: center; align-items: center; text-align: center; - height: 100vh; + min-height: 100vh; margin: 0; font-family: Arial, sans-serif; background-color: #f4f4f4; } + p, + pre { + text-align: left; + } + pre { + background-color: #f9f9f9; + padding: 10px; + border-radius: 5px; + overflow-x: auto; + } #container { width: 90%; max-width: 900px; - text-align: center; background: white; padding: 20px; border-radius: 8px;