Search is not available for this dataset
id
stringlengths
1
8
text
stringlengths
72
9.81M
addition_count
int64
0
10k
commit_subject
stringlengths
0
3.7k
deletion_count
int64
0
8.43k
file_extension
stringlengths
0
32
lang
stringlengths
1
94
license
stringclasses
10 values
repo_name
stringlengths
9
59
0
<NME> rdfquery.js <BEF> ADDFILE <MSG> SHACL-JS progress <DFF> @@ -0,0 +1,313 @@ +// rdfquery.js +// A simple RDF query library for JavaScript +// Contact: holger@topquadrant.com +// +// The basic idea is that the function RDFQuery produces an initial +// Query object, which starts with a single "empty" solution. +// Each query object has a function nextSolution() producing an iteration +// of variable bindings ("volcano style"). +// Each query object can be refined with subsequent calls to other +// functions, producing new queries. +// Invoking nextSolution on a query will pull solutions from its +// predecessors in a chain of query objects. +// Finally, functions such as .first() and .toArray() can be used +// to produce individual values. +// The solution objects are plain JavaScript objects providing a +// mapping from variable names to RDF Term objects. +// Unless a query has been walked to exhaustion, .close() must be called. +// +// RDF Term objects are expected to follow the contracts from the +// RDF Representation Task Force's interface specification: +// https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md +// +// In order to bootstrap all this, graph objects need to implement a +// function .find(s, p, o) where each parameter is either an RDF term or null +// producing an iterator object with a .next() function that produces RDF triples +// (with attributes subject, predicate, object) or null when done. +// +// (Note I am not particularly a JavaScript guru so the modularization of this +// script may be improved to hide private members from public API etc). + +/* Example: + var result = RDFQuery($dataGraph). + find(OWL.Class, RDFS.label, "label"). + find("otherClass", RDFS.label, "label"). + filter(function(solution) { return !OWL.Class.equals(solution.otherClass) }). + first().otherClass; + +Equivalent SPARQL: + SELECT ?otherClass + WHERE { + owl:Class rdfs:label ?label . + ?otherClass rdfs:label ?label . + FILTER (owl:Class != ?otherClass) . + } LIMIT 1 +*/ + + +function _Namespace (nsuri) { + return function (localName) { + return TermFactory.namedNode(nsuri + localName); + } +} + +// Suggested container object for all frequently needed namespaces +// Usage to get rdf:type: NS.rdf("type") +var NS = { + rdf : _Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'), + rdfs : _Namespace('http://www.w3.org/2000/01/rdf-schema#'), + sh : _Namespace('http://www.w3.org/ns/shacl#'), + owl : _Namespace('http://www.w3.org/2002/07/owl#'), + xsd : _Namespace('http://www.w3.org/2001/XMLSchema#') +} + +var OWL = { + Class : NS.owl("Class"), + DatatypeProperty : NS.owl("DatatypeProperty"), + ObjectProperty : NS.owl("ObjectProperty") +} + +var RDF = { + HTML : NS.rdf("HTML"), + List : NS.rdf("List"), + Property : NS.rdf("Property"), + Statement : NS.rdf("Statement"), + first : NS.rdf("first"), + langString : NS.rdf("langString"), + nil : NS.rdf("nil"), + object : NS.rdf("object"), + predicate : NS.rdf("predicate"), + rest : NS.rdf("rest"), + subject : NS.rdf("subject"), + type : NS.rdf("type"), + value : NS.rdf("value") +} + +var RDFS = { + Class : NS.rdfs("Class"), + Datatype : NS.rdfs("Datatype"), + Literal : NS.rdfs("Literal"), + Resource : NS.rdfs("Resource"), + comment : NS.rdfs("comment"), + domain : NS.rdfs("domain"), + label : NS.rdfs("label"), + range : NS.rdfs("range"), + seeAlso : NS.rdfs("seeAlso"), + subClassOf : NS.rdfs("subClassOf"), + subPropertyOf : NS.rdfs("subPropertyOf") +} + +var XSD = { + boolean : NS.xsd("boolean"), + date : NS.xsd("date"), + dateTime : NS.xsd("dateTime"), + decimal : NS.xsd("decimal"), + float : NS.xsd("float"), + integer : NS.xsd("integer"), + string : NS.xsd("string") +}; + + +/** + * Creates a query object for a given graph and optional initial solution. + * The resulting object can be further refined using the functions on + * AbstractQuery such as <code>find()</code> and <code>filter()</code>. + * Functions such as <code>nextSolution()</code> can be used to get the actual results. + * @param graph the graph to query + * @param initialSolution the initial solutions or null for none + * @returns a query object + */ +function RDFQuery(graph, initialSolution) { + return new StartQuery(graph, initialSolution ? initialSolution : []); +} + + +// class AbstractQuery + +function AbstractQuery() { +} + +/** + * Creates a new query that filters the solutions produced by this. + * @param filterFunction a function that takes a solution object + * and returns true iff that solution is valid + */ +AbstractQuery.prototype.filter = function(filterFunction) { + return new FilterQuery(this, filterFunction); +} + +// TODO: add other SPARQL-like query types +// - .distinct() +// - .bind(varName, function(solution)) +// - . +// - .limit() +// - .path(s, path, o) (this is complex) +// - .sort(varName, [comparatorFunction]) +// - .union(otherQuery) + +/** + * Creates a new query doing a triple match. + * @param s the match subject or null (any) or a variable name (string) + * @param p the match predicate or null (any) or a variable name (string) + * @param o the match object or null (any) or a variable name (string) + */ +AbstractQuery.prototype.find = function(s, p, o) { + return new RDFTripleQuery(this, s, p, o); +} + +/** + * Gets the next solution and closes the query. + * @return a solution object + */ +AbstractQuery.prototype.first = function() { + var n = this.nextSolution(); + this.close(); + return n; +} + +/** + * Turns all results into an array. + * @return a array consisting of solution objects + */ +AbstractQuery.prototype.toArray = function() { + var results = []; + for(var n = this.nextSolution(); n != null; n = this.nextSolution()) { + results.push(n); + } + return results; +} + + +// class FilterQuery +// Filters the incoming solutions, only letting through those where +// filterFunction(solution) returns true + +function FilterQuery(input, filterFunction) { + this.source = input.source; + this.input = input; + this.filterFunction = filterFunction; +} + +FilterQuery.prototype = Object.create(AbstractQuery.prototype); + +FilterQuery.prototype.close = function() { + this.input.close(); +} + +// Pulls the next result from the input Query and passes it into +// the given filter function +FilterQuery.prototype.nextSolution = function() { + for(;;) { + var result = this.input.nextSolution(); + if(result == null) { + return null; + } + else if(this.filterFunction(result) === true) { + return result; + } + } +} + + +// class RDFTripleQuery +// Joins the solutions from the input Query with triple matches against +// the current input graph. + +function RDFTripleQuery(input, s, p, o) { + this.source = input.source; + this.input = input; + this.s = s; + this.p = p; + this.o = o; +} + +RDFTripleQuery.prototype = Object.create(AbstractQuery.prototype); + +RDFTripleQuery.prototype.close = function() { + this.input.close(); + if(this.ownIterator) { + this.ownIterator.close(); + } +} + +// This pulls the first solution from the input Query and uses it to +// create an "ownIterator" which applies the input solution to those +// specified by s, p, o. +// Once this "ownIterator" has been exhausted, it moves to the next +// solution from the input Query, and so on. +// At each step, it produces the union of the input solutions plus the +// own solutions. +RDFTripleQuery.prototype.nextSolution = function() { + + var oit = this.ownIterator; + if(oit) { + var n = oit.next(); + if(n != null) { + var result = createSolution(this.inputSolution); + if(typeof this.s === 'string') { + result[this.s] = n.subject; + } + if(typeof this.p === 'string') { + result[this.p] = n.predicate; + } + if(typeof this.o === 'string') { + result[this.o] = n.object; + } + return result; + } + else { + delete this.ownIterator; // Mark as exhausted + } + } + + // Pull from input + this.inputSolution = this.input.nextSolution(); + if(this.inputSolution) { + var sm = (typeof this.s === 'string') ? this.inputSolution[this.s] : this.s; + var pm = (typeof this.p === 'string') ? this.inputSolution[this.p] : this.p; + var om = (typeof this.o === 'string') ? this.inputSolution[this.o] : this.o; + this.ownIterator = this.source.find(sm, pm, om) + return this.nextSolution(); + } + else { + return null; + } +} + + +// class StartQuery +// This simply produces a single result: the initial solution + +function StartQuery(source, initialSolution) { + this.source = source; + this.solution = initialSolution; +} + +StartQuery.prototype = Object.create(AbstractQuery.prototype); + +StartQuery.prototype.close = function() { +} + +StartQuery.prototype.nextSolution = function() { + if(this.solution) { + var b = this.solution; + delete this.solution; + return b; + } + else { + return null; + } +} + + +// Helper functions + +function createSolution(base) { + var result = {}; + for(var attr in base) { + if(base.hasOwnProperty(attr)) { + result[attr] = base[attr]; + } + } + return result; +}
313
SHACL-JS progress
0
.js
js
apache-2.0
TopQuadrant/shacl
1
<NME> rdfquery.js <BEF> ADDFILE <MSG> SHACL-JS progress <DFF> @@ -0,0 +1,313 @@ +// rdfquery.js +// A simple RDF query library for JavaScript +// Contact: holger@topquadrant.com +// +// The basic idea is that the function RDFQuery produces an initial +// Query object, which starts with a single "empty" solution. +// Each query object has a function nextSolution() producing an iteration +// of variable bindings ("volcano style"). +// Each query object can be refined with subsequent calls to other +// functions, producing new queries. +// Invoking nextSolution on a query will pull solutions from its +// predecessors in a chain of query objects. +// Finally, functions such as .first() and .toArray() can be used +// to produce individual values. +// The solution objects are plain JavaScript objects providing a +// mapping from variable names to RDF Term objects. +// Unless a query has been walked to exhaustion, .close() must be called. +// +// RDF Term objects are expected to follow the contracts from the +// RDF Representation Task Force's interface specification: +// https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md +// +// In order to bootstrap all this, graph objects need to implement a +// function .find(s, p, o) where each parameter is either an RDF term or null +// producing an iterator object with a .next() function that produces RDF triples +// (with attributes subject, predicate, object) or null when done. +// +// (Note I am not particularly a JavaScript guru so the modularization of this +// script may be improved to hide private members from public API etc). + +/* Example: + var result = RDFQuery($dataGraph). + find(OWL.Class, RDFS.label, "label"). + find("otherClass", RDFS.label, "label"). + filter(function(solution) { return !OWL.Class.equals(solution.otherClass) }). + first().otherClass; + +Equivalent SPARQL: + SELECT ?otherClass + WHERE { + owl:Class rdfs:label ?label . + ?otherClass rdfs:label ?label . + FILTER (owl:Class != ?otherClass) . + } LIMIT 1 +*/ + + +function _Namespace (nsuri) { + return function (localName) { + return TermFactory.namedNode(nsuri + localName); + } +} + +// Suggested container object for all frequently needed namespaces +// Usage to get rdf:type: NS.rdf("type") +var NS = { + rdf : _Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'), + rdfs : _Namespace('http://www.w3.org/2000/01/rdf-schema#'), + sh : _Namespace('http://www.w3.org/ns/shacl#'), + owl : _Namespace('http://www.w3.org/2002/07/owl#'), + xsd : _Namespace('http://www.w3.org/2001/XMLSchema#') +} + +var OWL = { + Class : NS.owl("Class"), + DatatypeProperty : NS.owl("DatatypeProperty"), + ObjectProperty : NS.owl("ObjectProperty") +} + +var RDF = { + HTML : NS.rdf("HTML"), + List : NS.rdf("List"), + Property : NS.rdf("Property"), + Statement : NS.rdf("Statement"), + first : NS.rdf("first"), + langString : NS.rdf("langString"), + nil : NS.rdf("nil"), + object : NS.rdf("object"), + predicate : NS.rdf("predicate"), + rest : NS.rdf("rest"), + subject : NS.rdf("subject"), + type : NS.rdf("type"), + value : NS.rdf("value") +} + +var RDFS = { + Class : NS.rdfs("Class"), + Datatype : NS.rdfs("Datatype"), + Literal : NS.rdfs("Literal"), + Resource : NS.rdfs("Resource"), + comment : NS.rdfs("comment"), + domain : NS.rdfs("domain"), + label : NS.rdfs("label"), + range : NS.rdfs("range"), + seeAlso : NS.rdfs("seeAlso"), + subClassOf : NS.rdfs("subClassOf"), + subPropertyOf : NS.rdfs("subPropertyOf") +} + +var XSD = { + boolean : NS.xsd("boolean"), + date : NS.xsd("date"), + dateTime : NS.xsd("dateTime"), + decimal : NS.xsd("decimal"), + float : NS.xsd("float"), + integer : NS.xsd("integer"), + string : NS.xsd("string") +}; + + +/** + * Creates a query object for a given graph and optional initial solution. + * The resulting object can be further refined using the functions on + * AbstractQuery such as <code>find()</code> and <code>filter()</code>. + * Functions such as <code>nextSolution()</code> can be used to get the actual results. + * @param graph the graph to query + * @param initialSolution the initial solutions or null for none + * @returns a query object + */ +function RDFQuery(graph, initialSolution) { + return new StartQuery(graph, initialSolution ? initialSolution : []); +} + + +// class AbstractQuery + +function AbstractQuery() { +} + +/** + * Creates a new query that filters the solutions produced by this. + * @param filterFunction a function that takes a solution object + * and returns true iff that solution is valid + */ +AbstractQuery.prototype.filter = function(filterFunction) { + return new FilterQuery(this, filterFunction); +} + +// TODO: add other SPARQL-like query types +// - .distinct() +// - .bind(varName, function(solution)) +// - . +// - .limit() +// - .path(s, path, o) (this is complex) +// - .sort(varName, [comparatorFunction]) +// - .union(otherQuery) + +/** + * Creates a new query doing a triple match. + * @param s the match subject or null (any) or a variable name (string) + * @param p the match predicate or null (any) or a variable name (string) + * @param o the match object or null (any) or a variable name (string) + */ +AbstractQuery.prototype.find = function(s, p, o) { + return new RDFTripleQuery(this, s, p, o); +} + +/** + * Gets the next solution and closes the query. + * @return a solution object + */ +AbstractQuery.prototype.first = function() { + var n = this.nextSolution(); + this.close(); + return n; +} + +/** + * Turns all results into an array. + * @return a array consisting of solution objects + */ +AbstractQuery.prototype.toArray = function() { + var results = []; + for(var n = this.nextSolution(); n != null; n = this.nextSolution()) { + results.push(n); + } + return results; +} + + +// class FilterQuery +// Filters the incoming solutions, only letting through those where +// filterFunction(solution) returns true + +function FilterQuery(input, filterFunction) { + this.source = input.source; + this.input = input; + this.filterFunction = filterFunction; +} + +FilterQuery.prototype = Object.create(AbstractQuery.prototype); + +FilterQuery.prototype.close = function() { + this.input.close(); +} + +// Pulls the next result from the input Query and passes it into +// the given filter function +FilterQuery.prototype.nextSolution = function() { + for(;;) { + var result = this.input.nextSolution(); + if(result == null) { + return null; + } + else if(this.filterFunction(result) === true) { + return result; + } + } +} + + +// class RDFTripleQuery +// Joins the solutions from the input Query with triple matches against +// the current input graph. + +function RDFTripleQuery(input, s, p, o) { + this.source = input.source; + this.input = input; + this.s = s; + this.p = p; + this.o = o; +} + +RDFTripleQuery.prototype = Object.create(AbstractQuery.prototype); + +RDFTripleQuery.prototype.close = function() { + this.input.close(); + if(this.ownIterator) { + this.ownIterator.close(); + } +} + +// This pulls the first solution from the input Query and uses it to +// create an "ownIterator" which applies the input solution to those +// specified by s, p, o. +// Once this "ownIterator" has been exhausted, it moves to the next +// solution from the input Query, and so on. +// At each step, it produces the union of the input solutions plus the +// own solutions. +RDFTripleQuery.prototype.nextSolution = function() { + + var oit = this.ownIterator; + if(oit) { + var n = oit.next(); + if(n != null) { + var result = createSolution(this.inputSolution); + if(typeof this.s === 'string') { + result[this.s] = n.subject; + } + if(typeof this.p === 'string') { + result[this.p] = n.predicate; + } + if(typeof this.o === 'string') { + result[this.o] = n.object; + } + return result; + } + else { + delete this.ownIterator; // Mark as exhausted + } + } + + // Pull from input + this.inputSolution = this.input.nextSolution(); + if(this.inputSolution) { + var sm = (typeof this.s === 'string') ? this.inputSolution[this.s] : this.s; + var pm = (typeof this.p === 'string') ? this.inputSolution[this.p] : this.p; + var om = (typeof this.o === 'string') ? this.inputSolution[this.o] : this.o; + this.ownIterator = this.source.find(sm, pm, om) + return this.nextSolution(); + } + else { + return null; + } +} + + +// class StartQuery +// This simply produces a single result: the initial solution + +function StartQuery(source, initialSolution) { + this.source = source; + this.solution = initialSolution; +} + +StartQuery.prototype = Object.create(AbstractQuery.prototype); + +StartQuery.prototype.close = function() { +} + +StartQuery.prototype.nextSolution = function() { + if(this.solution) { + var b = this.solution; + delete this.solution; + return b; + } + else { + return null; + } +} + + +// Helper functions + +function createSolution(base) { + var result = {}; + for(var attr in base) { + if(base.hasOwnProperty(attr)) { + result[attr] = base[attr]; + } + } + return result; +}
313
SHACL-JS progress
0
.js
js
apache-2.0
TopQuadrant/shacl
2
<NME> DASH.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.vocabulary; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; /** * Vocabulary for http://datashapes.org/dash */ public class DASH { public final static String BASE_URI = "http://datashapes.org/dash"; public final static String NAME = "DASH Data Shapes Vocabulary"; public final static String NS = BASE_URI + "#"; public final static String PREFIX = "dash"; public final static Resource Action = ResourceFactory.createResource(NS + "Action"); public final static Resource ActionGroup = ResourceFactory.createResource(NS + "ActionGroup"); public final static Resource ActionTestCase = ResourceFactory.createResource(NS + "ActionTestCase"); public final static Resource addedGraph = ResourceFactory.createResource(NS + "addedGraph"); public final static Resource all = ResourceFactory.createResource(NS + "all"); public final static Resource ChangeScript = ResourceFactory.createResource(NS + "ChangeScript"); public final static Resource CommitScript = ResourceFactory.createResource(NS + "CommitScript"); public final static Resource Constructor = ResourceFactory.createResource(NS + "Constructor"); public final static Resource deletedGraph = ResourceFactory.createResource(NS + "deletedGraph"); public final static Resource DepictionRole = ResourceFactory.createResource(NS + "DepictionRole"); public final static Resource Deprecated = ResourceFactory.createResource(NS + "Deprecated"); public final static Resource DescriptionRole = ResourceFactory.createResource(NS + "DescriptionRole"); public final static Resource Editor = ResourceFactory.createResource(NS + "Editor"); public final static Resource ExecutionPlatform = ResourceFactory.createResource(NS + "ExecutionPlatform"); public final static Resource Experimental = ResourceFactory.createResource(NS + "Experimental"); public final static Resource ExploreAction = ResourceFactory.createResource(NS + "ExploreAction"); public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult"); public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase"); public final static Resource IconRole = ResourceFactory.createResource(NS + "IconRole"); public final static Resource IDRole = ResourceFactory.createResource(NS + "IDRole"); public final static Resource IncludedScript = ResourceFactory.createResource(NS + "IncludedScript"); public final static Resource IndexedConstraintComponent = ResourceFactory.createResource(NS + "IndexedConstraintComponent"); public final static Resource InferencingTestCase = ResourceFactory.createResource(NS + "InferencingTestCase"); public final static Resource isDeactivated = ResourceFactory.createResource(NS + "isDeactivated"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Resource ModifyAction = ResourceFactory.createResource(NS + "ModifyAction"); public final static Resource MultiFunction = ResourceFactory.createResource(NS + "MultiFunction"); public final static Resource None = ResourceFactory.createResource(NS + "None"); public final static Resource NonRecursiveConstraintComponent = ResourceFactory.createResource(NS + "NonRecursiveConstraintComponent"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Resource ResourceAction = ResourceFactory.createResource(NS + "ResourceAction"); public final static Resource ResourceService = ResourceFactory.createResource(NS + "ResourceService"); public final static Resource Script = ResourceFactory.createResource(NS + "Script"); public final static Resource ScriptConstraint = ResourceFactory.createResource(NS + "ScriptConstraint"); public final static Resource ScriptConstraintComponent = ResourceFactory.createResource(NS + "ScriptConstraintComponent"); public final static Resource ScriptFunction = ResourceFactory.createResource(NS + "ScriptFunction"); public final static Resource ScriptSuggestionGenerator = ResourceFactory.createResource(NS + "ScriptSuggestionGenerator"); public final static Resource ScriptTestCase = ResourceFactory.createResource(NS + "ScriptTestCase"); public final static Resource ScriptValidator = ResourceFactory.createResource(NS + "ScriptValidator"); public final static Resource Service = ResourceFactory.createResource(NS + "Service"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource ShapeScript = ResourceFactory.createResource(NS + "ShapeScript"); public final static Resource SPARQLConstructTemplate = ResourceFactory.createResource(NS + "SPARQLConstructTemplate"); public final static Resource SPARQLMultiFunction = ResourceFactory.createResource(NS + "SPARQLMultiFunction"); public final static Resource SPARQLSelectTemplate = ResourceFactory.createResource(NS + "SPARQLSelectTemplate"); public final static Resource SPARQLUpdateSuggestionGenerator = ResourceFactory.createResource(NS + "SPARQLUpdateSuggestionGenerator"); public final static Resource SingleLineConstraintComponent = ResourceFactory.createResource(NS + "SingleLineConstraintComponent"); public final static Resource Stable = ResourceFactory.createResource(NS + "Stable"); public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase"); public final static Resource ValueTableViewer = ResourceFactory.createResource(NS + "ValueTableViewer"); public final static Resource Viewer = ResourceFactory.createResource(NS + "Viewer"); public final static Resource Widget = ResourceFactory.createResource(NS + "Widget"); public final static Property abstract_ = ResourceFactory.createProperty(NS + "abstract"); public final static Property action = ResourceFactory.createProperty(NS + "action"); public final static Property actualResult = ResourceFactory.createProperty(NS + "actualResult"); public final static Property actionGroup = ResourceFactory.createProperty(NS + "actionGroup"); public final static Property addedTriple = ResourceFactory.createProperty(NS + "addedTriple"); public final static Property apiStatus = ResourceFactory.createProperty(NS + "apiStatus"); public final static Property applicableToClass = ResourceFactory.createProperty(NS + "applicableToClass"); public final static Property cachable = ResourceFactory.createProperty(NS + "cachable"); public final static Property canWrite = ResourceFactory.createProperty(NS + "canWrite"); public final static Property composite = ResourceFactory.createProperty(NS + "composite"); public final static Property constructor = ResourceFactory.createProperty(NS + "constructor"); public final static Property contextFree = ResourceFactory.createProperty(NS + "contextFree"); public final static Property defaultViewForRole = ResourceFactory.createProperty(NS + "defaultViewForRole"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property dependencyPredicate = ResourceFactory.createProperty(NS + "dependencyPredicate"); public final static Property detailsEndpoint = ResourceFactory.createProperty(NS + "detailsEndpoint"); public final static Property detailsGraph = ResourceFactory.createProperty(NS + "detailsGraph"); public final static Property editor = ResourceFactory.createProperty(NS + "editor"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expectedResultIsJSON = ResourceFactory.createProperty(NS + "expectedResultIsJSON"); public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property exports = ResourceFactory.createProperty(NS + "exports"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property generateClass = ResourceFactory.createProperty(NS + "generateClass"); public final static Property generatePrefixClasses = ResourceFactory.createProperty(NS + "generatePrefixClasses"); public final static Property generatePrefixConstants = ResourceFactory.createProperty(NS + "generatePrefixConstants"); public final static Property hidden = ResourceFactory.createProperty(NS + "hidden"); public final static Property includedExecutionPlatform = ResourceFactory.createProperty(NS + "includedExecutionPlatform"); public final static Property includeSuggestions = ResourceFactory.createProperty(NS + "includeSuggestions"); public final static Property index = ResourceFactory.createProperty(NS + "index"); public final static Property indexed = ResourceFactory.createProperty(NS + "indexed"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsCondition = ResourceFactory.createProperty(NS + "jsCondition"); public final static Property mimeTypes = ResourceFactory.createProperty(NS + "mimeTypes"); public final static Property neverMaterialize = ResourceFactory.createProperty(NS + "neverMaterialize"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property onAllValues = ResourceFactory.createProperty(NS + "onAllValues"); public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property propertyRole = ResourceFactory.createProperty(NS + "propertyRole"); public final static Property propertySuggestionGenerator = ResourceFactory.createProperty(NS + "propertySuggestionGenerator"); public final static Property requiredExecutionPlatform = ResourceFactory.createProperty(NS + "requiredExecutionPlatform"); public final static Property resultVariable = ResourceFactory.createProperty(NS + "resultVariable"); public final static Property rootClass = ResourceFactory.createProperty(NS + "rootClass"); public final static Property readOnly = ResourceFactory.createProperty(NS + "readOnly"); public final static Property reifiableBy = ResourceFactory.createProperty(NS + "reifiableBy"); public final static Property resourceAction = ResourceFactory.createProperty(NS + "resourceAction"); public final static Property resourceService = ResourceFactory.createProperty(NS + "resourceService"); public final static Property responseContentType = ResourceFactory.createProperty(NS + "responseContentType"); public final static Property scriptConstraint = ResourceFactory.createProperty(NS + "scriptConstraint"); public final static Property shape = ResourceFactory.createProperty(NS + "shape"); public final static Property shapeScript = ResourceFactory.createProperty(NS + "shapeScript"); public final static Property singleLine = ResourceFactory.createProperty(NS + "singleLine"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Property testCase = ResourceFactory.createProperty(NS + "testCase"); public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph"); public final static Property uri = ResourceFactory.createProperty(NS + "uri"); public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart"); public final static Property validateShapes = ResourceFactory.createProperty(NS + "validateShapes"); public final static Property variables = ResourceFactory.createProperty(NS + "variables"); public final static Property viewer = ResourceFactory.createProperty(NS + "viewer"); public final static Property x = ResourceFactory.createProperty(NS + "x"); public final static Property y = ResourceFactory.createProperty(NS + "y"); public static String getURI() { return NS; } /** * Checks whether a given feature shall be included into the generated APIs. * @param feature the feature to check * @return true currently if the feature has any value for dash:apiStatus but this may change in case we introduce * additional stati in the future. */ public static boolean isAPI(Resource feature) { return feature.hasProperty(DASH.apiStatus); } } <MSG> Moved to Jena 3.5.0, misc minor adjustments and fixes <DFF> @@ -72,6 +72,8 @@ public class DASH { public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); + public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); + public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); @@ -92,6 +94,8 @@ public class DASH { public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); + + public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); @@ -107,6 +111,8 @@ public class DASH { public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); + public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); + public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup");
6
Moved to Jena 3.5.0, misc minor adjustments and fixes
0
.java
java
apache-2.0
TopQuadrant/shacl
3
<NME> DASH.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.vocabulary; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; /** * Vocabulary for http://datashapes.org/dash */ public class DASH { public final static String BASE_URI = "http://datashapes.org/dash"; public final static String NAME = "DASH Data Shapes Vocabulary"; public final static String NS = BASE_URI + "#"; public final static String PREFIX = "dash"; public final static Resource Action = ResourceFactory.createResource(NS + "Action"); public final static Resource ActionGroup = ResourceFactory.createResource(NS + "ActionGroup"); public final static Resource ActionTestCase = ResourceFactory.createResource(NS + "ActionTestCase"); public final static Resource addedGraph = ResourceFactory.createResource(NS + "addedGraph"); public final static Resource all = ResourceFactory.createResource(NS + "all"); public final static Resource ChangeScript = ResourceFactory.createResource(NS + "ChangeScript"); public final static Resource CommitScript = ResourceFactory.createResource(NS + "CommitScript"); public final static Resource Constructor = ResourceFactory.createResource(NS + "Constructor"); public final static Resource deletedGraph = ResourceFactory.createResource(NS + "deletedGraph"); public final static Resource DepictionRole = ResourceFactory.createResource(NS + "DepictionRole"); public final static Resource Deprecated = ResourceFactory.createResource(NS + "Deprecated"); public final static Resource DescriptionRole = ResourceFactory.createResource(NS + "DescriptionRole"); public final static Resource Editor = ResourceFactory.createResource(NS + "Editor"); public final static Resource ExecutionPlatform = ResourceFactory.createResource(NS + "ExecutionPlatform"); public final static Resource Experimental = ResourceFactory.createResource(NS + "Experimental"); public final static Resource ExploreAction = ResourceFactory.createResource(NS + "ExploreAction"); public final static Resource FailureResult = ResourceFactory.createResource(NS + "FailureResult"); public final static Resource FailureTestCaseResult = ResourceFactory.createResource(NS + "FailureTestCaseResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); public final static Resource GraphValidationTestCase = ResourceFactory.createResource(NS + "GraphValidationTestCase"); public final static Resource IconRole = ResourceFactory.createResource(NS + "IconRole"); public final static Resource IDRole = ResourceFactory.createResource(NS + "IDRole"); public final static Resource IncludedScript = ResourceFactory.createResource(NS + "IncludedScript"); public final static Resource IndexedConstraintComponent = ResourceFactory.createResource(NS + "IndexedConstraintComponent"); public final static Resource InferencingTestCase = ResourceFactory.createResource(NS + "InferencingTestCase"); public final static Resource isDeactivated = ResourceFactory.createResource(NS + "isDeactivated"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Resource ModifyAction = ResourceFactory.createResource(NS + "ModifyAction"); public final static Resource MultiFunction = ResourceFactory.createResource(NS + "MultiFunction"); public final static Resource None = ResourceFactory.createResource(NS + "None"); public final static Resource NonRecursiveConstraintComponent = ResourceFactory.createResource(NS + "NonRecursiveConstraintComponent"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Resource ResourceAction = ResourceFactory.createResource(NS + "ResourceAction"); public final static Resource ResourceService = ResourceFactory.createResource(NS + "ResourceService"); public final static Resource Script = ResourceFactory.createResource(NS + "Script"); public final static Resource ScriptConstraint = ResourceFactory.createResource(NS + "ScriptConstraint"); public final static Resource ScriptConstraintComponent = ResourceFactory.createResource(NS + "ScriptConstraintComponent"); public final static Resource ScriptFunction = ResourceFactory.createResource(NS + "ScriptFunction"); public final static Resource ScriptSuggestionGenerator = ResourceFactory.createResource(NS + "ScriptSuggestionGenerator"); public final static Resource ScriptTestCase = ResourceFactory.createResource(NS + "ScriptTestCase"); public final static Resource ScriptValidator = ResourceFactory.createResource(NS + "ScriptValidator"); public final static Resource Service = ResourceFactory.createResource(NS + "Service"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource ShapeScript = ResourceFactory.createResource(NS + "ShapeScript"); public final static Resource SPARQLConstructTemplate = ResourceFactory.createResource(NS + "SPARQLConstructTemplate"); public final static Resource SPARQLMultiFunction = ResourceFactory.createResource(NS + "SPARQLMultiFunction"); public final static Resource SPARQLSelectTemplate = ResourceFactory.createResource(NS + "SPARQLSelectTemplate"); public final static Resource SPARQLUpdateSuggestionGenerator = ResourceFactory.createResource(NS + "SPARQLUpdateSuggestionGenerator"); public final static Resource SingleLineConstraintComponent = ResourceFactory.createResource(NS + "SingleLineConstraintComponent"); public final static Resource Stable = ResourceFactory.createResource(NS + "Stable"); public final static Resource SuccessResult = ResourceFactory.createResource(NS + "SuccessResult"); public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource ValidationTestCase = ResourceFactory.createResource(NS + "ValidationTestCase"); public final static Resource ValueTableViewer = ResourceFactory.createResource(NS + "ValueTableViewer"); public final static Resource Viewer = ResourceFactory.createResource(NS + "Viewer"); public final static Resource Widget = ResourceFactory.createResource(NS + "Widget"); public final static Property abstract_ = ResourceFactory.createProperty(NS + "abstract"); public final static Property action = ResourceFactory.createProperty(NS + "action"); public final static Property actualResult = ResourceFactory.createProperty(NS + "actualResult"); public final static Property actionGroup = ResourceFactory.createProperty(NS + "actionGroup"); public final static Property addedTriple = ResourceFactory.createProperty(NS + "addedTriple"); public final static Property apiStatus = ResourceFactory.createProperty(NS + "apiStatus"); public final static Property applicableToClass = ResourceFactory.createProperty(NS + "applicableToClass"); public final static Property cachable = ResourceFactory.createProperty(NS + "cachable"); public final static Property canWrite = ResourceFactory.createProperty(NS + "canWrite"); public final static Property composite = ResourceFactory.createProperty(NS + "composite"); public final static Property constructor = ResourceFactory.createProperty(NS + "constructor"); public final static Property contextFree = ResourceFactory.createProperty(NS + "contextFree"); public final static Property defaultViewForRole = ResourceFactory.createProperty(NS + "defaultViewForRole"); public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property dependencyPredicate = ResourceFactory.createProperty(NS + "dependencyPredicate"); public final static Property detailsEndpoint = ResourceFactory.createProperty(NS + "detailsEndpoint"); public final static Property detailsGraph = ResourceFactory.createProperty(NS + "detailsGraph"); public final static Property editor = ResourceFactory.createProperty(NS + "editor"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); public final static Property expectedResultIsJSON = ResourceFactory.createProperty(NS + "expectedResultIsJSON"); public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property exports = ResourceFactory.createProperty(NS + "exports"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property generateClass = ResourceFactory.createProperty(NS + "generateClass"); public final static Property generatePrefixClasses = ResourceFactory.createProperty(NS + "generatePrefixClasses"); public final static Property generatePrefixConstants = ResourceFactory.createProperty(NS + "generatePrefixConstants"); public final static Property hidden = ResourceFactory.createProperty(NS + "hidden"); public final static Property includedExecutionPlatform = ResourceFactory.createProperty(NS + "includedExecutionPlatform"); public final static Property includeSuggestions = ResourceFactory.createProperty(NS + "includeSuggestions"); public final static Property index = ResourceFactory.createProperty(NS + "index"); public final static Property indexed = ResourceFactory.createProperty(NS + "indexed"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsCondition = ResourceFactory.createProperty(NS + "jsCondition"); public final static Property mimeTypes = ResourceFactory.createProperty(NS + "mimeTypes"); public final static Property neverMaterialize = ResourceFactory.createProperty(NS + "neverMaterialize"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property onAllValues = ResourceFactory.createProperty(NS + "onAllValues"); public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property propertyRole = ResourceFactory.createProperty(NS + "propertyRole"); public final static Property propertySuggestionGenerator = ResourceFactory.createProperty(NS + "propertySuggestionGenerator"); public final static Property requiredExecutionPlatform = ResourceFactory.createProperty(NS + "requiredExecutionPlatform"); public final static Property resultVariable = ResourceFactory.createProperty(NS + "resultVariable"); public final static Property rootClass = ResourceFactory.createProperty(NS + "rootClass"); public final static Property readOnly = ResourceFactory.createProperty(NS + "readOnly"); public final static Property reifiableBy = ResourceFactory.createProperty(NS + "reifiableBy"); public final static Property resourceAction = ResourceFactory.createProperty(NS + "resourceAction"); public final static Property resourceService = ResourceFactory.createProperty(NS + "resourceService"); public final static Property responseContentType = ResourceFactory.createProperty(NS + "responseContentType"); public final static Property scriptConstraint = ResourceFactory.createProperty(NS + "scriptConstraint"); public final static Property shape = ResourceFactory.createProperty(NS + "shape"); public final static Property shapeScript = ResourceFactory.createProperty(NS + "shapeScript"); public final static Property singleLine = ResourceFactory.createProperty(NS + "singleLine"); public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup"); public final static Property testCase = ResourceFactory.createProperty(NS + "testCase"); public final static Property testGraph = ResourceFactory.createProperty(NS + "testGraph"); public final static Property uri = ResourceFactory.createProperty(NS + "uri"); public final static Property uriStart = ResourceFactory.createProperty(NS + "uriStart"); public final static Property validateShapes = ResourceFactory.createProperty(NS + "validateShapes"); public final static Property variables = ResourceFactory.createProperty(NS + "variables"); public final static Property viewer = ResourceFactory.createProperty(NS + "viewer"); public final static Property x = ResourceFactory.createProperty(NS + "x"); public final static Property y = ResourceFactory.createProperty(NS + "y"); public static String getURI() { return NS; } /** * Checks whether a given feature shall be included into the generated APIs. * @param feature the feature to check * @return true currently if the feature has any value for dash:apiStatus but this may change in case we introduce * additional stati in the future. */ public static boolean isAPI(Resource feature) { return feature.hasProperty(DASH.apiStatus); } } <MSG> Moved to Jena 3.5.0, misc minor adjustments and fixes <DFF> @@ -72,6 +72,8 @@ public class DASH { public final static Resource SuccessTestCaseResult = ResourceFactory.createResource(NS + "SuccessTestCaseResult"); + public final static Resource SuggestionResult = ResourceFactory.createResource(NS + "SuggestionResult"); + public final static Resource TestCase = ResourceFactory.createResource(NS + "TestCase"); public final static Resource TestEnvironment = ResourceFactory.createResource(NS + "TestEnvironment"); @@ -92,6 +94,8 @@ public class DASH { public final static Property deletedTriple = ResourceFactory.createProperty(NS + "deletedTriple"); public final static Property expectedResult = ResourceFactory.createProperty(NS + "expectedResult"); + + public final static Property expectedResultIsTTL = ResourceFactory.createProperty(NS + "expectedResultIsTTL"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); @@ -107,6 +111,8 @@ public class DASH { public final static Property suggestion = ResourceFactory.createProperty(NS + "suggestion"); + public final static Property suggestionConfidence = ResourceFactory.createProperty(NS + "suggestionConfidence"); + public final static Property suggestionGenerator = ResourceFactory.createProperty(NS + "suggestionGenerator"); public final static Property suggestionGroup = ResourceFactory.createProperty(NS + "suggestionGroup");
6
Moved to Jena 3.5.0, misc minor adjustments and fixes
0
.java
java
apache-2.0
TopQuadrant/shacl
4
<NME> Validate.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; import org.apache.jena.util.FileUtils; import org.topbraid.jenax.util.JenaDatatypes; import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.shacl.vocabulary.SH; /** * Stand-alone utility to perform constraint validation of a given file. * * Example arguments: * * -datafile my.ttl * * @author Holger Knublauch */ public class Validate extends AbstractTool { public static void main(String[] args) throws IOException { // Temporarily redirect system.err to avoid SLF4J warning PrintStream oldPS = System.err; System.setErr(new PrintStream(new ByteArrayOutputStream())); Validate validate = new Validate(); System.setErr(oldPS); validate.run(args); } private void run(String[] args) throws IOException { Model dataModel = getDataModel(args); Model shapesModel = getShapesModel(args); if(shapesModel == null) { shapesModel = dataModel; } Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) { // See https://github.com/TopQuadrant/shacl/issues/56 System.exit(1); } } } <MSG> #135: validate command line tool now has -validateShapes flag which is off by default <DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.Arrays; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; @@ -54,7 +55,8 @@ public class Validate extends AbstractTool { if(shapesModel == null) { shapesModel = dataModel; } - Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); + boolean validateShapes = Arrays.asList(args).contains("-validateShapes"); + Resource report = ValidationUtil.validateModel(dataModel, shapesModel, validateShapes); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) {
3
#135: validate command line tool now has -validateShapes flag which is off by default
1
.java
java
apache-2.0
TopQuadrant/shacl
5
<NME> Validate.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; import org.apache.jena.util.FileUtils; import org.topbraid.jenax.util.JenaDatatypes; import org.topbraid.shacl.validation.ValidationUtil; import org.topbraid.shacl.vocabulary.SH; /** * Stand-alone utility to perform constraint validation of a given file. * * Example arguments: * * -datafile my.ttl * * @author Holger Knublauch */ public class Validate extends AbstractTool { public static void main(String[] args) throws IOException { // Temporarily redirect system.err to avoid SLF4J warning PrintStream oldPS = System.err; System.setErr(new PrintStream(new ByteArrayOutputStream())); Validate validate = new Validate(); System.setErr(oldPS); validate.run(args); } private void run(String[] args) throws IOException { Model dataModel = getDataModel(args); Model shapesModel = getShapesModel(args); if(shapesModel == null) { shapesModel = dataModel; } Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) { // See https://github.com/TopQuadrant/shacl/issues/56 System.exit(1); } } } <MSG> #135: validate command line tool now has -validateShapes flag which is off by default <DFF> @@ -19,6 +19,7 @@ package org.topbraid.shacl.tools; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.Arrays; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; @@ -54,7 +55,8 @@ public class Validate extends AbstractTool { if(shapesModel == null) { shapesModel = dataModel; } - Resource report = ValidationUtil.validateModel(dataModel, shapesModel, true); + boolean validateShapes = Arrays.asList(args).contains("-validateShapes"); + Resource report = ValidationUtil.validateModel(dataModel, shapesModel, validateShapes); report.getModel().write(System.out, FileUtils.langTurtle); if(report.hasProperty(SH.conforms, JenaDatatypes.FALSE)) {
3
#135: validate command line tool now has -validateShapes flag which is off by default
1
.java
java
apache-2.0
TopQuadrant/shacl
6
<NME> AbstractSPARQLExecutor.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.validation.sparql; import java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryParseException; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.rdf.model.Statement; import org.apache.jena.vocabulary.RDF; import org.topbraid.jenax.statistics.ExecStatistics; import org.topbraid.jenax.statistics.ExecStatisticsManager; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaDatatypes; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.jenax.util.RDFLabels; import org.topbraid.shacl.arq.SHACLPaths; import org.topbraid.shacl.arq.functions.HasShapeFunction; import org.topbraid.shacl.engine.Constraint; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.util.FailureLog; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.validation.ConstraintExecutor; import org.topbraid.shacl.validation.SHACLException; import org.topbraid.shacl.validation.ValidationEngine; import org.topbraid.shacl.vocabulary.DASH; import org.topbraid.shacl.vocabulary.SH; public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { // Flag to generate dash:SuccessResults for all violations. public static boolean createSuccessResults = false; private Query query; private String queryString; protected AbstractSPARQLExecutor(Constraint constraint) { this.queryString = getSPARQL(constraint); try { this.query = ARQFactory.get().createQuery(queryString); Resource path = constraint.getShapeResource().getPath(); if(path != null && path.isAnon()) { String pathString = SHACLPaths.getPathString(constraint.getShapeResource().getPropertyResourceValue(SH.path)); query = SPARQLSubstitutions.substitutePaths(query, pathString, constraint.getShapeResource().getModel()); } } catch(QueryParseException ex) { throw new SHACLException("Invalid SPARQL constraint (" + ex.getLocalizedMessage() + "):\n" + queryString); } if(!query.isSelectType()) { throw new IllegalArgumentException("SHACL constraints must be SELECT queries"); } } @Override public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) { QuerySolutionMap bindings = new QuerySolutionMap(); addBindings(constraint, bindings); bindings.add(SH.currentShapeVar.getVarName(), constraint.getShapeResource()); bindings.add(SH.shapesGraphVar.getVarName(), ResourceFactory.createResource(engine.getShapesGraphURI().toString())); Resource path = constraint.getShapeResource().getPath(); if(path != null && path.isURIResource()) { bindings.add(SH.PATHVar.getName(), path); } URI oldShapesGraphURI = HasShapeFunction.getShapesGraphURI(); ShapesGraph oldShapesGraph = HasShapeFunction.getShapesGraph(); if(!engine.getShapesGraphURI().equals(oldShapesGraphURI)) { HasShapeFunction.setShapesGraph(engine.getShapesGraph(), engine.getShapesGraphURI()); } Model oldNestedResults = HasShapeFunction.getResultsModel(); Model nestedResults = JenaUtil.createMemoryModel(); HasShapeFunction.setResultsModel(nestedResults); try { long startTime = System.currentTimeMillis(); Resource messageHolder = getSPARQLExecutable(constraint); for(RDFNode focusNode : focusNodes) { bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings); executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings); } if(ExecStatisticsManager.get().isRecording()) { long endTime = System.currentTimeMillis(); long duration = endTime - startTime; String label = getLabel(constraint); Iterator<String> varNames = bindings.varNames(); if(varNames.hasNext()) { queryString += "\nBindings:"; while(varNames.hasNext()) { String varName = varNames.next(); queryString += "\n- ?" + varName + ": " + bindings.get(varName); } } ExecStatistics stats = new ExecStatistics(label, queryString, duration, startTime, constraint.getComponent().asNode()); ExecStatisticsManager.get().add(Collections.singletonList(stats)); } } finally { HasShapeFunction.setShapesGraph(oldShapesGraph, oldShapesGraphURI); HasShapeFunction.setResultsModel(oldNestedResults); } } protected abstract void addBindings(Constraint constraint, QuerySolutionMap bindings); protected abstract Resource getSPARQLExecutable(Constraint constraint); protected abstract String getLabel(Constraint constraint); protected Query getQuery() { return query; } protected abstract String getSPARQL(Constraint constraint); private void executeSelectQuery(ValidationEngine engine, Constraint constraint, Resource messageHolder, Model nestedResults, RDFNode focusNode, QueryExecution qexec, QuerySolution bindings) { ResultSet rs = qexec.execSelect(); if(!rs.getResultVars().contains("this")) { qexec.close(); throw new IllegalArgumentException("SELECT constraints must return $this"); } try { if(rs.hasNext()) { while(rs.hasNext()) { QuerySolution sol = rs.next(); RDFNode thisValue = sol.get(SH.thisVar.getVarName()); if(thisValue != null) { Resource resultType = SH.ValidationResult; RDFNode selectMessage = sol.get(SH.message.getLocalName()); if(JenaDatatypes.TRUE.equals(sol.get(SH.failureVar.getName()))) { resultType = DASH.FailureResult; String message = getLabel(constraint); message += " has produced ?" + SH.failureVar.getName(); if(focusNode != null) { message += " for focus node "; if(focusNode.isLiteral()) { message += focusNode; } else { message += RDFLabels.get().getLabel((Resource)focusNode); } } FailureLog.get().logFailure(message); selectMessage = ResourceFactory.createTypedLiteral("Validation Failure: Could not validate shape"); } Resource result = engine.createResult(resultType, constraint, thisValue); if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) { result.addProperty(SH.sourceConstraint, constraint.getParameterValue()); } if(selectMessage != null) { result.addProperty(SH.resultMessage, selectMessage); } else if(constraint.getShapeResource().hasProperty(SH.message)) { for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) { result.addProperty(SH.resultMessage, s.getObject()); } } else { addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol); } RDFNode pathValue = sol.get(SH.pathVar.getVarName()); if(pathValue != null && pathValue.isURIResource()) { result.addProperty(SH.resultPath, pathValue); } else if(constraint.getShapeResource().isPropertyShape()) { Resource basePath = constraint.getShapeResource().getPropertyResourceValue(SH.path); result.addProperty(SH.resultPath, SHACLPaths.clonePath(basePath, result.getModel())); } if(!SH.HasValueConstraintComponent.equals(constraint.getComponent())) { // See https://github.com/w3c/data-shapes/issues/111 RDFNode selectValue = sol.get(SH.valueVar.getVarName()); if(selectValue != null) { result.addProperty(SH.value, selectValue); } else if(SH.NodeShape.equals(constraint.getContext())) { result.addProperty(SH.value, focusNode); } } if(engine.getConfiguration().getReportDetails()) { addDetails(result, nestedResults); } } } } else if(createSuccessResults) { Resource success = engine.createResult(DASH.SuccessResult, constraint, focusNode); if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) { success.addProperty(SH.sourceConstraint, constraint.getParameterValue()); } if(engine.getConfiguration().getReportDetails()) { addDetails(success, nestedResults); } } } finally { qexec.close(); } } private void addDefaultMessages(ValidationEngine engine, Resource messageHolder, Resource fallback, Resource result, QuerySolution bindings, QuerySolution solution) { boolean found = false; for(Statement s : messageHolder.listProperties(SH.message).toList()) { if(s.getObject().isLiteral()) { QuerySolutionMap map = new QuerySolutionMap(); map.addAll(bindings); map.addAll(solution); engine.addResultMessage(result, s.getLiteral(), map); found = true; } } if(!found && fallback != null) { addDefaultMessages(engine, fallback, null, result, bindings, solution); } } public static void addDetails(Resource parentResult, Model nestedResults) { if(!nestedResults.isEmpty()) { parentResult.getModel().add(nestedResults); for(Resource type : SHACLUtil.RESULT_TYPES) { for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) { if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) { parentResult.addProperty(SH.detail, nestedResult); } } } } } } <MSG> Support for cancelling validation, other clean up <DFF> @@ -111,6 +111,7 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings); executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings); + engine.checkCanceled(); } if(ExecStatisticsManager.get().isRecording()) { long endTime = System.currentTimeMillis();
1
Support for cancelling validation, other clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
7
<NME> AbstractSPARQLExecutor.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.validation.sparql; import java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryParseException; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.rdf.model.Statement; import org.apache.jena.vocabulary.RDF; import org.topbraid.jenax.statistics.ExecStatistics; import org.topbraid.jenax.statistics.ExecStatisticsManager; import org.topbraid.jenax.util.ARQFactory; import org.topbraid.jenax.util.JenaDatatypes; import org.topbraid.jenax.util.JenaUtil; import org.topbraid.jenax.util.RDFLabels; import org.topbraid.shacl.arq.SHACLPaths; import org.topbraid.shacl.arq.functions.HasShapeFunction; import org.topbraid.shacl.engine.Constraint; import org.topbraid.shacl.engine.ShapesGraph; import org.topbraid.shacl.util.FailureLog; import org.topbraid.shacl.util.SHACLUtil; import org.topbraid.shacl.validation.ConstraintExecutor; import org.topbraid.shacl.validation.SHACLException; import org.topbraid.shacl.validation.ValidationEngine; import org.topbraid.shacl.vocabulary.DASH; import org.topbraid.shacl.vocabulary.SH; public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { // Flag to generate dash:SuccessResults for all violations. public static boolean createSuccessResults = false; private Query query; private String queryString; protected AbstractSPARQLExecutor(Constraint constraint) { this.queryString = getSPARQL(constraint); try { this.query = ARQFactory.get().createQuery(queryString); Resource path = constraint.getShapeResource().getPath(); if(path != null && path.isAnon()) { String pathString = SHACLPaths.getPathString(constraint.getShapeResource().getPropertyResourceValue(SH.path)); query = SPARQLSubstitutions.substitutePaths(query, pathString, constraint.getShapeResource().getModel()); } } catch(QueryParseException ex) { throw new SHACLException("Invalid SPARQL constraint (" + ex.getLocalizedMessage() + "):\n" + queryString); } if(!query.isSelectType()) { throw new IllegalArgumentException("SHACL constraints must be SELECT queries"); } } @Override public void executeConstraint(Constraint constraint, ValidationEngine engine, Collection<RDFNode> focusNodes) { QuerySolutionMap bindings = new QuerySolutionMap(); addBindings(constraint, bindings); bindings.add(SH.currentShapeVar.getVarName(), constraint.getShapeResource()); bindings.add(SH.shapesGraphVar.getVarName(), ResourceFactory.createResource(engine.getShapesGraphURI().toString())); Resource path = constraint.getShapeResource().getPath(); if(path != null && path.isURIResource()) { bindings.add(SH.PATHVar.getName(), path); } URI oldShapesGraphURI = HasShapeFunction.getShapesGraphURI(); ShapesGraph oldShapesGraph = HasShapeFunction.getShapesGraph(); if(!engine.getShapesGraphURI().equals(oldShapesGraphURI)) { HasShapeFunction.setShapesGraph(engine.getShapesGraph(), engine.getShapesGraphURI()); } Model oldNestedResults = HasShapeFunction.getResultsModel(); Model nestedResults = JenaUtil.createMemoryModel(); HasShapeFunction.setResultsModel(nestedResults); try { long startTime = System.currentTimeMillis(); Resource messageHolder = getSPARQLExecutable(constraint); for(RDFNode focusNode : focusNodes) { bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings); executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings); } if(ExecStatisticsManager.get().isRecording()) { long endTime = System.currentTimeMillis(); long duration = endTime - startTime; String label = getLabel(constraint); Iterator<String> varNames = bindings.varNames(); if(varNames.hasNext()) { queryString += "\nBindings:"; while(varNames.hasNext()) { String varName = varNames.next(); queryString += "\n- ?" + varName + ": " + bindings.get(varName); } } ExecStatistics stats = new ExecStatistics(label, queryString, duration, startTime, constraint.getComponent().asNode()); ExecStatisticsManager.get().add(Collections.singletonList(stats)); } } finally { HasShapeFunction.setShapesGraph(oldShapesGraph, oldShapesGraphURI); HasShapeFunction.setResultsModel(oldNestedResults); } } protected abstract void addBindings(Constraint constraint, QuerySolutionMap bindings); protected abstract Resource getSPARQLExecutable(Constraint constraint); protected abstract String getLabel(Constraint constraint); protected Query getQuery() { return query; } protected abstract String getSPARQL(Constraint constraint); private void executeSelectQuery(ValidationEngine engine, Constraint constraint, Resource messageHolder, Model nestedResults, RDFNode focusNode, QueryExecution qexec, QuerySolution bindings) { ResultSet rs = qexec.execSelect(); if(!rs.getResultVars().contains("this")) { qexec.close(); throw new IllegalArgumentException("SELECT constraints must return $this"); } try { if(rs.hasNext()) { while(rs.hasNext()) { QuerySolution sol = rs.next(); RDFNode thisValue = sol.get(SH.thisVar.getVarName()); if(thisValue != null) { Resource resultType = SH.ValidationResult; RDFNode selectMessage = sol.get(SH.message.getLocalName()); if(JenaDatatypes.TRUE.equals(sol.get(SH.failureVar.getName()))) { resultType = DASH.FailureResult; String message = getLabel(constraint); message += " has produced ?" + SH.failureVar.getName(); if(focusNode != null) { message += " for focus node "; if(focusNode.isLiteral()) { message += focusNode; } else { message += RDFLabels.get().getLabel((Resource)focusNode); } } FailureLog.get().logFailure(message); selectMessage = ResourceFactory.createTypedLiteral("Validation Failure: Could not validate shape"); } Resource result = engine.createResult(resultType, constraint, thisValue); if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) { result.addProperty(SH.sourceConstraint, constraint.getParameterValue()); } if(selectMessage != null) { result.addProperty(SH.resultMessage, selectMessage); } else if(constraint.getShapeResource().hasProperty(SH.message)) { for(Statement s : constraint.getShapeResource().listProperties(SH.message).toList()) { result.addProperty(SH.resultMessage, s.getObject()); } } else { addDefaultMessages(engine, messageHolder, constraint.getComponent(), result, bindings, sol); } RDFNode pathValue = sol.get(SH.pathVar.getVarName()); if(pathValue != null && pathValue.isURIResource()) { result.addProperty(SH.resultPath, pathValue); } else if(constraint.getShapeResource().isPropertyShape()) { Resource basePath = constraint.getShapeResource().getPropertyResourceValue(SH.path); result.addProperty(SH.resultPath, SHACLPaths.clonePath(basePath, result.getModel())); } if(!SH.HasValueConstraintComponent.equals(constraint.getComponent())) { // See https://github.com/w3c/data-shapes/issues/111 RDFNode selectValue = sol.get(SH.valueVar.getVarName()); if(selectValue != null) { result.addProperty(SH.value, selectValue); } else if(SH.NodeShape.equals(constraint.getContext())) { result.addProperty(SH.value, focusNode); } } if(engine.getConfiguration().getReportDetails()) { addDetails(result, nestedResults); } } } } else if(createSuccessResults) { Resource success = engine.createResult(DASH.SuccessResult, constraint, focusNode); if(SH.SPARQLConstraintComponent.equals(constraint.getComponent())) { success.addProperty(SH.sourceConstraint, constraint.getParameterValue()); } if(engine.getConfiguration().getReportDetails()) { addDetails(success, nestedResults); } } } finally { qexec.close(); } } private void addDefaultMessages(ValidationEngine engine, Resource messageHolder, Resource fallback, Resource result, QuerySolution bindings, QuerySolution solution) { boolean found = false; for(Statement s : messageHolder.listProperties(SH.message).toList()) { if(s.getObject().isLiteral()) { QuerySolutionMap map = new QuerySolutionMap(); map.addAll(bindings); map.addAll(solution); engine.addResultMessage(result, s.getLiteral(), map); found = true; } } if(!found && fallback != null) { addDefaultMessages(engine, fallback, null, result, bindings, solution); } } public static void addDetails(Resource parentResult, Model nestedResults) { if(!nestedResults.isEmpty()) { parentResult.getModel().add(nestedResults); for(Resource type : SHACLUtil.RESULT_TYPES) { for(Resource nestedResult : nestedResults.listSubjectsWithProperty(RDF.type, type).toList()) { if(!parentResult.getModel().contains(null, SH.detail, nestedResult)) { parentResult.addProperty(SH.detail, nestedResult); } } } } } } <MSG> Support for cancelling validation, other clean up <DFF> @@ -111,6 +111,7 @@ public abstract class AbstractSPARQLExecutor implements ConstraintExecutor { bindings.add(SH.thisVar.getVarName(), focusNode); // Overwrite any previous binding QueryExecution qexec = SPARQLSubstitutions.createQueryExecution(query, engine.getDataset(), bindings); executeSelectQuery(engine, constraint, messageHolder, nestedResults, focusNode, qexec, bindings); + engine.checkCanceled(); } if(ExecStatisticsManager.get().isRecording()) { long endTime = System.currentTimeMillis();
1
Support for cancelling validation, other clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
8
<NME> ValidationSuggestionGenerator.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.validation; import java.util.function.Function; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; /** * An interface for objects that can produce suggestions for a given results graph. * * @author Holger Knublauch */ public interface ValidationSuggestionGenerator { /** * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); /** * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction); /** * Checks if this is (in principle) capable of adding suggestions for a given result. * @param result the validation result * @return true if this can */ boolean canHandle(Resource result); } <MSG> JavaDoc clean up <DFF> @@ -33,6 +33,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); @@ -42,6 +43,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction);
2
JavaDoc clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
9
<NME> ValidationSuggestionGenerator.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.validation; import java.util.function.Function; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; /** * An interface for objects that can produce suggestions for a given results graph. * * @author Holger Knublauch */ public interface ValidationSuggestionGenerator { /** * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); /** * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction); /** * Checks if this is (in principle) capable of adding suggestions for a given result. * @param result the validation result * @return true if this can */ boolean canHandle(Resource result); } <MSG> JavaDoc clean up <DFF> @@ -33,6 +33,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for all result resource in the given results Model. * @param results the results Model * @param maxCount the maximum number of suggestions to produce per result + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Model results, int maxCount, Function<RDFNode,String> labelFunction); @@ -42,6 +43,7 @@ public interface ValidationSuggestionGenerator { * Adds dash:suggestion triples for a given result resource. * @param result the sh:ValidationResult to add the suggestions to * @param maxCount the maximum number of suggestions to produce + * @param labelFunction an optional function producing labels of nodes * @return the number of suggestions that were created */ int addSuggestions(Resource result, int maxCount, Function<RDFNode,String> labelFunction);
2
JavaDoc clean up
0
.java
java
apache-2.0
TopQuadrant/shacl
10
<NME> SH.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.vocabulary; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.sparql.core.Var; /** * Vocabulary for http://www.w3.org/ns/shacl# * * @author Holger Knublauch */ public class SH { public final static String BASE_URI = "http://www.w3.org/ns/shacl#"; public final static String NAME = "SHACL"; public final static String NS = BASE_URI; public final static String PREFIX = "sh"; public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult"); public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent"); public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode"); public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI"); public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral"); public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent"); public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent"); public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint"); public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent"); public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent"); public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent"); public final static Resource Literal = ResourceFactory.createResource(NS + "Literal"); public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent"); public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent"); public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent"); public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent"); public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent"); public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent"); public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent"); public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent"); public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent"); public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter"); public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable"); public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent"); public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration"); public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup"); public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape"); public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent"); public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent"); public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent"); public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator"); public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint"); public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent"); public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule"); public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable"); public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property property = ResourceFactory.createProperty(NS + "property"); public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent"); public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport"); public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult"); public final static Resource Validator = ResourceFactory.createResource(NS + "Validator"); public final static Resource Violation = ResourceFactory.createResource(NS + "Violation"); public final static Resource Warning = ResourceFactory.createResource(NS + "Warning"); public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent"); public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath"); public final static Property and = ResourceFactory.createProperty(NS + "and"); public final static Property ask = ResourceFactory.createProperty(NS + "ask"); public final static Property class_ = ResourceFactory.createProperty(NS + "class"); public final static Property closed = ResourceFactory.createProperty(NS + "closed"); public final static Property condition = ResourceFactory.createProperty(NS + "condition"); public final static Property conforms = ResourceFactory.createProperty(NS + "conforms"); public final static Property construct = ResourceFactory.createProperty(NS + "construct"); public final static Property datatype = ResourceFactory.createProperty(NS + "datatype"); public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated"); public final static Property declare = ResourceFactory.createProperty(NS + "declare"); public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue"); public final static Property detail = ResourceFactory.createProperty(NS + "detail"); public final static Property description = ResourceFactory.createProperty(NS + "description"); public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint"); public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property equals = ResourceFactory.createProperty(NS + "equals"); public final static Property flags = ResourceFactory.createProperty(NS + "flags"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property group = ResourceFactory.createProperty(NS + "group"); public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue"); public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties"); public final static Property in = ResourceFactory.createProperty(NS + "in"); public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath"); public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate"); public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn"); public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan"); public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals"); public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount"); public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive"); public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive"); public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength"); public final static Property message = ResourceFactory.createProperty(NS + "message"); public final static Property minCount = ResourceFactory.createProperty(NS + "minCount"); public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive"); public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive"); public final static Property minLength = ResourceFactory.createProperty(NS + "minLength"); public final static Property name = ResourceFactory.createProperty(NS + "name"); public final static Property namespace = ResourceFactory.createProperty(NS + "namespace"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind"); public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator"); public final static Property not = ResourceFactory.createProperty(NS + "not"); public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath"); public final static Property optional = ResourceFactory.createProperty(NS + "optional"); public final static Property or = ResourceFactory.createProperty(NS + "or"); public final static Property order = ResourceFactory.createProperty(NS + "order"); public final static Property parameter = ResourceFactory.createProperty(NS + "parameter"); public final static Property path = ResourceFactory.createProperty(NS + "path"); public final static Property pattern = ResourceFactory.createProperty(NS + "pattern"); public final static Property prefix = ResourceFactory.createProperty(NS + "prefix"); public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes"); public final static Property property = ResourceFactory.createProperty(NS + "property"); public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator"); public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount"); public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount"); public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape"); public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint"); public final static Property result = ResourceFactory.createProperty(NS + "result"); public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage"); public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath"); public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity"); public final static Property select = ResourceFactory.createProperty(NS + "select"); public final static Property severity = ResourceFactory.createProperty(NS + "severity"); public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph"); public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint"); public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent"); public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape"); public final static Property sparql = ResourceFactory.createProperty(NS + "sparql"); public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass"); public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode"); public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf"); public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf"); public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang"); public final static Property update = ResourceFactory.createProperty(NS + "update"); public final static Property validator = ResourceFactory.createProperty(NS + "validator"); public final static Property value = ResourceFactory.createProperty(NS + "value"); public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath"); public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath"); // Advanced features public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent"); public final static Resource Function = ResourceFactory.createResource(NS + "Function"); public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint"); public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent"); public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable"); public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction"); public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary"); public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule"); public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget"); public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType"); public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator"); public final static Resource Rule = ResourceFactory.createResource(NS + "Rule"); public final static Resource Rules = ResourceFactory.createResource(NS + "Rules"); public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule"); public final static Resource Target = ResourceFactory.createResource(NS + "Target"); public final static Resource this_ = ResourceFactory.createResource(NS + "this"); public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property intersection = ResourceFactory.createProperty(NS + "intersection"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName"); public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary"); public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL"); public final static Property member = ResourceFactory.createProperty(NS + "member"); public final static Property nodes = ResourceFactory.createProperty(NS + "nodes"); public final static Property object = ResourceFactory.createProperty(NS + "object"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property returnType = ResourceFactory.createProperty(NS + "returnType"); public final static Property rule = ResourceFactory.createProperty(NS + "rule"); public final static Property subject = ResourceFactory.createProperty(NS + "subject"); public final static Property target = ResourceFactory.createProperty(NS + "target"); public final static Property union = ResourceFactory.createProperty(NS + "union"); // Features not in SHACL 1.0 but candidates for next release public final static Property count = ResourceFactory.createProperty(NS + "count"); public final static Property desc = ResourceFactory.createProperty(NS + "desc"); public final static Property distinct = ResourceFactory.createProperty(NS + "distinct"); public final static Property else_ = ResourceFactory.createProperty(NS + "else"); public final static Property exists = ResourceFactory.createProperty(NS + "exists"); public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat"); public final static Property if_ = ResourceFactory.createProperty(NS + "if"); public final static Property limit = ResourceFactory.createProperty(NS + "limit"); public final static Property max = ResourceFactory.createProperty(NS + "max"); public final static Property min = ResourceFactory.createProperty(NS + "min"); public final static Property minus = ResourceFactory.createProperty(NS + "minus"); public final static Property offset = ResourceFactory.createProperty(NS + "offset"); public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy"); public final static Property separator = ResourceFactory.createProperty(NS + "separator"); public final static Property sum = ResourceFactory.createProperty(NS + "sum"); public final static Property then = ResourceFactory.createProperty(NS + "then"); public final static Property values = ResourceFactory.createProperty(NS + "values"); public static final Var currentShapeVar = Var.alloc("currentShape"); public static final Var failureVar = Var.alloc("failure"); public static final Var PATHVar = Var.alloc("PATH"); public static final Var pathVar = Var.alloc(path.getLocalName()); public static final Var shapesGraphVar = Var.alloc("shapesGraph"); public static final Var thisVar = Var.alloc("this"); public static final Var valueVar = Var.alloc("value"); public final static String JS_DATA_VAR = "$data"; public final static String JS_SHAPES_VAR = "$shapes"; public static String getURI() { return NS; } } <MSG> Improved support for scopes <DFF> @@ -61,6 +61,8 @@ public class SH { public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); + public final static Resource Scope = ResourceFactory.createResource(NS + "Scope"); + public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); @@ -68,6 +70,8 @@ public class SH { public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); + + public final static Resource TemplateScope = ResourceFactory.createResource(NS + "TemplateScope"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); @@ -95,6 +99,8 @@ public class SH { public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); + + public final static Property final_ = ResourceFactory.createProperty(NS + "final"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); @@ -133,6 +139,8 @@ public class SH { public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); + + public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property property = ResourceFactory.createProperty(NS + "property");
8
Improved support for scopes
0
.java
java
apache-2.0
TopQuadrant/shacl
11
<NME> SH.java <BEF> /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.topbraid.shacl.vocabulary; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.sparql.core.Var; /** * Vocabulary for http://www.w3.org/ns/shacl# * * @author Holger Knublauch */ public class SH { public final static String BASE_URI = "http://www.w3.org/ns/shacl#"; public final static String NAME = "SHACL"; public final static String NS = BASE_URI; public final static String PREFIX = "sh"; public final static Resource AbstractResult = ResourceFactory.createResource(NS + "AbstractResult"); public final static Resource AndConstraintComponent = ResourceFactory.createResource(NS + "AndConstraintComponent"); public final static Resource BlankNode = ResourceFactory.createResource(NS + "BlankNode"); public final static Resource BlankNodeOrIRI = ResourceFactory.createResource(NS + "BlankNodeOrIRI"); public final static Resource BlankNodeOrLiteral = ResourceFactory.createResource(NS + "BlankNodeOrLiteral"); public final static Resource ClassConstraintComponent = ResourceFactory.createResource(NS + "ClassConstraintComponent"); public final static Resource ClosedConstraintComponent = ResourceFactory.createResource(NS + "ClosedConstraintComponent"); public final static Resource Constraint = ResourceFactory.createResource(NS + "Constraint"); public final static Resource ConstraintComponent = ResourceFactory.createResource(NS + "ConstraintComponent"); public final static Resource DatatypeConstraintComponent = ResourceFactory.createResource(NS + "DatatypeConstraintComponent"); public final static Resource DisjointConstraintComponent = ResourceFactory.createResource(NS + "DisjointConstraintComponent"); public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); public final static Resource LessThanOrEqualsConstraintComponent = ResourceFactory.createResource(NS + "LessThanOrEqualsConstraintComponent"); public final static Resource Literal = ResourceFactory.createResource(NS + "Literal"); public final static Resource MaxCountConstraintComponent = ResourceFactory.createResource(NS + "MaxCountConstraintComponent"); public final static Resource MaxExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxExclusiveConstraintComponent"); public final static Resource MaxInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MaxInclusiveConstraintComponent"); public final static Resource MaxLengthConstraintComponent = ResourceFactory.createResource(NS + "MaxLengthConstraintComponent"); public final static Resource MinCountConstraintComponent = ResourceFactory.createResource(NS + "MinCountConstraintComponent"); public final static Resource MinExclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinExclusiveConstraintComponent"); public final static Resource MinInclusiveConstraintComponent = ResourceFactory.createResource(NS + "MinInclusiveConstraintComponent"); public final static Resource MinLengthConstraintComponent = ResourceFactory.createResource(NS + "MinLengthConstraintComponent"); public final static Resource NodeConstraintComponent = ResourceFactory.createResource(NS + "NodeConstraintComponent"); public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); public final static Resource Parameter = ResourceFactory.createResource(NS + "Parameter"); public final static Resource Parameterizable = ResourceFactory.createResource(NS + "Parameterizable"); public final static Resource PatternConstraintComponent = ResourceFactory.createResource(NS + "PatternConstraintComponent"); public final static Resource PrefixDeclaration = ResourceFactory.createResource(NS + "PrefixDeclaration"); public final static Resource PropertyGroup = ResourceFactory.createResource(NS + "PropertyGroup"); public final static Resource PropertyShape = ResourceFactory.createResource(NS + "PropertyShape"); public final static Resource PropertyConstraintComponent = ResourceFactory.createResource(NS + "PropertyConstraintComponent"); public final static Resource QualifiedMaxCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMaxCountConstraintComponent"); public final static Resource QualifiedMinCountConstraintComponent = ResourceFactory.createResource(NS + "QualifiedMinCountConstraintComponent"); public final static Resource ResultAnnotation = ResourceFactory.createResource(NS + "ResultAnnotation"); public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource SPARQLAskValidator = ResourceFactory.createResource(NS + "SPARQLAskValidator"); public final static Resource SPARQLConstraint = ResourceFactory.createResource(NS + "SPARQLConstraint"); public final static Resource SPARQLConstraintComponent = ResourceFactory.createResource(NS + "SPARQLConstraintComponent"); public final static Resource SPARQLConstructRule = ResourceFactory.createResource(NS + "SPARQLConstructRule"); public final static Resource SPARQLExecutable = ResourceFactory.createResource(NS + "SPARQLExecutable"); public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property property = ResourceFactory.createProperty(NS + "property"); public final static Resource UniqueLangConstraintComponent = ResourceFactory.createResource(NS + "UniqueLangConstraintComponent"); public final static Resource ValidationReport = ResourceFactory.createResource(NS + "ValidationReport"); public final static Resource ValidationResult = ResourceFactory.createResource(NS + "ValidationResult"); public final static Resource Validator = ResourceFactory.createResource(NS + "Validator"); public final static Resource Violation = ResourceFactory.createResource(NS + "Violation"); public final static Resource Warning = ResourceFactory.createResource(NS + "Warning"); public final static Resource XoneConstraintComponent = ResourceFactory.createResource(NS + "XoneConstraintComponent"); public final static Property alternativePath = ResourceFactory.createProperty(NS + "alternativePath"); public final static Property and = ResourceFactory.createProperty(NS + "and"); public final static Property ask = ResourceFactory.createProperty(NS + "ask"); public final static Property class_ = ResourceFactory.createProperty(NS + "class"); public final static Property closed = ResourceFactory.createProperty(NS + "closed"); public final static Property condition = ResourceFactory.createProperty(NS + "condition"); public final static Property conforms = ResourceFactory.createProperty(NS + "conforms"); public final static Property construct = ResourceFactory.createProperty(NS + "construct"); public final static Property datatype = ResourceFactory.createProperty(NS + "datatype"); public final static Property deactivated = ResourceFactory.createProperty(NS + "deactivated"); public final static Property declare = ResourceFactory.createProperty(NS + "declare"); public final static Property defaultValue = ResourceFactory.createProperty(NS + "defaultValue"); public final static Property detail = ResourceFactory.createProperty(NS + "detail"); public final static Property description = ResourceFactory.createProperty(NS + "description"); public final static Property disjoint = ResourceFactory.createProperty(NS + "disjoint"); public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property equals = ResourceFactory.createProperty(NS + "equals"); public final static Property flags = ResourceFactory.createProperty(NS + "flags"); public final static Property focusNode = ResourceFactory.createProperty(NS + "focusNode"); public final static Property group = ResourceFactory.createProperty(NS + "group"); public final static Property hasValue = ResourceFactory.createProperty(NS + "hasValue"); public final static Property ignoredProperties = ResourceFactory.createProperty(NS + "ignoredProperties"); public final static Property in = ResourceFactory.createProperty(NS + "in"); public final static Property inversePath = ResourceFactory.createProperty(NS + "inversePath"); public final static Property labelTemplate = ResourceFactory.createProperty(NS + "labelTemplate"); public final static Property languageIn = ResourceFactory.createProperty(NS + "languageIn"); public final static Property lessThan = ResourceFactory.createProperty(NS + "lessThan"); public final static Property lessThanOrEquals = ResourceFactory.createProperty(NS + "lessThanOrEquals"); public final static Property maxCount = ResourceFactory.createProperty(NS + "maxCount"); public final static Property maxExclusive = ResourceFactory.createProperty(NS + "maxExclusive"); public final static Property maxInclusive = ResourceFactory.createProperty(NS + "maxInclusive"); public final static Property maxLength = ResourceFactory.createProperty(NS + "maxLength"); public final static Property message = ResourceFactory.createProperty(NS + "message"); public final static Property minCount = ResourceFactory.createProperty(NS + "minCount"); public final static Property minExclusive = ResourceFactory.createProperty(NS + "minExclusive"); public final static Property minInclusive = ResourceFactory.createProperty(NS + "minInclusive"); public final static Property minLength = ResourceFactory.createProperty(NS + "minLength"); public final static Property name = ResourceFactory.createProperty(NS + "name"); public final static Property namespace = ResourceFactory.createProperty(NS + "namespace"); public final static Property node = ResourceFactory.createProperty(NS + "node"); public final static Property nodeKind = ResourceFactory.createProperty(NS + "nodeKind"); public final static Property nodeValidator = ResourceFactory.createProperty(NS + "nodeValidator"); public final static Property not = ResourceFactory.createProperty(NS + "not"); public final static Property oneOrMorePath = ResourceFactory.createProperty(NS + "oneOrMorePath"); public final static Property optional = ResourceFactory.createProperty(NS + "optional"); public final static Property or = ResourceFactory.createProperty(NS + "or"); public final static Property order = ResourceFactory.createProperty(NS + "order"); public final static Property parameter = ResourceFactory.createProperty(NS + "parameter"); public final static Property path = ResourceFactory.createProperty(NS + "path"); public final static Property pattern = ResourceFactory.createProperty(NS + "pattern"); public final static Property prefix = ResourceFactory.createProperty(NS + "prefix"); public final static Property prefixes = ResourceFactory.createProperty(NS + "prefixes"); public final static Property property = ResourceFactory.createProperty(NS + "property"); public final static Property propertyValidator = ResourceFactory.createProperty(NS + "propertyValidator"); public final static Property qualifiedMaxCount = ResourceFactory.createProperty(NS + "qualifiedMaxCount"); public final static Property qualifiedMinCount = ResourceFactory.createProperty(NS + "qualifiedMinCount"); public final static Property qualifiedValueShape = ResourceFactory.createProperty(NS + "qualifiedValueShape"); public final static Property qualifiedValueShapesDisjoint = ResourceFactory.createProperty(NS + "qualifiedValueShapesDisjoint"); public final static Property result = ResourceFactory.createProperty(NS + "result"); public final static Property resultMessage = ResourceFactory.createProperty(NS + "resultMessage"); public final static Property resultPath = ResourceFactory.createProperty(NS + "resultPath"); public final static Property resultSeverity = ResourceFactory.createProperty(NS + "resultSeverity"); public final static Property select = ResourceFactory.createProperty(NS + "select"); public final static Property severity = ResourceFactory.createProperty(NS + "severity"); public final static Property shapesGraph = ResourceFactory.createProperty(NS + "shapesGraph"); public final static Property sourceConstraint = ResourceFactory.createProperty(NS + "sourceConstraint"); public final static Property sourceConstraintComponent = ResourceFactory.createProperty(NS + "sourceConstraintComponent"); public final static Property sourceShape = ResourceFactory.createProperty(NS + "sourceShape"); public final static Property sparql = ResourceFactory.createProperty(NS + "sparql"); public final static Property targetClass = ResourceFactory.createProperty(NS + "targetClass"); public final static Property targetNode = ResourceFactory.createProperty(NS + "targetNode"); public final static Property targetObjectsOf = ResourceFactory.createProperty(NS + "targetObjectsOf"); public final static Property targetSubjectsOf = ResourceFactory.createProperty(NS + "targetSubjectsOf"); public final static Property uniqueLang = ResourceFactory.createProperty(NS + "uniqueLang"); public final static Property update = ResourceFactory.createProperty(NS + "update"); public final static Property validator = ResourceFactory.createProperty(NS + "validator"); public final static Property value = ResourceFactory.createProperty(NS + "value"); public final static Property zeroOrMorePath = ResourceFactory.createProperty(NS + "zeroOrMorePath"); public final static Property zeroOrOnePath = ResourceFactory.createProperty(NS + "zeroOrOnePath"); // Advanced features public final static Resource ExpressionConstraintComponent = ResourceFactory.createResource(NS + "ExpressionConstraintComponent"); public final static Resource Function = ResourceFactory.createResource(NS + "Function"); public final static Resource JSConstraint = ResourceFactory.createResource(NS + "JSConstraint"); public final static Resource JSConstraintComponent = ResourceFactory.createResource(NS + "JSConstraintComponent"); public final static Resource JSExecutable = ResourceFactory.createResource(NS + "JSExecutable"); public final static Resource JSFunction = ResourceFactory.createResource(NS + "JSFunction"); public final static Resource JSLibrary = ResourceFactory.createResource(NS + "JSLibrary"); public final static Resource JSRule = ResourceFactory.createResource(NS + "JSRule"); public final static Resource JSTarget = ResourceFactory.createResource(NS + "JSTarget"); public final static Resource JSTargetType = ResourceFactory.createResource(NS + "JSTargetType"); public final static Resource JSValidator = ResourceFactory.createResource(NS + "JSValidator"); public final static Resource Rule = ResourceFactory.createResource(NS + "Rule"); public final static Resource Rules = ResourceFactory.createResource(NS + "Rules"); public final static Resource SPARQLRule = ResourceFactory.createResource(NS + "SPARQLRule"); public final static Resource Target = ResourceFactory.createResource(NS + "Target"); public final static Resource this_ = ResourceFactory.createResource(NS + "this"); public final static Resource TripleRule = ResourceFactory.createResource(NS + "TripleRule"); public final static Property expression = ResourceFactory.createProperty(NS + "expression"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); public final static Property intersection = ResourceFactory.createProperty(NS + "intersection"); public final static Property js = ResourceFactory.createProperty(NS + "js"); public final static Property jsFunctionName = ResourceFactory.createProperty(NS + "jsFunctionName"); public final static Property jsLibrary = ResourceFactory.createProperty(NS + "jsLibrary"); public final static Property jsLibraryURL = ResourceFactory.createProperty(NS + "jsLibraryURL"); public final static Property member = ResourceFactory.createProperty(NS + "member"); public final static Property nodes = ResourceFactory.createProperty(NS + "nodes"); public final static Property object = ResourceFactory.createProperty(NS + "object"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); public final static Property returnType = ResourceFactory.createProperty(NS + "returnType"); public final static Property rule = ResourceFactory.createProperty(NS + "rule"); public final static Property subject = ResourceFactory.createProperty(NS + "subject"); public final static Property target = ResourceFactory.createProperty(NS + "target"); public final static Property union = ResourceFactory.createProperty(NS + "union"); // Features not in SHACL 1.0 but candidates for next release public final static Property count = ResourceFactory.createProperty(NS + "count"); public final static Property desc = ResourceFactory.createProperty(NS + "desc"); public final static Property distinct = ResourceFactory.createProperty(NS + "distinct"); public final static Property else_ = ResourceFactory.createProperty(NS + "else"); public final static Property exists = ResourceFactory.createProperty(NS + "exists"); public final static Property groupConcat = ResourceFactory.createProperty(NS + "groupConcat"); public final static Property if_ = ResourceFactory.createProperty(NS + "if"); public final static Property limit = ResourceFactory.createProperty(NS + "limit"); public final static Property max = ResourceFactory.createProperty(NS + "max"); public final static Property min = ResourceFactory.createProperty(NS + "min"); public final static Property minus = ResourceFactory.createProperty(NS + "minus"); public final static Property offset = ResourceFactory.createProperty(NS + "offset"); public final static Property orderBy = ResourceFactory.createProperty(NS + "orderBy"); public final static Property separator = ResourceFactory.createProperty(NS + "separator"); public final static Property sum = ResourceFactory.createProperty(NS + "sum"); public final static Property then = ResourceFactory.createProperty(NS + "then"); public final static Property values = ResourceFactory.createProperty(NS + "values"); public static final Var currentShapeVar = Var.alloc("currentShape"); public static final Var failureVar = Var.alloc("failure"); public static final Var PATHVar = Var.alloc("PATH"); public static final Var pathVar = Var.alloc(path.getLocalName()); public static final Var shapesGraphVar = Var.alloc("shapesGraph"); public static final Var thisVar = Var.alloc("this"); public static final Var valueVar = Var.alloc("value"); public final static String JS_DATA_VAR = "$data"; public final static String JS_SHAPES_VAR = "$shapes"; public static String getURI() { return NS; } } <MSG> Improved support for scopes <DFF> @@ -61,6 +61,8 @@ public class SH { public final static Resource PropertyConstraint = ResourceFactory.createResource(NS + "PropertyConstraint"); + public final static Resource Scope = ResourceFactory.createResource(NS + "Scope"); + public final static Resource Shape = ResourceFactory.createResource(NS + "Shape"); public final static Resource ShapeClass = ResourceFactory.createResource(NS + "ShapeClass"); @@ -68,6 +70,8 @@ public class SH { public final static Resource Template = ResourceFactory.createResource(NS + "Template"); public final static Resource TemplateConstraint = ResourceFactory.createResource(NS + "TemplateConstraint"); + + public final static Resource TemplateScope = ResourceFactory.createResource(NS + "TemplateScope"); public final static Resource Templates = ResourceFactory.createResource(NS + "Templates"); @@ -95,6 +99,8 @@ public class SH { public final static Property entailment = ResourceFactory.createProperty(NS + "entailment"); public final static Property filterShape = ResourceFactory.createProperty(NS + "filterShape"); + + public final static Property final_ = ResourceFactory.createProperty(NS + "final"); public final static Property graph = ResourceFactory.createProperty(NS + "graph"); @@ -133,6 +139,8 @@ public class SH { public final static Property optionalWhenInherited = ResourceFactory.createProperty(NS + "optionalWhenInherited"); public final static Property predicate = ResourceFactory.createProperty(NS + "predicate"); + + public final static Property private_ = ResourceFactory.createProperty(NS + "private"); public final static Property property = ResourceFactory.createProperty(NS + "property");
8
Improved support for scopes
0
.java
java
apache-2.0
TopQuadrant/shacl
12
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sh: <http://www.w3.org/ns/shacl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 002" ; owl:imports <http://datashapes.org/dash> ; . ex:GraphValidationTestCase rdf:type dash:GraphValidationTestCase ; dash:expectedResult [ rdf:type sh:ValidationReport ; sh:conforms "false"^^xsd:boolean ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; sh:resultPath ex:property ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -28,6 +28,7 @@ ex:GraphValidationTestCase sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; + dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ;
1
Tracking latest SHACL spec
0
.ttl
test
apache-2.0
TopQuadrant/shacl
13
<NME> anon-shape-002.test.ttl <BEF> # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test # imports: http://datashapes.org/dash # prefix: ex @prefix dash: <http://datashapes.org/dash#> . @prefix ex: <http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sh: <http://www.w3.org/ns/shacl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test> rdf:type owl:Ontology ; rdfs:label "Test of anonymous shape definition 002" ; owl:imports <http://datashapes.org/dash> ; . ex:GraphValidationTestCase rdf:type dash:GraphValidationTestCase ; dash:expectedResult [ rdf:type sh:ValidationReport ; sh:conforms "false"^^xsd:boolean ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:InvalidNode1 ; sh:resultPath ex:property ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ; rdfs:label "Invalid node 1" ; . ex:ValidNode1 ex:property 42 ; . [ rdf:type sh:NodeShape ; rdfs:label "Anon shape" ; sh:property [ sh:path ex:property ; sh:datatype xsd:integer ; sh:maxCount 1 ; sh:minCount 1 ; sh:name "property" ; ] ; sh:targetNode ex:InvalidNode1 ; sh:targetNode ex:ValidNode1 ; ]. <MSG> Tracking latest SHACL spec <DFF> @@ -28,6 +28,7 @@ ex:GraphValidationTestCase sh:sourceConstraintComponent sh:MinCountConstraintComponent ; ] ; ] ; + dash:validateShapes "true"^^xsd:boolean ; . ex:InvalidNode1 rdfs:label "Invalid node 1" ;
1
Tracking latest SHACL spec
0
.ttl
test
apache-2.0
TopQuadrant/shacl
14
<NME> sparqlscope-001.test.ttl <BEF> ADDFILE <MSG> Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid <DFF> @@ -0,0 +1,53 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix sh: <http://www.w3.org/ns/shacl#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparqlscope-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer"^^xsd:string ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidInstance1 ; + sh:predicate rdfs:label ; + sh:severity sh:Violation ; + sh:subject ex:InvalidInstance1 ; + ] ; +. +ex:InvalidInstance1 + rdf:type owl:Thing ; + rdfs:label "Invalid instance1"^^xsd:string ; +. +ex:TestShape + rdf:type sh:Shape ; + rdfs:label "Test shape"^^xsd:string ; + sh:property [ + rdfs:comment "Must not have any rdfs:label"^^xsd:string ; + rdfs:label "label"^^xsd:string ; + sh:datatype xsd:string ; + sh:maxCount 0 ; + sh:predicate rdfs:label ; + ] ; + sh:scope [ + rdf:type sh:SPARQLScope ; + sh:sparql """SELECT ?this +WHERE { + ?this a owl:Thing . +}""" ; + ] ; +. +ex:ValidInstance1 + rdf:type owl:Thing ; +.
53
Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid
0
.ttl
test
apache-2.0
TopQuadrant/shacl
15
<NME> sparqlscope-001.test.ttl <BEF> ADDFILE <MSG> Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid <DFF> @@ -0,0 +1,53 @@ +# baseURI: http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test +# imports: http://datashapes.org/dash +# prefix: ex + +@prefix dash: <http://datashapes.org/dash#> . +@prefix ex: <http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix sh: <http://www.w3.org/ns/shacl#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +<http://datashapes.org/sh/tests/sparql/scope/sparqlscope-001.test> + rdf:type owl:Ontology ; + rdfs:label "Test of sparqlscope-001" ; + owl:imports <http://datashapes.org/dash> ; + owl:versionInfo "Created with TopBraid Composer"^^xsd:string ; +. +ex:GraphValidationTestCase + rdf:type dash:GraphValidationTestCase ; + dash:expectedResult [ + rdf:type sh:ValidationResult ; + sh:focusNode ex:InvalidInstance1 ; + sh:predicate rdfs:label ; + sh:severity sh:Violation ; + sh:subject ex:InvalidInstance1 ; + ] ; +. +ex:InvalidInstance1 + rdf:type owl:Thing ; + rdfs:label "Invalid instance1"^^xsd:string ; +. +ex:TestShape + rdf:type sh:Shape ; + rdfs:label "Test shape"^^xsd:string ; + sh:property [ + rdfs:comment "Must not have any rdfs:label"^^xsd:string ; + rdfs:label "label"^^xsd:string ; + sh:datatype xsd:string ; + sh:maxCount 0 ; + sh:predicate rdfs:label ; + ] ; + sh:scope [ + rdf:type sh:SPARQLScope ; + sh:sparql """SELECT ?this +WHERE { + ?this a owl:Thing . +}""" ; + ] ; +. +ex:ValidInstance1 + rdf:type owl:Thing ; +.
53
Update to latest spec, moved to latest Jena 3.1 snapshot, test cases aligned with TopBraid
0
.ttl
test
apache-2.0
TopQuadrant/shacl
16
<NME> README.md <BEF> # TopBraid SHACL API **An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.** Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library uses code from org.topbraid.spin packages. These will eventually be refactored. Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly. * [SHACL Compact Syntax](https://w3c.github.io/shacl/shacl-compact-syntax/) Former Coverage until version 1.3.2 * [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/) The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes) and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves). The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release). Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list: https://groups.google.com/forum/#!forum/topbraid-users Please prefix your messages with [SHACL API] To get started, look at the class ValidationUtil in the package org.topbraid.shacl.validation. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) ## Application dependency Releases are available in the central maven repository: ``` <dependency> <groupId>org.topbraid</groupId> <artifactId>shacl</artifactId> <version>*VER*</version> </dependency> ``` ## Command Line Usage Download the latest release from: `https://repo1.maven.org/maven2/org/topbraid/shacl/` The binary distribution is: `https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`. Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing). To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena). For example, on Windows: ``` SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin SET PATH=%PATH%;%SHACLROOT%\bin ``` As another example, for Linux, add to .bashrc these lines: ``` # for shacl export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin export PATH=$SHACLROOT:$PATH ``` Both tools take the following parameters, for example: `shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl` where `-shapesfile` is optional and falls back to using the data graph as shapes graph. Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular). Currently only Turtle (.ttl) files are supported. The tools print the validation report or the inferences graph to the output screen. <MSG> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library uses code from org.topbraid.spin packages. These will eventually be refactored. Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
1
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
17
<NME> README.md <BEF> # TopBraid SHACL API **An open source implementation of the W3C Shapes Constraint Language (SHACL) based on Apache Jena.** Contact: Holger Knublauch (holger@topquadrant.com) Can be used to perform SHACL constraint checking and rule inferencing in any Jena-based Java application. This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library uses code from org.topbraid.spin packages. These will eventually be refactored. Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly. * [SHACL Compact Syntax](https://w3c.github.io/shacl/shacl-compact-syntax/) Former Coverage until version 1.3.2 * [SHACL JavaScript Extensions](https://www.w3.org/TR/shacl-js/) The TopBraid SHACL API is internally used by the European Commission's generic [SHACL-based RDF validator](https://www.itb.ec.europa.eu/shacl/any/upload) (used to validate RDF content against SHACL shapes) and [SHACL shape validator](https://www.itb.ec.europa.eu/shacl/shacl/upload) (used to validate SHACL shapes themselves). The same code is used in the TopBraid products (currently aligned with the TopBraid 7.1 release). Feedback and questions should become GitHub issues or sent to TopBraid Users mailing list: https://groups.google.com/forum/#!forum/topbraid-users Please prefix your messages with [SHACL API] To get started, look at the class ValidationUtil in the package org.topbraid.shacl.validation. There is also an [Example Test Case](../master/src/test/java/org/topbraid/shacl/ValidationExample.java) ## Application dependency Releases are available in the central maven repository: ``` <dependency> <groupId>org.topbraid</groupId> <artifactId>shacl</artifactId> <version>*VER*</version> </dependency> ``` ## Command Line Usage Download the latest release from: `https://repo1.maven.org/maven2/org/topbraid/shacl/` The binary distribution is: `https://repo1.maven.org/maven2/org/topbraid/shacl/*VER*/shacl-*VER*-bin.zip`. Two command line utilities are included: shaclvalidate (performs constraint validation) and shaclinfer (performs SHACL rule inferencing). To use them, set up your environment similar to https://jena.apache.org/documentation/tools/ (note that the SHACL download includes Jena). For example, on Windows: ``` SET SHACLROOT=C:\Users\Holger\Desktop\shacl-1.4.1-bin SET PATH=%PATH%;%SHACLROOT%\bin ``` As another example, for Linux, add to .bashrc these lines: ``` # for shacl export SHACLROOT=/home/holger/shacl/shacl-1.4.1-bin/shacl-1.4.1/bin export PATH=$SHACLROOT:$PATH ``` Both tools take the following parameters, for example: `shaclvalidate.bat -datafile myfile.ttl -shapesfile myshapes.ttl` where `-shapesfile` is optional and falls back to using the data graph as shapes graph. Add -validateShapes in case you want to include the metashapes (from the tosh namespace in particular). Currently only Turtle (.ttl) files are supported. The tools print the validation report or the inferences graph to the output screen. <MSG> Merge branch 'master' of https://github.com/TopQuadrant/shacl <DFF> @@ -8,7 +8,7 @@ Can be used to perform SHACL constraint checking in any Jena-based Java applicat This API also serves as a reference implementation developed in parallel to the SHACL spec. **The code is totally not optimized for performance, just for correctness. And there are unfinished gaps!** -The same code is used in the TopBraid products (currently ahead of the release cycle, TopBraid 5.2 will catch up). +The same code is used in the TopBraid products (currently slightly ahead of the release cycle, TopBraid 5.3 will catch up). For interoperability with TopBraid, and during the transition period from SPIN to SHACL, this library uses code from org.topbraid.spin packages. These will eventually be refactored. Meanwhile, please don't rely on any class from the org.topbraid.spin packages directly.
1
Merge branch 'master' of https://github.com/TopQuadrant/shacl
1
.md
md
apache-2.0
TopQuadrant/shacl
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
860
Edit dataset card