Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sh:class not working as expected. #118

Open
neormx opened this issue Aug 15, 2018 · 4 comments
Open

sh:class not working as expected. #118

neormx opened this issue Aug 15, 2018 · 4 comments

Comments

@neormx
Copy link

neormx commented Aug 15, 2018

If I try next model I always got <http://localhost/vocabulary/Me> doesn't belong to class <http://localhost/vocabulary/Person> which is not true:

@prefix family: <http://localhost/vocabulary/> .
@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#> .
@prefix oslc: <http://open-services.net/ns/core#> .


<http://localhost/vocabulary/family>
  rdf:type owl:Ontology ;
  owl:imports <http://datashapes.org/dash> ;
.

<http://localhost/vocabulary/Person>
    a rdfs:Class, sh:NodeShape ;
    rdfs:label "Person" ;
    sh:property [
    	sh:nodeKind sh:Literal ;
    	sh:datatype xsd:string ;
        sh:path <http://localhost/vocabulary/name> ;
    ] ;
    sh:property [
        sh:path <http://localhost/vocabulary/friend> ;
		sh:nodeKind sh:BlankNodeOrIRI ;
		sh:class family:Person ;
    ] ;
.


<>  a  family:Person ;
	family:name  "Ricardo" ;
	family:friend family:Me ;
.

family:Me a <http://localhost/vocabulary/Person> ;
	family:name  "Javier" ;
.

The complete and exact 0.1.02 response (through https://github.com/eclipse/lyo.validation) is:

[
	{
		"valid": false,
		"type": "Result",
		"message": "Not valid",
		"shapeMap": [
			{
				"node": "<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>",
				"shape": "<http://localhost/vocabulary/Person>",
				"status": "nonconformant",
				"appInfo": null,
				"reason": "Error: Violation Error(<http://www.w3.org/ns/shacl#ShapesFailed>). Node(<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>) LiteralValue(\"<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875> does not have nodeShape http://localhost/vocabulary/Person because some shapes failed.\")"
			},
			{
				"node": "<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>",
				"shape": "_:7f24532cccec2a0ce73e95087d67ea44",
				"status": "conformant",
				"appInfo": null,
				"reason": "Evidences: \"Ricardo\" has datatype <http://www.w3.org/2001/XMLSchema#string>\n \"Ricardo\" is a Literal\n Checked minCount(1) for path(PredicatePath(<http://localhost/vocabulary/name>)) on node <http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>\n Checked maxCount(1) for path(PredicatePath(<http://localhost/vocabulary/name>)) on node <http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>\n <http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875> satisfies property shape PropertyShape(_:7f24532cccec2a0ce73e95087d67ea44,PredicatePath(<http://localhost/vocabulary/name>),List(MaxCount(1), MinCount(1), NodeKind(LiteralKind), Datatype(<http://www.w3.org/2001/XMLSchema#string>)),List(),List(),false,List())"
			},
			{
				"node": "<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>",
				"shape": "_:a0ce8436f205b870d4a1bdef53b70306",
				"status": "nonconformant",
				"appInfo": null,
				"reason": "Error: Violation Error(<http://www.w3.org/ns/shacl#ShapesFailed>). Node(<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875>) LiteralValue(\"Property shape failed\")\n Violation Error(<http://www.w3.org/ns/shacl#ClassConstraintComponent>). Node(<http://localhost/vocabulary/Me>) LiteralValue(\"Node <http://localhost/vocabulary/Me> doesn't belong to class <http://localhost/vocabulary/Person>\")"
			}
		],
		"errors": [
			{
				"type": "ErrorInfo",
				"error": "sh:ShapesFailed FocusNode: <http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875> LiteralValue(\"<http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875> does not have nodeShape http://localhost/vocabulary/Person because some shapes failed.\")"
			},
			{
				"type": "ErrorInfo",
				"error": "sh:ShapesFailed FocusNode: <http://localhost:8080/dynamic-oslc/rest/oslc/default/resource/Person/1534341259875> LiteralValue(\"Property shape failed\")"
			},
			{
				"type": "ErrorInfo",
				"error": "sh:ClassConstraintComponent FocusNode: family:Me LiteralValue(\"Node <http://localhost/vocabulary/Me> doesn't belong to class <http://localhost/vocabulary/Person>\")"
			}
		],
		"nodesPrefixMap": {
		},
		"shapesPrefixMap": {
			"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
			"oslc": "http://open-services.net/ns/core#",
			"owl": "http://www.w3.org/2002/07/owl#",
			"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
			"xsd": "http://www.w3.org/2001/XMLSchema#",
			"family": "http://localhost/vocabulary/",
			"sh": "http://www.w3.org/ns/shacl#"
		}
	}
]
@berezovskyi
Copy link
Contributor

berezovskyi commented Aug 15, 2018

@neormx you mentioned to me on Slack that using shaclex directly worked well but only from the HEAD. Could you please post the Java/Scala code to see how did you invoke shaclex directly?

BTW, I just tried the shacl.js based validator and it seems to work, but I made the following changes

Data graph:

@prefix family: <http://localhost/vocabulary/> .
@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#> .
@prefix oslc: <http://open-services.net/ns/core#> .

<http://localhost/vocabulary/Person> a rdfs:Class .


<>  a  family:Person ;
	family:name  "Ricardo" ;
	family:friend family:Me ;
.

family:Me a <http://localhost/vocabulary/Person> ;
	family:name  "Javier" ;
.

Shape graph:

@prefix family: <http://localhost/vocabulary/> .
@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#> .
@prefix oslc: <http://open-services.net/ns/core#> .

<http://localhost/vocabulary/PersonShape>
    a sh:NodeShape ;
	sh:targetClass <http://localhost/vocabulary/Person>;
    rdfs:label "Person" ;
    sh:property [
    	sh:nodeKind sh:Literal ;
    	sh:datatype xsd:string ;
        sh:path <http://localhost/vocabulary/name> ;
    ] ;
    sh:property [
        sh:path <http://localhost/vocabulary/friend> ;
		sh:nodeKind sh:BlankNodeOrIRI ;
		sh:class family:Person ;
    ] ;
.

@neormx
Copy link
Author

neormx commented Aug 15, 2018

@berezovskyi I just tried with your graphs and no luck, hope not being missing something. To run directly with shaclex, I saved the graph posted on my original comment on a file, e.g. dynamic.ttl, then execute from console at the project's home directory:

sbt "run --data dynamic.ttl --engine ShaClex"

@labra
Copy link
Member

labra commented Aug 16, 2018

You can also try the rdfshape tool. I tried @berezovskyi's example and it works as you can see here.

I also tried the original one and it also seems to work, see here.

I also run the example using the command line tool with the arguments you provided and it returns valid. Are you using the latest "Shaclex" version? At this moment: 0.1.02 ?

@berezovskyi
Copy link
Contributor

@labra I actually managed to reproduce @neormx's example. But I believe it might be a bug in our lyo.validation library and not in shaclex.

The following works:

_:p1  a  family:Person ;
  family:name  "Ricardo" ;
  family:friend _:p2 .

_:p2 a family:Person ;
  family:name  “Javier" .

and the following does too:

<p1>  a  family:Person ;
  family:name  "Ricardo" ;
  family:friend <p2> .

<p2> a family:Person ;
  family:name  “Javier" .

But this fails:

_:p1  a  family:Person ;
  family:name  "Ricardo" ;
  family:friend <p2> .

<p2> a family:Person ;
  family:name  "Javier" .

The dependencies used in a test:

[INFO] com.example:shacl:jar:1.0-SNAPSHOT
[INFO] +- org.eclipse.lyo:lyo-validation:jar:2.3.0:compile
[INFO] |  +- org.apache.jena:jena-core:jar:3.0.1:compile
[INFO] |  |  +- org.apache.jena:jena-iri:jar:3.0.1:compile
[INFO] |  |  +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  |  +- commons-cli:commons-cli:jar:1.3:compile
[INFO] |  |  \- org.apache.jena:jena-base:jar:3.0.1:compile
[INFO] |  |     \- com.github.andrewoma.dexx:dexx-collections:jar:0.2:compile
[INFO] |  +- org.apache.jena:jena-arq:jar:3.0.1:compile
[INFO] |  |  +- org.apache.jena:jena-shaded-guava:jar:3.0.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.2.6:compile
[INFO] |  |  |  +- org.apache.httpcomponents:httpcore:jar:4.2.5:compile
[INFO] |  |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  |  +- com.github.jsonld-java:jsonld-java:jar:0.7.0:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] |  |  |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] |  |  |  \- commons-io:commons-io:jar:2.4:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient-cache:jar:4.2.6:compile
[INFO] |  |  +- org.apache.thrift:libthrift:jar:0.9.2:compile
[INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] |  |  +- org.apache.commons:commons-csv:jar:1.0:compile
[INFO] |  |  \- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] |  +- es.weso:shaclex_2.12:pom:0.0.63:compile
[INFO] |  |  +- org.scala-lang:scala-compiler:jar:2.12.2:runtime
[INFO] |  |  |  \- org.scala-lang.modules:scala-xml_2.12:jar:1.0.6:compile
[INFO] |  |  +- es.weso:schema_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:shacl_2.12:jar:0.0.63:compile
[INFO] |  |  |  +- com.github.nikita-volkov:sext:jar:0.2.4:compile
[INFO] |  |  |  |  +- org.scala-lang:scala-reflect:jar:2.12.0-RC2:compile (version selected from constraint [2.10,2.12))
[INFO] |  |  |  |  \- org.scala-lang:scala-library:jar:2.12.0-RC2:compile (version selected from constraint [2.10,2.12))
[INFO] |  |  |  \- org.typelevel:cats_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-macros_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-kernel_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-kernel-laws_2.12:jar:0.9.0:compile
[INFO] |  |  |     |  +- org.scalacheck:scalacheck_2.12:jar:1.13.4:compile
[INFO] |  |  |     |  |  \- org.scala-sbt:test-interface:jar:1.0:compile
[INFO] |  |  |     |  +- org.typelevel:discipline_2.12:jar:0.7.2:compile
[INFO] |  |  |     |  \- org.typelevel:catalysts-platform_2.12:jar:0.0.5:compile
[INFO] |  |  |     |     \- org.typelevel:catalysts-macros_2.12:jar:0.0.5:compile
[INFO] |  |  |     +- org.typelevel:cats-core_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-laws_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-free_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- org.typelevel:cats-jvm_2.12:jar:0.9.0:compile
[INFO] |  |  |     +- com.github.mpilquist:simulacrum_2.12:jar:0.10.0:compile
[INFO] |  |  |     \- org.typelevel:machinist_2.12:jar:0.6.1:compile
[INFO] |  |  +- es.weso:shex_2.12:jar:0.0.63:compile
[INFO] |  |  |  +- org.antlr:antlr4:jar:4.5:compile
[INFO] |  |  |  |  +- org.antlr:antlr4-runtime:jar:4.5:compile
[INFO] |  |  |  |  |  \- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1:compile
[INFO] |  |  |  |  +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] |  |  |  |  \- org.antlr:ST4:jar:4.0.8:compile
[INFO] |  |  |  +- io.circe:circe-core_2.12:jar:0.8.0:compile
[INFO] |  |  |  |  \- io.circe:circe-numbers_2.12:jar:0.8.0:compile
[INFO] |  |  |  +- io.circe:circe-generic_2.12:jar:0.8.0:compile
[INFO] |  |  |  |  +- org.typelevel:macro-compat_2.12:jar:1.1.1:compile
[INFO] |  |  |  |  \- com.chuusai:shapeless_2.12:jar:2.3.2:compile
[INFO] |  |  |  \- io.circe:circe-parser_2.12:jar:0.8.0:compile
[INFO] |  |  |     \- io.circe:circe-jawn_2.12:jar:0.8.0:compile
[INFO] |  |  |        \- org.spire-math:jawn-parser_2.12:jar:0.10.4:compile
[INFO] |  |  +- es.weso:manifest_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:srdfjena_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:srdf_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:utils_2.12:jar:0.0.63:compile
[INFO] |  |  |  +- org.atnos:eff_2.12:jar:3.0.2:compile
[INFO] |  |  |  \- org.gnieh:diffson-circe_2.12:jar:2.1.2:compile
[INFO] |  |  |     \- org.gnieh:diffson-core_2.12:jar:2.1.2:compile
[INFO] |  |  +- es.weso:converter_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:rbe_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:typing_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:validating_2.12:jar:0.0.63:compile
[INFO] |  |  +- es.weso:server_2.12:jar:0.0.63:compile
[INFO] |  |  |  +- com.typesafe.play:twirl-api_2.12:jar:1.3.0:compile
[INFO] |  |  |  +- org.http4s:http4s-dsl_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |  +- org.typelevel:scala-library:jar:2.12.1:compile
[INFO] |  |  |  |  \- org.http4s:http4s-core_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |     +- co.fs2:fs2-cats_2.12:jar:0.3.0:compile
[INFO] |  |  |  |     |  \- co.fs2:fs2-core_2.12:jar:0.9.2:compile
[INFO] |  |  |  |     +- co.fs2:fs2-io_2.12:jar:0.9.5:compile
[INFO] |  |  |  |     +- org.http4s:http4s-websocket_2.12:jar:0.1.6:compile
[INFO] |  |  |  |     +- org.log4s:log4s_2.12:jar:1.3.4:compile
[INFO] |  |  |  |     \- org.scodec:scodec-bits_2.12:jar:1.1.4:compile
[INFO] |  |  |  +- org.http4s:http4s-blaze-server_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |  +- org.http4s:http4s-blaze-core_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |  |  \- org.http4s:blaze-http_2.12:jar:0.12.5:compile
[INFO] |  |  |  |  |     +- org.http4s:blaze-core_2.12:jar:0.12.5:compile
[INFO] |  |  |  |  |     +- com.twitter:hpack:jar:v1.0.1:compile
[INFO] |  |  |  |  |     \- org.eclipse.jetty.alpn:alpn-api:jar:1.1.2.v20150522:compile
[INFO] |  |  |  |  \- org.http4s:http4s-server_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  +- org.http4s:http4s-blaze-client_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |  \- org.http4s:http4s-client_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  +- org.http4s:http4s-circe_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |  \- org.http4s:http4s-jawn_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  |     \- org.http4s:jawn-fs2_2.12:jar:0.10.1:compile
[INFO] |  |  |  +- org.http4s:http4s-twirl_2.12:jar:0.17.0-M3:compile
[INFO] |  |  |  \- com.lihaoyi:scalatags_2.12:jar:0.6.2:compile
[INFO] |  |  |     \- com.lihaoyi:sourcecode_2.12:jar:0.1.3:compile
[INFO] |  |  +- org.scalactic:scalactic_2.12:jar:3.0.1:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.1.7:compile
[INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.1.7:compile
[INFO] |  |  +- com.typesafe.scala-logging:scala-logging_2.12:jar:3.5.0:compile
[INFO] |  |  \- org.rogach:scallop_2.12:jar:2.0.6:compile
[INFO] |  +- com.google.guava:guava:jar:21.0:compile
[INFO] |  +- org.eclipse.lyo.oslc4j.core:oslc4j-core:jar:2.3.0:compile
[INFO] |  |  \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] |  +- org.eclipse.lyo.oslc4j.core:oslc4j-jena-provider:jar:2.3.0:compile
[INFO] |  +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.7.24:compile
[INFO] |  \- com.google.code.gson:gson:jar:2.8.1:compile
[INFO] +- org.apache.jena:jena-tdb:jar:3.0.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] \- junit:junit:jar:4.12:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test

P.S. Code was provided @neormx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants