Giter VIP home page Giter VIP logo

linked-data's Introduction

Linked Data Extension

The Elsevier Data Architecture Linked Data Extension (LDE) for Visual Studio Code brings a number of Linked Data related functionalities to a popular integrated development environment.

It's not industry-grade solid, but should be good enough™. For any questions, comments, please contact Rinke Hoekstra, or create an issue in the GitHub repository.

What it does

  • Visualise an RDF graph directly from a file.
  • Convert between JSON-LD, Turtle, RDF/XML and N-Quads (some quirks because not every format supports named graphs)
  • Convert between JSON-LD variants (compact, expanded, flattened)
  • Apply a JSON-LD frame to a JSON-LD file.
  • Validate your RDF against a SHACL file
  • Run a SPARQL query directly on a file and see the results in HTML and CSV

The JSON-LD operations can work with local context files. This overcomes the limitation in most JSON-LD libraries that interpret context references as URLs. See the loadLocalContexts setting below.

Download Linked Data Extension from https://marketplace.visualstudio.com/items?itemName=Elsevier.linked-data or through the Extensions menu of VSCode.

This extension depends on the Stardog Languages Extension Pack from Stardog Union for file type recognition, syntax highlighting and syntax checking.

Screenshots

For the files used in the screenshots, see the examples folder.

Conversion Between RDF Formats

RDF Formats

Visualisation and JSON-LD Variants

Visualization

SPARQL and SHACL

Querying and Validation

Commands

You can access the commands through the command palette: Cmd-Shift-p or Ctrl-Shift-p and then start typing "Linked Data", or use one of the following keyboard shortcuts.

Keyboard Shortcuts

  • Standard syntactic JSON-LD operations:
  • Standard format conversions:
    • Ctrl-Option-n/Ctrl-Alt-n: Convert an RDF file (any format) to N-Quads
    • Ctrl-Option-t/Ctrl-Alt-t: Convert an RDF file (any format) to Turtle (may be lossy for files that contain multiple graphs)
    • Ctrl-Option-r/Ctrl-Alt-r: Convert an RDF file (any format) to RDF/XML (may be lossy for files that contain multiple graphs)
    • Ctrl-Option-j/Ctrl-Alt-j: Convert an RDF file (any format) to JSON-LD
  • View as a Graph:
    • Ctrl-Option-g/Ctrl-Alt-g: Render an RDF file as a D3js force directed graph.
  • Validate against SHACL shapes:
    • Ctrl-Option-v/Ctrl-Alt-v: Validate an RDF file against SHACL shapes (see below)
  • Query a Graph:
    • Ctrl-Option-q/Ctrl-Alt-q: Run the SPARQL query against an RDF file (see below)

Extension Settings

This extension contributes the following settings:

  • linked-data.loadLocalContexts: Should the extension try to load local (non-URI) JSON-LD context files. This is especially useful when testing large context files that are intended to be shared across multiple JSON-LD files. It overcomes the problem that JSON-LD libraries interpret references to contexts as URIs, which would require running an HTTP server to test the context.

Tips and Recommendations

SHACL Validator

The SHACL Validator can be told what shapes file to use, by adding commented lines to the top of a Turtle file (does not work for JSON-LD) that refer to a (relative path) to the shapes file using the shapes attribute, e.g. the following will try to load the my_excellent_shapes.ttl file.

# shapes: my_excellent_shapes.ttl
@prefix ex: <https://example.com/> .

ex:Alice
	a ex:Person ;
	ex:ssn "987-65-432A" .

If there is no such instruction, or the instruction cannot be parsed as YAML, the extension will show a file open window for you to select the shapes file to use.

SPARQL Query

You can run a SPARQL Query only from valid SPARQL files (*.rq), and similar to the SHACL validator, you can specify the file against which you want to run the query by using the file attribute:

# file: example-1-transformed/source.json
SELECT * WHERE  {
    ?a ?b ?c .
}

If there is no such instruction, or the instruction cannot be parsed as YAMLM, the extension will show a file open window for you to select the RDF file to query against.

SPARQL results are shown both as a web view with a table that supports sorting and search, as well as a CSV file for further processing.

Known Limitations

  • RDF format support is limited to the underlying libraries. E.g RDF/XML support is spotty as it doesn't deal with XML entity definitions very well.

Thanks go to:

linked-data's People

Contributors

jeswr avatar rinkehoekstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

linked-data's Issues

Shapes attribute is not considered when running `Validate`

Linked Data Extension v1.0.6
VSCode/Windows Version:
image

I am using your example for SHACL validation by placing the shapes attribute as a comment with the relative path to the shapes file:

# shapes: shacl_example_shapes.ttl
@prefix ex: <https://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:Alice
	a ex:Person ;
	ex:ssn "987-65-432A" .

However, still a dialog opens asking me to select the shapes file.

SPARQL results table visualization omits optional results

Given

@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:alice
  ex:name "Alice" ;
  ex:age "25"^^xsd:integer .

ex:bob 
  ex:name "Bob" ;
  ex:age "25"^^xsd:integer .

ex:charlie
  ex:name "Charlie" ;
  ex:age "25"^^xsd:integer .

ex:dave
  ex:name "Dave" ;
  ex:age "25"^^xsd:integer .

running the following query

PREFIX ex: <http://example.org/>

select ?name ?age
where {
  ?person ex:name ?name .
  OPTIONAL{?person ex:age ?age.}
}

gives the following expected result

image

But executing the same query on this input:

@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:alice
  ex:name "Alice" .
  # ex:age "25"^^xsd:integer .

ex:bob 
  ex:name "Bob" ;
  ex:age "25"^^xsd:integer .

ex:charlie
  ex:name "Charlie" ;
  ex:age "25"^^xsd:integer .

ex:dave
  ex:name "Dave" ;
  ex:age "25"^^xsd:integer .

give this result:

image

with this data result:

"Alice"
"Bob";"25"
"Charlie";"25"
"Dave";"25"

BUG: Fetching remote context not working

Remote "@context" is not properly supported, i.e. https not recognized.

How to reproduce

Create a file with content:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "actor": "https://other_domain/users/phoenix",
  "id": "https://other_domain/users/phoenix#likes/557",
  "object": "https://my_domain/activitypub/helge/id567",
  "type": "Like"
}

run Linked-Data: Compact

Error messages:

file:///home/helge/code/bovine/tests/data/https%3A/www.w3.org/ns/activitystreams. Detail: Unable to read file '/home/helge/code/bovine/tests/data/https:/www.w3.org/ns/activitystreams' (Error: Unable to resolve nonexistent file '/home/helge/code/bovine/tests/data/https:/www.w3.org/ns/activitystreams')

and

Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.

feature: syntax highlight `.acl` files

Thanks for this great tool!

In the context of solid we often have RDF serialized .acl files. Specifically they usually serialised in turtle. Could this extension add support to apply syntax highlighting to those files by default if there is no other syntax highlighting already applied to .acl by other extensions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.