Closed matentzn closed 1 year ago
Good one... I will have a look at it.
Just did it. It's a bit better but the interesting stuff would be better version control over the SPARQL queries. They are still "one liners".
[
{
"kind": 1,
"language": "markdown",
"value": "# Flux Class Metadata Notebook"
},
{
"kind": 1,
"language": "markdown",
"value": "## Fetch all Class Metadata instances\n"
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX sh: <http://www.w3.org/ns/shacl#>\nPREFIX flux: <https://flux.described.at/>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>\n\nSELECT ?metaIri ?label ?comment WHERE {\n ?metaIri a fluxMetadataShapes:ClassMetadataShape .\n OPTIONAL {\n ?metaIri rdfs:label ?label\n }\n OPTIONAL {\n ?metaIri rdfs:comment ?comment\n }\n}"
},
{
"kind": 1,
"language": "markdown",
"value": "## Fetch one Class Metadata Instance\n"
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX sh: <http://www.w3.org/ns/shacl#>\nPREFIX flux: <https://flux.described.at/>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>\nPREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\nSELECT ?metaIri ?p ?o WHERE {\n ?metaIri ?p ?o .\n}\nVALUES ?metaIri {\n <http://schema.example.org/BexioContact/latest/FluxClassInstance>\n}"
},
{
"kind": 2,
"language": "sparql",
"value": "CONSTRUCT { ?metaInstance ?p ?o . } WHERE {\n {\n SELECT ?metaInstance {\n ?metaInstance a <https://ld.flux.zazuko.com/shapes/metadata/ClassMetadataShape> .\n }\n }\n ?metaInstance ?p ?o .\n}"
}
]
Muuuch better! Thank you! That will be helpful! Do you have a timeline for when this will propagate to the VSCODE plugin?
@matentzn or do you think we should serialize it to turtle. They have multi line literals.
@prefix : <http://example.org/stuff/1.0/> .
:a :sparqlQuery """REFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX flux: <https://flux.described.at/>\
...""" .
I think it is fine as is - the best would be to have the SPARQL string have proper line breaks, but since that is not allowed in JSON, I guess what you have now is the next best thing.
Or did you suggest to serialise everything as turtle?
[
{
"kind": 1,
"language": "markdown",
"value": "# Flux Class Metadata Notebook"
},
{
"kind": 1,
"language": "markdown",
"value": "## Fetch all Class Metadata instances\n"
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX sh: <http://www.w3.org/ns/shacl#>\nPREFIX flux: <https://flux.described.at/>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>\n\nSELECT ?metaIri ?label ?comment WHERE {\n ?metaIri a fluxMetadataShapes:ClassMetadataShape .\n OPTIONAL {\n ?metaIri rdfs:label ?label\n }\n OPTIONAL {\n ?metaIri rdfs:comment ?comment\n }\n}"
},
{
"kind": 1,
"language": "markdown",
"value": "## Fetch one Class Metadata Instance\n"
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX sh: <http://www.w3.org/ns/shacl#>\nPREFIX flux: <https://flux.described.at/>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>\nPREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\nSELECT ?metaIri ?p ?o WHERE {\n ?metaIri ?p ?o .\n}\nVALUES ?metaIri {\n <http://schema.example.org/BexioContact/latest/FluxClassInstance>\n}"
},
{
"kind": 2,
"language": "sparql",
"value": "CONSTRUCT { ?metaInstance ?p ?o . } WHERE {\n {\n SELECT ?metaInstance {\n ?metaInstance a <https://ld.flux.zazuko.com/shapes/metadata/ClassMetadataShape> .\n }\n }\n ?metaInstance ?p ?o .\n}"
}
]
yes all in turtle. But i don't know if we have serialiser able to produce multi line string literals in turtle.
In this case, I would suggest yaml.
This is what a json to yaml converter (https://www.json2yaml.com/) would spit out:
---
- kind: 1
language: markdown
value: "# Flux Class Metadata Notebook"
- kind: 1
language: markdown
value: "## Fetch all Class Metadata instances\n"
- kind: 2
language: sparql
value: |-
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX flux: <https://flux.described.at/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>
SELECT ?metaIri ?label ?comment WHERE {
?metaIri a fluxMetadataShapes:ClassMetadataShape .
OPTIONAL {
?metaIri rdfs:label ?label
}
OPTIONAL {
?metaIri rdfs:comment ?comment
}
}
- kind: 1
language: markdown
value: "## Fetch one Class Metadata Instance\n"
- kind: 2
language: sparql
value: |-
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX flux: <https://flux.described.at/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fluxMetadataShapes: <https://ld.flux.zazuko.com/shapes/metadata/>
PREFIX fluxShapes: <https://ld.flux.zazuko.com/shapes/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?metaIri ?p ?o WHERE {
?metaIri ?p ?o .
}
VALUES ?metaIri {
<http://schema.example.org/BexioContact/latest/FluxClassInstance>
}
- kind: 2
language: sparql
value: |-
CONSTRUCT { ?metaInstance ?p ?o . } WHERE {
{
SELECT ?metaInstance {
?metaInstance a <https://ld.flux.zazuko.com/shapes/metadata/ClassMetadataShape> .
}
}
?metaInstance ?p ?o .
}
Thank you for that pointer. I think this is really nice. But i have to test it. In the mean time i will release a new version with the formatted json. And later think about using YAML. Thank you.
Version 0.17 is published
Awesome! I tried it immediately and its great! Thanks.
@matentzn you can include external .sparql / .rq files. then you have even better version control. -> 's here https://github.com/zazuko/vscode-sparql-notebook/blob/main/README.md#use-query-files version 0.0.19 has it
I am experimenting with using sparqlbook files using your amazing VSCode plugin, and wondering if there would be a way to make the sparqlbook files themselves more amenable to version control. Right now, it seems like the whole notebook is saved in a single line:
Maybe there is something I did wrong on my end though :)