Read RDF, mix an ontology into data, and validate it against SHACL shapes with Apache Jena.
Every graph is an org.apache.jena.graph.Graph. For the Model API, wrap one
with org.apache.jena.rdf.model.ModelFactory/createModelForGraph.
A source is a String naming a file, or anything else
clojure.java.io/input-stream accepts.
Read RDF, mix an ontology into data, and validate it against SHACL shapes with Apache Jena. Every graph is an `org.apache.jena.graph.Graph`. For the Model API, wrap one with `org.apache.jena.rdf.model.ModelFactory/createModelForGraph`. A source is a String naming a file, or anything else `clojure.java.io/input-stream` accepts.
(inoculate ontology)The triples pyshacl 0.40.1's inoculate() copies from ontology into an
empty data graph, as a new Graph: RDFS and OWL class and property axioms,
with blank-node structures cloned.
Each owl:NamedIndividual is deep-cloned with every triple whose object it is, as pyshacl does.
Union the result into the data graph to validate, for example with
org.apache.jena.graph.GraphUtil/addInto.
The triples pyshacl 0.40.1's `inoculate()` copies from `ontology` into an empty data graph, as a new Graph: RDFS and OWL class and property axioms, with blank-node structures cloned. Each owl:NamedIndividual is deep-cloned with every triple whose object it is, as pyshacl does. Union the result into the data graph to validate, for example with `org.apache.jena.graph.GraphUtil/addInto`.
(read-jsonld sources)(read-jsonld sources {:keys [contexts]})Parse JSON-LD sources into one new Graph.
Each source gets its own blank nodes, so _:b0 in two sources names two
nodes.
:contexts maps a URL string to the source of the document served for it.
A remote context at any other URL throws ex-info with :url and
:contexts; nothing is fetched.
Parse JSON-LD `sources` into one new Graph. Each source gets its own blank nodes, so `_:b0` in two sources names two nodes. `:contexts` maps a URL string to the source of the document served for it. A remote context at any other URL throws ex-info with `:url` and `:contexts`; nothing is fetched.
(read-turtle source)Parse one Turtle source into a new Graph.
Parse one Turtle source into a new Graph.
(targets-any? data shapes)True when some class asserted with rdf:type in data is a shape target in
shapes: the object of an sh:targetClass, or itself an sh:NodeShape.
A false result means no class-targeted shape selects a focus node.
True when some class asserted with rdf:type in `data` is a shape target in `shapes`: the object of an sh:targetClass, or itself an sh:NodeShape. A false result means no class-targeted shape selects a focus node.
(validate data shapes)Validate data against shapes, a Graph or a parsed
org.apache.jena.shacl.Shapes.
Returns {:conforms? bool :results [...]}. Each result holds
:focus-node and :value-node, the Jena nodes, and these strings: :focus, :path (nil
for a node-level result; the SPARQL path syntax for a complex path),
:component, :value, :message and :source-shape. :severity is
:violation, :warning or :info, or the IRI of another severity.
IRIs are strings, a blank node is _: and its label, and a literal is its
lexical form.
Validate `data` against `shapes`, a Graph or a parsed
`org.apache.jena.shacl.Shapes`.
Returns `{:conforms? bool :results [...]}`. Each result holds
`:focus-node` and `:value-node`, the Jena nodes, and these strings: `:focus`, `:path` (nil
for a node-level result; the SPARQL path syntax for a complex path),
`:component`, `:value`, `:message` and `:source-shape`. `:severity` is
`:violation`, `:warning` or `:info`, or the IRI of another severity.
IRIs are strings, a blank node is `_:` and its label, and a literal is its
lexical form.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |