zazuko / vscode-sparql-notebook

Visual Studio Code SPARQL Notebook Extension
https://marketplace.visualstudio.com/items?itemName=Zazuko.sparql-notebook
Other
26 stars 8 forks source link

Think about using YAML as notebook format #41

Closed BenjaminHofstetter closed 1 year ago

BenjaminHofstetter commented 1 year ago

It's a good solution and very Version Control friendly.

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 .
    }
tpluscode commented 1 year ago

This data is already RDF, right? Maybe serialise as JSON-LD and then into YAML to keep the graph structure?

BenjaminHofstetter commented 1 year ago

no the data is not RDF. The saved notebook is a JSON array with Code and Markdown cells . The scope of this Version control. I had the json as one liner. This is not good for Version control. Right now the JSON is formatted and it's not a one liner anymore. But the SPARQL Queries are still stored as one line with \n. Again not very Version Control friendly.

BenjaminHofstetter commented 1 year ago

we can use external SPARQL file to have that