├── .dockerignore ├── .editorconfig ├── .flake8 ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── CITATION.cff ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── Dockerfile ├── FEATURES.md ├── LICENSE.txt ├── MANIFEST.in ├── Makefile ├── README.md ├── benchmarks └── benchmark.py ├── examples ├── advanced.py ├── example.py ├── remote_sparql.py ├── sparql_assert_datatype.py └── two_file_example.py ├── hooks └── pre-commit ├── poetry.lock ├── poetry.toml ├── pySHACL-250.png ├── pySHACL.png ├── pySHACL.svg ├── pyproject.toml ├── pyshacl ├── __init__.py ├── __main__.py ├── assets │ ├── dash.pickle │ ├── dash.ttl │ ├── make_builtin.py │ ├── schema.pickle │ ├── schema.ttl │ ├── shacl-shacl.pickle │ ├── shacl-shacl.ttl │ ├── shacl.pickle │ └── shacl.ttl ├── cli.py ├── cli_rules.py ├── constraints │ ├── __init__.py │ ├── advanced │ │ └── __init__.py │ ├── constraint_component.py │ ├── core │ │ ├── __init__.py │ │ ├── cardinality_constraints.py │ │ ├── logical_constraints.py │ │ ├── other_constraints.py │ │ ├── property_pair_constraints.py │ │ ├── shape_based_constraints.py │ │ ├── string_based_constraints.py │ │ ├── value_constraints.py │ │ └── value_range_constraints.py │ └── sparql │ │ ├── __init__.py │ │ ├── sparql_based_constraint_components.py │ │ └── sparql_based_constraints.py ├── consts.py ├── entrypoints.py ├── errors.py ├── extras │ ├── __init__.py │ └── js │ │ ├── __init__.py │ │ ├── constraint.py │ │ ├── constraint_component.py │ │ ├── context.py │ │ ├── function.py │ │ ├── js_executable.py │ │ ├── loader.py │ │ ├── rules.py │ │ └── target.py ├── functions │ ├── __init__.py │ └── shacl_function.py ├── helper │ ├── __init__.py │ ├── expression_helper.py │ ├── path_helper.py │ └── sparql_query_helper.py ├── inference │ ├── __init__.py │ └── custom_rdfs_closure.py ├── monkey │ └── __init__.py ├── parameter.py ├── py.typed ├── pyshacl-cli.spec ├── pytypes.py ├── rdfutil │ ├── __init__.py │ ├── clone.py │ ├── compare.py │ ├── consts.py │ ├── inoculate.py │ ├── load.py │ ├── pytypes.py │ └── stringify.py ├── rule_expand_runner.py ├── rules │ ├── __init__.py │ ├── shacl_rule.py │ ├── sparql │ │ └── __init__.py │ └── triple │ │ └── __init__.py ├── run_type.py ├── sh_http.py ├── shape.py ├── shapes_graph.py ├── target.py ├── validator.py └── validator_conformance.py └── test ├── __init__.py ├── helpers.py ├── implementation_report.py ├── issues ├── __init__.py ├── bad_test_070.py ├── issue_102.py ├── test_008.py ├── test_009.py ├── test_012.py ├── test_014.py ├── test_026.py ├── test_029 │ ├── __init__.py │ ├── simpleData.ttl │ └── simpleOnto.ttl ├── test_036.py ├── test_038.py ├── test_040 │ ├── 03-Network.ttl │ ├── __init__.py │ └── sample-network.ttl ├── test_058.py ├── test_062.py ├── test_071.py ├── test_076.py ├── test_079.py ├── test_087.py ├── test_098.py ├── test_108.py ├── test_116.py ├── test_120.py ├── test_124.py ├── test_126.py ├── test_133.py ├── test_141.py ├── test_142.py ├── test_146.py ├── test_148.py ├── test_154.py ├── test_160.py ├── test_162.py ├── test_170.py ├── test_190.py ├── test_199.py ├── test_213.py ├── test_217.py ├── test_220 │ ├── LICENSE.md │ ├── __init__.py │ ├── kb-REPRODUCTION-1.ttl │ ├── kb-REPRODUCTION-2.ttl │ ├── owl-REPRODUCTION.ttl │ ├── sh-REPRODUCTION-1.ttl │ └── sh-REPRODUCTION-2.ttl ├── test_227.py ├── test_240.py ├── test_281 │ ├── data.ttl │ ├── policies.ttl │ ├── policies │ │ └── gitlab-policy.ttl │ └── test_281.py ├── test_286.py ├── test_96.py └── test_w3_list1.py ├── resources ├── cmdline_tests │ ├── d1.jsonld │ ├── d1.ttl │ ├── d2.ttl │ ├── o1.ttl │ ├── rules_d.ttl │ ├── rules_s.ttl │ └── s1.ttl ├── dash_tests │ ├── core │ │ ├── complex │ │ │ └── personexample.test.ttl │ │ ├── misc │ │ │ ├── deactivated-001.test.ttl │ │ │ ├── deactivated-002.test.ttl │ │ │ ├── severity-001.test.ttl │ │ │ └── severity-002.test.ttl │ │ ├── node │ │ │ ├── and-001.test.ttl │ │ │ ├── and-002.test.ttl │ │ │ ├── class-001.test.ttl │ │ │ ├── class-002.test.ttl │ │ │ ├── closed-001.test.ttl │ │ │ ├── closed-002.test.ttl │ │ │ ├── datatype-001.test.ttl │ │ │ ├── datatype-002.test.ttl │ │ │ ├── disjoint-001.test.ttl │ │ │ ├── equals-001.test.ttl │ │ │ ├── hasValue-001.test.ttl │ │ │ ├── in-001.test.ttl │ │ │ ├── languageIn-001.test.ttl │ │ │ ├── maxExclusive-001.test.ttl │ │ │ ├── maxInclusive-001.test.ttl │ │ │ ├── maxLength-001.test.ttl │ │ │ ├── minExclusive-001.test.ttl │ │ │ ├── minInclusive-001.test.ttl │ │ │ ├── minLength-001.test.ttl │ │ │ ├── node-001.test.ttl │ │ │ ├── nodeKind-001.test.ttl │ │ │ ├── not-001.test.ttl │ │ │ ├── not-002.test.ttl │ │ │ ├── or-001.test.ttl │ │ │ ├── pattern-001.test.ttl │ │ │ ├── pattern-002.test.ttl │ │ │ └── xone-001.test.ttl │ │ ├── path │ │ │ ├── path-alternative-001.test.ttl │ │ │ ├── path-complex-001.test.ttl │ │ │ ├── path-inverse-001.test.ttl │ │ │ ├── path-oneOrMore-001.test.ttl │ │ │ ├── path-sequence-001.test.ttl │ │ │ ├── path-sequence-002.test.ttl │ │ │ ├── path-sequence-duplicate-001.test.ttl │ │ │ ├── path-zeroOrMore-001.test.ttl │ │ │ └── path-zeroOrOne-001.test.ttl │ │ ├── property │ │ │ ├── and-001.test.ttl │ │ │ ├── class-001.test.ttl │ │ │ ├── datatype-001.test.ttl │ │ │ ├── datatype-002.test.ttl │ │ │ ├── datatype-003.test.ttl │ │ │ ├── disjoint-001.test.ttl │ │ │ ├── equals-001.test.ttl │ │ │ ├── hasValue-001.test.ttl │ │ │ ├── in-001.test.ttl │ │ │ ├── languageIn-001.test.ttl │ │ │ ├── lessThan-001.test.ttl │ │ │ ├── lessThan-002.test.ttl │ │ │ ├── lessThanOrEquals-001.test.ttl │ │ │ ├── maxCount-001.test.ttl │ │ │ ├── maxCount-002.test.ttl │ │ │ ├── maxExclusive-001.test.ttl │ │ │ ├── maxInclusive-001.test.ttl │ │ │ ├── maxLength-001.test.ttl │ │ │ ├── minCount-001.test.ttl │ │ │ ├── minCount-002.test.ttl │ │ │ ├── minExclusive-001.test.ttl │ │ │ ├── minExclusive-002.test.ttl │ │ │ ├── minLength-001.test.ttl │ │ │ ├── node-001.test.ttl │ │ │ ├── node-002.test.ttl │ │ │ ├── nodeKind-001.test.ttl │ │ │ ├── not-001.test.ttl │ │ │ ├── or-001.test.ttl │ │ │ ├── or-datatypes-001.test.ttl │ │ │ ├── pattern-001.test.ttl │ │ │ ├── pattern-002.test.ttl │ │ │ ├── property-001.test.ttl │ │ │ ├── qualifiedMinCountDisjoint-001.test.ttl │ │ │ ├── qualifiedValueShape-001.test.ttl │ │ │ ├── qualifiedValueShapesDisjoint-001.test.ttl │ │ │ ├── uniqueLang-001.test.ttl │ │ │ └── xone-001.test.ttl │ │ └── targets │ │ │ ├── multipleTargets-001.test.ttl │ │ │ ├── targetClass-001.test.ttl │ │ │ ├── targetClassImplicit-001.test.ttl │ │ │ ├── targetNode-001.test.ttl │ │ │ ├── targetObjectsOf-001.test.ttl │ │ │ ├── targetSubjectsOf-001.test.ttl │ │ │ └── targetSubjectsOf-002.test.ttl │ ├── expression │ │ └── booleans-001.test.ttl │ ├── function │ │ ├── callSPARQLFunction.test.ttl │ │ └── simpleSPARQLFunction.test.ttl │ ├── rules │ │ ├── sparql │ │ │ ├── classify-square.test.ttl │ │ │ └── rectangle.test.ttl │ │ └── triple │ │ │ ├── functions-permutations.test.ttl │ │ │ ├── person.ttl │ │ │ ├── person2schema.test.ttl │ │ │ ├── rectangle.test.ttl │ │ │ ├── schema2person.test.ttl │ │ │ └── square.test.ttl │ ├── shapedefs │ │ ├── anon-shape-001.test.ttl │ │ └── anon-shape-002.test.ttl │ ├── sparql │ │ ├── component │ │ │ ├── nodeValidator-001.test.ttl │ │ │ ├── optional-001.test.ttl │ │ │ ├── propertyValidator-select-001.test.ttl │ │ │ └── validator-001.test.ttl │ │ ├── node │ │ │ ├── prefixes-001.test.ttl │ │ │ ├── sparql-001.test.ttl │ │ │ └── sparql-002.test.ttl │ │ └── property │ │ │ └── sparql-001.test.ttl │ └── target │ │ ├── sparqlTarget-001.test.ttl │ │ └── sparqlTargetType-001.test.ttl ├── js │ ├── findBornIn.js │ ├── findThings.js │ ├── germanLabel.js │ ├── hasMaxCount.js │ ├── hasMaxLength.js │ ├── multiply.js │ └── rectangle.js └── sht_tests │ ├── core │ ├── complex │ │ ├── manifest.ttl │ │ ├── personexample.ttl │ │ ├── shacl-shacl-data-shapes.ttl │ │ └── shacl-shacl.ttl │ ├── manifest.ttl │ ├── misc │ │ ├── deactivated-001.ttl │ │ ├── deactivated-002.ttl │ │ ├── manifest.ttl │ │ ├── message-001.ttl │ │ ├── severity-001.ttl │ │ └── severity-002.ttl │ ├── node │ │ ├── and-001.ttl │ │ ├── and-002.ttl │ │ ├── class-001.ttl │ │ ├── class-002.ttl │ │ ├── class-003.ttl │ │ ├── closed-001.ttl │ │ ├── closed-002.ttl │ │ ├── datatype-001.ttl │ │ ├── datatype-002.ttl │ │ ├── disjoint-001.ttl │ │ ├── equals-001.ttl │ │ ├── hasValue-001.ttl │ │ ├── in-001.ttl │ │ ├── languageIn-001.ttl │ │ ├── manifest.ttl │ │ ├── maxExclusive-001.ttl │ │ ├── maxInclusive-001.ttl │ │ ├── maxLength-001.ttl │ │ ├── minExclusive-001.ttl │ │ ├── minInclusive-001.ttl │ │ ├── minInclusive-002.ttl │ │ ├── minInclusive-003.ttl │ │ ├── minLength-001.ttl │ │ ├── node-001.ttl │ │ ├── nodeKind-001.ttl │ │ ├── not-001.ttl │ │ ├── not-002.ttl │ │ ├── or-001.ttl │ │ ├── pattern-001.ttl │ │ ├── pattern-002.ttl │ │ ├── qualified-001-data.ttl │ │ ├── qualified-001-shapes.ttl │ │ ├── qualified-001.ttl │ │ ├── xone-001.ttl │ │ ├── xone-duplicate-data.ttl │ │ ├── xone-duplicate-shapes.ttl │ │ └── xone-duplicate.ttl │ ├── path │ │ ├── manifest.ttl │ │ ├── path-alternative-001.ttl │ │ ├── path-complex-001.ttl │ │ ├── path-complex-002-data.ttl │ │ ├── path-complex-002-shapes.ttl │ │ ├── path-complex-002.ttl │ │ ├── path-inverse-001.ttl │ │ ├── path-oneOrMore-001.ttl │ │ ├── path-sequence-001.ttl │ │ ├── path-sequence-002.ttl │ │ ├── path-sequence-duplicate-001.ttl │ │ ├── path-strange-001.ttl │ │ ├── path-strange-002.ttl │ │ ├── path-unused-001-data.ttl │ │ ├── path-unused-001-shapes.ttl │ │ ├── path-unused-001.ttl │ │ ├── path-zeroOrMore-001.ttl │ │ └── path-zeroOrOne-001.ttl │ ├── property │ │ ├── and-001.ttl │ │ ├── class-001.ttl │ │ ├── datatype-001.ttl │ │ ├── datatype-002.ttl │ │ ├── datatype-003.ttl │ │ ├── datatype-ill-formed-data.ttl │ │ ├── datatype-ill-formed-shapes.ttl │ │ ├── datatype-ill-formed.ttl │ │ ├── disjoint-001.ttl │ │ ├── equals-001.ttl │ │ ├── hasValue-001.ttl │ │ ├── in-001.ttl │ │ ├── languageIn-001.ttl │ │ ├── lessThan-001.ttl │ │ ├── lessThan-002.ttl │ │ ├── lessThanOrEquals-001.ttl │ │ ├── manifest.ttl │ │ ├── maxCount-001.ttl │ │ ├── maxCount-002.ttl │ │ ├── maxExclusive-001.ttl │ │ ├── maxInclusive-001.ttl │ │ ├── maxLength-001.ttl │ │ ├── minCount-001.ttl │ │ ├── minCount-002.ttl │ │ ├── minExclusive-001.ttl │ │ ├── minExclusive-002.ttl │ │ ├── minLength-001.ttl │ │ ├── node-001.ttl │ │ ├── node-002.ttl │ │ ├── nodeKind-001.ttl │ │ ├── not-001.ttl │ │ ├── or-001.ttl │ │ ├── or-datatypes-001.ttl │ │ ├── pattern-001.ttl │ │ ├── pattern-002.ttl │ │ ├── property-001.ttl │ │ ├── qualifiedMinCountDisjoint-001.ttl │ │ ├── qualifiedValueShape-001.ttl │ │ ├── qualifiedValueShapesDisjoint-001.ttl │ │ ├── uniqueLang-001.ttl │ │ ├── uniqueLang-002-data.ttl │ │ ├── uniqueLang-002-shapes.ttl │ │ └── uniqueLang-002.ttl │ ├── targets │ │ ├── manifest.ttl │ │ ├── multipleTargets-001.ttl │ │ ├── targetClass-001.ttl │ │ ├── targetClassImplicit-001.ttl │ │ ├── targetNode-001.ttl │ │ ├── targetObjectsOf-001.ttl │ │ ├── targetSubjectsOf-001.ttl │ │ └── targetSubjectsOf-002.ttl │ └── validation-reports │ │ ├── manifest.ttl │ │ ├── shared-data.ttl │ │ ├── shared-shapes.ttl │ │ └── shared.ttl │ ├── manifest.ttl │ └── sparql │ ├── component │ ├── manifest.ttl │ ├── nodeValidator-001.ttl │ ├── optional-001.ttl │ ├── propertyValidator-select-001.ttl │ └── validator-001.ttl │ ├── manifest.ttl │ ├── node │ ├── manifest.ttl │ ├── prefixes-001.ttl │ ├── sparql-001.ttl │ ├── sparql-002.ttl │ └── sparql-003.ttl │ ├── pre-binding │ ├── manifest.ttl │ ├── pre-binding-001.ttl │ ├── pre-binding-002.ttl │ ├── pre-binding-003.ttl │ ├── pre-binding-004.ttl │ ├── pre-binding-005.ttl │ ├── pre-binding-006.ttl │ ├── pre-binding-007.ttl │ ├── shapesGraph-001.ttl │ ├── unsupported-sparql-001.ttl │ ├── unsupported-sparql-002.ttl │ ├── unsupported-sparql-003.ttl │ ├── unsupported-sparql-004.ttl │ ├── unsupported-sparql-005.ttl │ └── unsupported-sparql-006.ttl │ └── property │ ├── manifest.ttl │ └── sparql-001.ttl ├── test_advanced.py ├── test_cmdline.py ├── test_cmdline_rules.py ├── test_dash_validate.py ├── test_extra.py ├── test_inoculate.py ├── test_integers.py ├── test_js ├── __init__.py ├── conftest.py ├── test_js_constraint.py ├── test_js_constraint_component.py ├── test_js_constraint_path_component.py ├── test_js_function.py ├── test_js_rules.py ├── test_js_target.py └── test_js_target_type.py ├── test_manual_targeting.py ├── test_schema_org.py ├── test_sh_details.py ├── test_shacl_rules_runner.py └── test_sht_validate.py /.dockerignore: -------------------------------------------------------------------------------- 1 | /.venv 2 | /venv 3 | /.venv38 4 | /.venv39 5 | /.venv310 6 | /dist 7 | /htmlcov 8 | /build 9 | /_build 10 | /hooks 11 | /.idea 12 | /.git 13 | /.mypy_cache 14 | */.mypy_cache/ 15 | /.ruff_cache/ 16 | /.pytest_cache 17 | /.tox 18 | /__pycache__ 19 | */__pycache__ 20 | *.egg-info 21 | *.pyc 22 | .coverage 23 | *.png 24 | *.svg 25 | Dockerfile 26 | .dockerignore 27 | snyk-linux 28 | 29 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: 2 | # http://EditorConfig.org 3 | 4 | # top-most EditorConfig file 5 | root = true 6 | 7 | # Unix-style newlines with a newline ending every file 8 | [*] 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | # Leave line endings as-is in Markdown and ReStructuredText files 14 | [*.{md, rst}] 15 | charset = utf-8 16 | trim_trailing_whitespace = false 17 | 18 | # Matches multiple files with brace expansion notation 19 | # Set default charset 20 | [*.{js, py}] 21 | charset = utf-8 22 | 23 | # 4 space indentation 24 | [*.py] 25 | indent_style = space 26 | indent_size = 4 27 | max_line_length = 119 28 | 29 | # tab indentation 30 | [Makefile] 31 | indent_style = tab 32 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 119 3 | select = C,E,F,W,B,B950 4 | ignore = E501,W503,E203 5 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use PySHACL in a publication, please cite it as below." 3 | authors: 4 | - family-names: "Sommer" 5 | given-names: "Ashley" 6 | orcid: "https://orcid.org/0000-0003-0590-0131" 7 | - family-names: "Car" 8 | given-names: "Nicholas" 9 | orcid: "http://orcid.org/0000-0002-8742-7730" 10 | title: "pySHACL" 11 | version: 0.30.1 12 | doi: 10.5281/zenodo.4750840 13 | license: Apache-2.0 14 | date-released: 2025-03-15 15 | url: "https://github.com/RDFLib/pySHACL" 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | 3 | ### The PySHACL project encourages submissions from anyone who wishes to contribute 4 | 5 | There are some strict submission quality requirements: 6 | 7 | ## Code Format 8 | 9 | PySHACL uses the `black` code style. https://github.com/psf/black 10 | 11 | Specifically, we use v20.8b1 in `py36` mode, with line length of `119`, and `skip-string-normalization = true`. 12 | 13 | ## Code Linting 14 | 15 | PySHACL requires all code to pass the Flake8 linter. In the internal test suite, we use Flake8 v3.8.0. 16 | 17 | In addition to Flake8, we use `isort` to keep the import strings at the top of each source file in a consistent sorted order. The version if isort used is v5.7.0 and it is configured with the isort settings listed in the pyproject.toml file. 18 | 19 | ## Type Checking 20 | 21 | PySHACL uses MyPy to run static type analysis checks on the code. Not all parts of PySHACL have type annotations, but those parts that do should be annotated correctly to pass the MyPy test. 22 | 23 | The internal test suite uses MyPy v0.800. 24 | 25 | ## Testing 26 | 27 | The best way to comprehensively test PySHACL is to use [Tox](https://tox.readthedocs.io/en/latest/). 28 | 29 | It is a simple matter of running `pip3 install tox` then `tox` on the commandline in the project root. 30 | 31 | This will run a whole suite of tests, including pytest, flake8, mypy, black and isort. 32 | 33 | All tests in the PySHACL pytest test suite should pass without errors. 34 | 35 | ## Makefile 36 | 37 | There is also a Makefile in the project root that you can for covenience to kick off tests with `make test`, as well as some non-tox commands that can be invoked with `make format`, `make list` and `make type-check`. 38 | 39 | 40 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | **Ashley Sommer** 4 | * almost everything! 5 | 6 | **Nicholas Car** 7 | * a few small admin bits and pieces 8 | 9 | **Jonathan Yu** 10 | * pyinstaller spec for compiling pySHACL cli as a Windows binary 11 | 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/python:3.11-alpine 2 | LABEL org.opencontainers.image.base.name="docker.io/library/python:3.11-alpine" 3 | LABEL org.opencontainers.image.base.digest="sha256:d5e2fc72296647869f5eeb09e7741088a1841195059de842b05b94cb9d3771bb" 4 | LABEL org.opencontainers.image.source="https://github.com/RDFLib/pySHACL" 5 | LABEL org.opencontainers.image.version="0.30.1" 6 | LABEL maintainer="ashleysommer@gmail.com" 7 | RUN apk add --no-cache --update tini-static cython 8 | RUN apk add --no-cache --update --virtual build-dependencies build-base libffi-dev python3-dev py3-cffi 9 | # Update to latest setuptools and pip in /usr/local/lib to mitigate CVE-2024-6345 10 | RUN pip3 install -U pip setuptools 11 | WORKDIR /home/pyshacl 12 | RUN addgroup -g 1000 -S pyshacl &&\ 13 | adduser --disabled-password --gecos "" --home "$(pwd)" --ingroup "pyshacl" --no-create-home --uid 1000 pyshacl 14 | WORKDIR /app 15 | COPY . . 16 | RUN chown -R pyshacl:pyshacl /home/pyshacl /app && chmod -R 775 /home/pyshacl /app 17 | USER pyshacl 18 | ENV PATH="/home/pyshacl/.local/bin:$PATH" 19 | RUN pip3 install "poetry<3.0,>=2.1" 20 | RUN poetry install --extras "js http" 21 | RUN poetry run pip3 install -U "rdflib[orjson]<8" # add orjson support to rdflib 22 | USER root 23 | RUN apk del build-dependencies 24 | USER pyshacl 25 | ENTRYPOINT ["/sbin/tini-static", "--"] 26 | CMD ["poetry", "run", "pyshacl"] 27 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.txt *.md 2 | include pyproject.toml 3 | include poetry.lock 4 | include Makefile 5 | include MANIFEST.in 6 | include hooks/* 7 | include pyshacl/assets/*.pickle 8 | include pyshacl/*.spec 9 | include test/*.py 10 | include test/issues/*.py 11 | recursive-include test/resources *.ttl *.js 12 | recursive-include docs *.txt *.md 13 | -------------------------------------------------------------------------------- /benchmarks/benchmark.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import timeit 3 | 4 | # set up code is not included in the benchmark 5 | # this includes loading the SHACL file into a rdflib graph 6 | # this is a benchmark of the validator, not of rdflib ttl parsing. 7 | set_up_script = ''' 8 | import rdflib 9 | from pyshacl import monkey 10 | import pyshacl 11 | from os import path 12 | monkey.apply_patches() 13 | target_ttl_file = \ 14 | '../test/resources/dash_tests/core/complex/personexample.test.ttl' 15 | target_ttl_file = path.abspath(target_ttl_file) 16 | target_graph = rdflib.Graph("Memory") 17 | with open(target_ttl_file, 'rb') as file: 18 | target_graph.parse(file=file, format='turtle') 19 | ''' 20 | 21 | run_script_pre_none = ''' 22 | r = pyshacl.validate(target_graph, inference='none') 23 | ''' 24 | 25 | run_script_pre_rdfs = ''' 26 | r = pyshacl.validate(target_graph, inference='rdfs') 27 | ''' 28 | 29 | run_script_pre_owlrl = ''' 30 | r = pyshacl.validate(target_graph, inference='owlrl') 31 | ''' 32 | 33 | run_script_pre_both = ''' 34 | r = pyshacl.validate(target_graph, inference='both') 35 | ''' 36 | 37 | t1 = timeit.timeit(run_script_pre_none, set_up_script, number=200) / 200.0 38 | 39 | t2 = timeit.timeit(run_script_pre_rdfs, set_up_script, number=200) / 200.0 40 | 41 | t3 = timeit.timeit(run_script_pre_owlrl, set_up_script, number=200) / 200.0 42 | 43 | t4 = timeit.timeit(run_script_pre_both, set_up_script, number=200) / 200.0 44 | 45 | 46 | print("Benchmark completed. Validation took:\n" 47 | "With no inferencing: {} seconds\n" 48 | "With rdfs inferencing: {} seconds\n" 49 | "With owl-rl inferencing: {} seconds\n" 50 | "With both inferencing: {} seconds\n".format(t1, t2, t3, t4)) 51 | -------------------------------------------------------------------------------- /examples/example.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyshacl import validate 3 | from os import path 4 | 5 | data_ttl_file = \ 6 | '../test/resources/dash_tests/core/complex/personexample.test.ttl' 7 | data_ttl_file = path.abspath(data_ttl_file) 8 | 9 | conforms, v_graph, v_text = validate(data_ttl_file, shacl_graph=None, inference='rdfs', 10 | serialize_report_graph=True) 11 | print(conforms) 12 | print(v_graph) 13 | print(v_text) 14 | -------------------------------------------------------------------------------- /examples/remote_sparql.py: -------------------------------------------------------------------------------- 1 | from pyshacl import validate 2 | from rdflib import Dataset, Graph 3 | from rdflib.plugins.stores.sparqlstore import SPARQLStore 4 | 5 | # Remote sparql endpoint: 6 | my_sparql_endpoint = "https://my.service.com/repo/data/sparql" 7 | store = SPARQLStore(my_sparql_endpoint, auth=('username', 'password')) 8 | data_dataset = Dataset(store, default_union=True) 9 | 10 | # Shapes graph: 11 | shapes_graph = Graph().parse("my_shapes.ttl", format="turtle") 12 | 13 | # Validate: 14 | result_tuple = validate(data_dataset, shacl_graph=shapes_graph, sparql_mode=True) 15 | conforms, results_graph, results_text = result_tuple 16 | -------------------------------------------------------------------------------- /poetry.toml: -------------------------------------------------------------------------------- 1 | [virtualenvs] 2 | create = true 3 | in-project = true 4 | system-site-packages = false 5 | prefer-active-python = true 6 | -------------------------------------------------------------------------------- /pySHACL-250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pySHACL-250.png -------------------------------------------------------------------------------- /pySHACL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pySHACL.png -------------------------------------------------------------------------------- /pyshacl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: latin-1 -*- 2 | # 3 | from .entrypoints import shacl_rules, validate 4 | from .rule_expand_runner import RuleExpandRunner 5 | from .shape import Shape 6 | from .shapes_graph import ShapesGraph 7 | from .validator import Validator 8 | 9 | # version compliant with https://www.python.org/dev/peps/pep-0440/ 10 | __version__ = '0.30.1' 11 | # Don't forget to change the version number in pyproject.toml, Dockerfile, and CITATION.cff along with this one 12 | 13 | __all__ = ['validate', 'shacl_rules', 'Validator', 'RuleExpandRunner', '__version__', 'Shape', 'ShapesGraph'] 14 | -------------------------------------------------------------------------------- /pyshacl/__main__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: latin-1 -*- 2 | # 3 | import os 4 | import sys 5 | 6 | from pyshacl.cli import main as validate_main 7 | from pyshacl.cli_rules import main as rules_main 8 | 9 | 10 | def str_is_true(s_var: str): 11 | if len(s_var) > 0: 12 | if s_var.lower() not in ("0", "f", "n", "false", "no"): 13 | return True 14 | return False 15 | 16 | 17 | do_server = os.getenv("PYSHACL_HTTP", "") 18 | do_server = os.getenv("PYSHACL_SERVER", do_server) 19 | 20 | first_arg = None if len(sys.argv) < 2 else sys.argv[1] 21 | 22 | if first_arg is not None and str(first_arg).lower() in ('rules', '--rules'): 23 | rules_main(prog="python3 -m pyshacl") 24 | elif (first_arg is not None and str(first_arg).lower() in ('serve', 'server', '--server')) or ( 25 | do_server and str_is_true(do_server) 26 | ): 27 | from pyshacl.sh_http import main as http_main 28 | 29 | http_main() 30 | else: 31 | validate_main(prog="python3 -m pyshacl") 32 | -------------------------------------------------------------------------------- /pyshacl/assets/dash.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pyshacl/assets/dash.pickle -------------------------------------------------------------------------------- /pyshacl/assets/make_builtin.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | 3 | from rdflib import Graph, URIRef 4 | from rdflib.plugins.stores.memory import Memory 5 | 6 | from pyshacl.monkey import apply_patches 7 | 8 | apply_patches() 9 | identifier = URIRef("http://datashapes.org/schema") 10 | store = Memory(identifier=identifier) 11 | with open("./schema.ttl", "rb") as f: 12 | g = Graph(store=store, identifier=identifier, bind_namespaces='core').parse(file=f) 13 | with open("./schema.pickle", "wb") as f: 14 | pickle.dump((store, identifier), f, protocol=5) 15 | 16 | identifier = URIRef("http://www.w3.org/ns/shacl#") 17 | store = Memory(identifier=identifier) 18 | with open("./shacl.ttl", "rb") as f: 19 | g = Graph(store=store, identifier=identifier, bind_namespaces='core').parse(file=f) 20 | with open("./shacl.pickle", "wb") as f: 21 | pickle.dump((store, identifier), f, protocol=5) 22 | 23 | identifier = URIRef("http://datashapes.org/dash") 24 | store = Memory(identifier=identifier) 25 | with open("./dash.ttl", "rb") as f: 26 | g = Graph(store=store, identifier=identifier, bind_namespaces='core').parse(file=f) 27 | with open("./dash.pickle", "wb") as f: 28 | pickle.dump((store, identifier), f, protocol=5) 29 | 30 | identifier = URIRef("http://www.w3.org/ns/shacl-shacl#") 31 | store = Memory(identifier=identifier) 32 | with open("./shacl-shacl.ttl", "rb") as f: 33 | g = Graph(store=store, identifier=identifier, bind_namespaces='core').parse(file=f) 34 | with open("./shacl-shacl.pickle", "wb") as f: 35 | pickle.dump((store, identifier), f, protocol=5) 36 | -------------------------------------------------------------------------------- /pyshacl/assets/schema.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pyshacl/assets/schema.pickle -------------------------------------------------------------------------------- /pyshacl/assets/shacl-shacl.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pyshacl/assets/shacl-shacl.pickle -------------------------------------------------------------------------------- /pyshacl/assets/shacl.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/pyshacl/assets/shacl.pickle -------------------------------------------------------------------------------- /pyshacl/constraints/core/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /pyshacl/constraints/sparql/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /pyshacl/extras/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | import sys 4 | from functools import lru_cache 5 | from warnings import warn 6 | 7 | if sys.version_info[:2] < (3, 12): 8 | from importlib_metadata import PackageNotFoundError, metadata 9 | else: 10 | from importlib.metadata import PackageNotFoundError, metadata 11 | 12 | 13 | # In dev mode, the extras-loader doesn't check if extension is installed before loading it. 14 | # This is useful when testing, when we're working on a codebase of a library that is not yet installed. 15 | dev_mode = False 16 | 17 | 18 | extras_requirements = {"js": ["pyduktape2"], "http": ["sanic", "sanic-ext", "sanic-cors"]} 19 | 20 | 21 | @lru_cache() 22 | def check_extra_installed(extra_name: str): 23 | if dev_mode: 24 | return True 25 | # first check if pyshacl is installed using the normal means 26 | try: 27 | this_mdata = metadata('pyshacl') 28 | except PackageNotFoundError: 29 | # Hmm, it thinks pyshacl isn't installed. Can't even check for extras 30 | return None 31 | try: 32 | has_extras = this_mdata.json['provides_extra'] 33 | except LookupError: 34 | # Can't check metadata for extras for some reason? 35 | return None 36 | if extra_name not in has_extras: 37 | warn(Warning(f"Extra \"{extra_name}\" doesn't exist in this version of pyshacl.")) 38 | return False 39 | if extra_name not in extras_requirements: 40 | warn(Warning(f"Extra \"{extra_name}\" cannot be checked in this version of pyshacl.")) 41 | all_reqs = extras_requirements[extra_name] 42 | for req in all_reqs: 43 | try: 44 | _ = metadata(req) 45 | except PackageNotFoundError: 46 | warn(Warning(f"Extra \"{extra_name}\" is not satisfied because requirement {req} is not installed.")) 47 | return False 48 | return True 49 | -------------------------------------------------------------------------------- /pyshacl/extras/js/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | 4 | from .loader import load_into_context 5 | 6 | __all__ = ['load_into_context'] 7 | -------------------------------------------------------------------------------- /pyshacl/helper/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | mod = sys.modules[__name__] 4 | setattr(mod, 'SPARQLQueryHelperCls', None) 5 | 6 | 7 | def get_query_helper_cls(): 8 | # The SPARQLQueryHelper file is expensive to load due to regex compilation steps 9 | # so we do it this way so its only loaded when something actually needs to use 10 | # a SPARQLQueryHelper 11 | SPARQLQueryHelperCls = getattr(mod, 'SPARQLQueryHelperCls', None) 12 | if SPARQLQueryHelperCls is None: 13 | from .sparql_query_helper import SPARQLQueryHelper 14 | 15 | SPARQLQueryHelperCls = SPARQLQueryHelper 16 | setattr(mod, 'SPARQLQueryHelperCls', SPARQLQueryHelperCls) 17 | return SPARQLQueryHelperCls 18 | -------------------------------------------------------------------------------- /pyshacl/inference/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .custom_rdfs_closure import CustomRDFSOWLRLSemantics, CustomRDFSSemantics 3 | 4 | __all__ = ['CustomRDFSSemantics', 'CustomRDFSOWLRLSemantics'] 5 | -------------------------------------------------------------------------------- /pyshacl/py.typed: -------------------------------------------------------------------------------- 1 | partial 2 | -------------------------------------------------------------------------------- /pyshacl/pyshacl-cli.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | ## run `pyinstaller pyshacl-cli.spec` to create `dist/pyshacl.exe` dist 3 | ## note it requires pywin32 4 | 5 | block_cipher = None 6 | 7 | a = Analysis( 8 | ['cli.py'], 9 | pathex=['.'], 10 | binaries=[ 11 | ('assets/shacl.pickle','assets'), 12 | ('assets/shacl-shacl.pickle','assets') 13 | ], 14 | datas=[ 15 | ('assets/shacl.ttl','assets'), 16 | ('assets/shacl-shacl.ttl','assets') 17 | ], 18 | hiddenimports=[ 19 | 'rdflib.plugins', 20 | 'rdflib', 21 | 'urllib3', 22 | 'win32com.gen_py', 23 | 'pkg_resources.py2_warn' 24 | ], 25 | hookspath=[], 26 | runtime_hooks=[], 27 | excludes=[], 28 | win_no_prefer_redirects=False, 29 | win_private_assemblies=False, 30 | cipher=block_cipher, 31 | noarchive=False 32 | ) 33 | 34 | pyz = PYZ( 35 | a.pure, 36 | a.zipped_data, 37 | cipher=block_cipher 38 | ) 39 | 40 | exe = EXE( 41 | pyz, 42 | a.scripts, 43 | a.binaries, 44 | a.zipfiles, 45 | a.datas, 46 | [], 47 | name='pyshacl', 48 | debug=False, 49 | bootloader_ignore_signals=False, 50 | strip=False, 51 | upx=True, 52 | upx_exclude=[], 53 | runtime_tmpdir=None, 54 | console=True 55 | ) 56 | -------------------------------------------------------------------------------- /pyshacl/pytypes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | 4 | from dataclasses import dataclass 5 | from typing import List, Optional, Union 6 | 7 | from rdflib import ConjunctiveGraph, Dataset, Graph, Literal 8 | from rdflib.term import IdentifiedNode, URIRef 9 | 10 | ConjunctiveLike = Union[ConjunctiveGraph, Dataset] 11 | GraphLike = Union[ConjunctiveLike, Graph] 12 | RDFNode = Union[IdentifiedNode, Literal] 13 | 14 | 15 | @dataclass 16 | class SHACLExecutor: 17 | validator: Optional[object] = None 18 | advanced_mode: bool = False 19 | abort_on_first: bool = False 20 | allow_infos: bool = False 21 | allow_warnings: bool = False 22 | iterate_rules: bool = False 23 | debug: bool = False 24 | sparql_mode: bool = False 25 | max_validation_depth: int = 15 26 | focus_nodes: Optional[List[URIRef]] = None 27 | -------------------------------------------------------------------------------- /pyshacl/rdfutil/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """A collection of handy utility RDF functions, will one day be split out into its own installable module.""" 4 | 5 | from .clone import clone_blank_node, clone_graph, clone_literal, clone_node, mix_datasets, mix_graphs # noqa: F401 6 | from .compare import compare_blank_node, compare_literal, compare_node, order_graph_literal # noqa: F401 7 | from .inoculate import inoculate, inoculate_dataset # noqa: F401 8 | from .load import add_baked_in, get_rdf_from_web, load_from_source # noqa: F401 9 | from .stringify import stringify_blank_node, stringify_graph, stringify_literal, stringify_node # noqa: F401 10 | -------------------------------------------------------------------------------- /pyshacl/rdfutil/pytypes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | from typing import Union 4 | 5 | from rdflib import ConjunctiveGraph, Dataset, Graph 6 | 7 | ConjunctiveLike = Union[ConjunctiveGraph, Dataset] 8 | GraphLike = Union[ConjunctiveLike, Graph] 9 | -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | from .helpers import load_manifest, flatten_manifests, Manifest, SHTValidate 4 | -------------------------------------------------------------------------------- /test/issues/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | -------------------------------------------------------------------------------- /test/issues/test_009.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/9 5 | """ 6 | from pyshacl import validate 7 | 8 | shacl_file_text = """ 9 | @prefix owl: . 10 | @prefix rdf: . 11 | @prefix rdfs: . 12 | @prefix sh: . 13 | @prefix xsd: . 14 | @prefix ex: . 15 | 16 | ex:Parent a rdfs:Class ; 17 | rdfs:isDefinedBy ex: ; 18 | rdfs:comment "The parent class"@en ; 19 | rdfs:subClassOf owl:Thing . 20 | 21 | ex:ParentShape a sh:NodeShape ; 22 | rdfs:isDefinedBy ex: ; 23 | sh:property [ 24 | sh:datatype xsd:string ; 25 | sh:path ex:name ; 26 | sh:maxCount 1 ; 27 | sh:minCount 1 ; 28 | ] ; 29 | sh:closed true ; 30 | sh:ignoredProperties ( rdf:type ) ; 31 | sh:targetClass ex:Parent . 32 | """ 33 | 34 | data_file_text = """ 35 | { 36 | "@context": { 37 | "@vocab": "http://example.com/ex#" 38 | }, 39 | "@type": "Parent", 40 | "name": "Father", 41 | "dummy": "Dummy value" 42 | } 43 | """ 44 | 45 | 46 | def test_009(): 47 | res = validate( 48 | data_file_text, 49 | shacl_graph=shacl_file_text, 50 | data_graph_format='json-ld', 51 | shacl_graph_format='turtle', 52 | inference='both', 53 | debug=True, 54 | ) 55 | conforms, graph, string = res 56 | assert not conforms 57 | -------------------------------------------------------------------------------- /test/issues/test_012.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/12 5 | """ 6 | from pyshacl import validate 7 | 8 | shacl_file_text = """ 9 | @prefix hei: . 10 | @prefix rdf: . 11 | @prefix rdfs: . 12 | @prefix sh: . 13 | @prefix xml: . 14 | @prefix xsd: . 15 | 16 | hei:HeiAddressShape a sh:NodeShape ; 17 | sh:property [ rdfs:comment "Street constraint" ; 18 | sh:datatype xsd:string ; 19 | sh:minLength 30 ; 20 | sh:path hei:Ship_to_street ] ; 21 | sh:targetClass hei:Hei_customer . 22 | """ 23 | 24 | data_file_text = """ 25 | @prefix hei: . 26 | @prefix rdfs: . 27 | hei:hei_cust_1281 a hei:Hei_customer ; 28 | rdfs:label "XYZHorecagroothandel" ; 29 | hei:Klant_nummer 1281 ; 30 | hei:Ship_to_City "Middenmeer" ; 31 | hei:Ship_to_postcode "1799 AB" ; 32 | hei:Ship_to_street "Industrieweg" . 33 | """ 34 | 35 | 36 | def test_012_text(): 37 | res = validate( 38 | data_file_text, 39 | shacl_graph=shacl_file_text, 40 | data_graph_format='turtle', 41 | shacl_graph_format='turtle', 42 | inference='both', 43 | debug=True, 44 | ) 45 | conforms, graph, string = res 46 | assert not conforms 47 | 48 | 49 | def test_012_graph(): 50 | from rdflib import Graph 51 | 52 | g = Graph() 53 | g.parse(data=data_file_text, format='turtle') 54 | sg = Graph() 55 | sg.parse(data=shacl_file_text, format='turtle') 56 | res = validate(g, shacl_graph=sg, inference='both', debug=True) 57 | conforms, graph, string = res 58 | assert not conforms 59 | -------------------------------------------------------------------------------- /test/issues/test_029/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | from pyshacl import validate 4 | from pyshacl.rdfutil.load import load_from_source 5 | 6 | data_graph = load_from_source("./test/issues/test_029/simpleData.ttl") 7 | shacl_graph = load_from_source("./test/issues/test_029/simpleOnto.ttl") 8 | 9 | 10 | def test_029(): 11 | res = validate(data_graph, shacl_graph=shacl_graph, ont_graph=shacl_graph, inference='none', debug=True) 12 | conforms, graph, string = res 13 | assert not conforms 14 | 15 | 16 | if __name__ == "__main__": 17 | test_029() 18 | -------------------------------------------------------------------------------- /test/issues/test_029/simpleData.ttl: -------------------------------------------------------------------------------- 1 | @prefix metadata: . 2 | @prefix ex: . 3 | @prefix teamwork: . 4 | @prefix sh: . 5 | @prefix owl: . 6 | @prefix rdf: . 7 | @prefix xsd: . 8 | @prefix rdfs: . 9 | @prefix test: . 10 | 11 | test:FuncNode a ex:Func; 12 | ex:hasParameter test:FuncParam_b . 13 | 14 | test:FuncParam_a a ex:FuncParam_Func_a . 15 | test:FuncParam_b a ex:FuncParam_Func_b . 16 | 17 | -------------------------------------------------------------------------------- /test/issues/test_029/simpleOnto.ttl: -------------------------------------------------------------------------------- 1 | @prefix metadata: . 2 | @prefix ex: . 3 | @prefix teamwork: . 4 | @prefix sh: . 5 | @prefix owl: . 6 | @prefix rdf: . 7 | @prefix xsd: . 8 | @prefix rdfs: . 9 | 10 | ex:Function a owl:Class . 11 | 12 | ex:Func a owl:Class , sh:NodeShape ; 13 | rdfs:label "Func" ; 14 | rdfs:subClassOf ex:Function ; 15 | sh:property [ a sh:PropertyShape ; 16 | sh:class ex:FuncParam_Func_a ; 17 | sh:path ex:hasParameter ; 18 | sh:minCount 1; 19 | sh:name "Func_a" 20 | ] . 21 | 22 | ex:FuncParam_Func_a a owl:Class . 23 | ex:FuncParam_Func_b a owl:Class . 24 | -------------------------------------------------------------------------------- /test/issues/test_036.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/36 5 | """ 6 | from pyshacl import validate 7 | 8 | shacl_file_text = """\ 9 | { 10 | "@context": { 11 | "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 12 | "sh": "http://www.w3.org/ns/shacl#", 13 | "schema": "http://schema.org/" 14 | }, 15 | "@graph": [ 16 | { 17 | "@id": "_:forceDatasetShape", 18 | "@type": "sh:NodeShape", 19 | "sh:targetNode": "schema:DigitalDocument", 20 | "sh:property": [ 21 | { 22 | "sh:path": [ 23 | { 24 | "sh:inversePath": [{ 25 | "@id": "rdf:type", 26 | "@type": "@id" 27 | }] 28 | } 29 | ], 30 | "sh:minCount": 1 31 | } 32 | ] 33 | } 34 | ] 35 | } 36 | """ 37 | 38 | data_file_text_jsonld = """\ 39 | { 40 | 41 | } 42 | """ 43 | 44 | 45 | def test_036_jsonld(): 46 | res = validate( 47 | data_file_text_jsonld, 48 | shacl_graph=shacl_file_text, 49 | data_graph_format='json-ld', 50 | shacl_graph_format='json-ld', 51 | inference='rdfs', 52 | debug=True, 53 | ) 54 | conforms, graph, string = res 55 | assert not conforms 56 | 57 | 58 | if __name__ == "__main__": 59 | test_036_jsonld() 60 | -------------------------------------------------------------------------------- /test/issues/test_038.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/38 5 | 6 | I think this is duplicate of test test_029.py 7 | """ 8 | from rdflib import Graph 9 | from pyshacl import validate 10 | 11 | shapes = Graph() 12 | shapes.parse( 13 | data=""" 14 | @prefix sh: . 15 | @prefix owl: . 16 | @prefix ex: . 17 | 18 | ex:Person 19 | a owl:Class ; 20 | a sh:NodeShape ; 21 | sh:property ex:NameConstraint ; 22 | . 23 | 24 | ex:NameConstraint 25 | a sh:PropertyShape ; 26 | sh:path ex:name ; 27 | sh:minCount 1 ; 28 | . 29 | """, 30 | format="ttl", 31 | ) 32 | 33 | data = Graph() 34 | data.parse( 35 | data=""" 36 | @prefix ex: . 37 | 38 | ex:Bob 39 | a ex:Person ; 40 | . 41 | """, 42 | format="ttl", 43 | ) 44 | 45 | 46 | def test_038(): 47 | conforms, g, s = validate(data_graph=data, shacl_graph=shapes, inference='rdfs') 48 | assert not conforms 49 | 50 | 51 | if __name__ == "__main__": 52 | test_038() 53 | -------------------------------------------------------------------------------- /test/issues/test_040/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/40 5 | 6 | """ 7 | from pyshacl import validate 8 | from pyshacl.rdfutil import load_from_source 9 | 10 | 11 | with open("./test/issues/test_040/sample-network.ttl", "r") as f: 12 | data_graph = load_from_source(f) 13 | 14 | shacl_graph = load_from_source("./test/issues/test_040/03-Network.ttl") 15 | 16 | 17 | def test_040(): 18 | conforms, g, s = validate(data_graph=data_graph, shacl_graph=shacl_graph, ont_graph=shacl_graph, inference='rdfs') 19 | assert conforms 20 | 21 | 22 | if __name__ == "__main__": 23 | test_040() 24 | -------------------------------------------------------------------------------- /test/issues/test_040/sample-network.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | @prefix rdf: . 4 | @prefix bacnet: . 5 | @prefix xsd: . 6 | 7 | :a rdf:type bacnet:Network ; 8 | bacnet:hasNode :b, :c . 9 | 10 | :b rdf:type bacnet:Node ; 11 | bacnet:hasAddress 1 ; 12 | bacnet:layeredAbove :c . 13 | 14 | :c rdf:type bacnet:Node ; 15 | bacnet:hasAddress 2 ; 16 | bacnet:layeredBelow :b . 17 | 18 | :d rdf:type bacnet:EthernetNode ; 19 | bacnet:hasAddress "01:02:03:04:05:06" . 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/issues/test_058.py: -------------------------------------------------------------------------------- 1 | import rdflib 2 | from pyshacl import validate 3 | from pyshacl.errors import ConstraintLoadError 4 | 5 | """ 6 | https://github.com/RDFLib/pySHACL/issues/58 7 | """ 8 | data = """ 9 | @prefix asdf: . 10 | @prefix ex: . 11 | 12 | asdf:e2e a ex:termA ; 13 | ex:child asdf:23e . 14 | 15 | asdf:23e a ex:termB . 16 | """ 17 | 18 | shaclData = """ 19 | @prefix ex: . 20 | @prefix rdf: . 21 | @prefix sh: . 22 | 23 | ex:termShape a sh:NodeShape ; 24 | sh:ignoredProperties ( rdf:type ) ; 25 | sh:targetClass ex:termB . 26 | """ 27 | 28 | 29 | def test_058(): 30 | dataGraph = rdflib.Graph().parse(data=data, format='ttl') 31 | shaclGraph = rdflib.Graph().parse(data=shaclData, format='ttl') 32 | exc = None 33 | try: 34 | conforms, g, s = validate( 35 | dataGraph, shacl_graph=shaclGraph, abort_on_first=False, meta_shacl=False, debug=False, advanced=True 36 | ) 37 | except Exception as e: 38 | assert isinstance(e, ConstraintLoadError) 39 | exc = e 40 | assert exc is not None 41 | assert "ignoredProperties" in str(exc) 42 | 43 | 44 | if __name__ == "__main__": 45 | test_058() 46 | -------------------------------------------------------------------------------- /test/issues/test_079.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/79 5 | """ 6 | import rdflib 7 | import pyshacl 8 | 9 | shapes_data = """\ 10 | @prefix ex: . 11 | @prefix sh: . 12 | @prefix owl: . 13 | @prefix rdf: . 14 | 15 | ex:AAA a owl:Class. 16 | ex:BBB a owl:Class. 17 | ex:CCC a owl:Class. 18 | 19 | ex:Shape a sh:NodeShape ; 20 | sh:targetClass ex:AAA; 21 | sh:not [ 22 | sh:or ( 23 | [sh:class ex:BBB] 24 | [sh:class ex:CCC] 25 | ) 26 | ]. 27 | """ 28 | 29 | 30 | def test_079(): 31 | shape_g = rdflib.Graph().parse(data=shapes_data, format='turtle') 32 | data_g = rdflib.Graph().parse( 33 | data=""" 34 | @prefix ex: . 35 | 36 | ex:aaa a ex:AAA. 37 | ex:aaa a ex:BBB. 38 | ex:aaa a ex:CCC. 39 | """, 40 | format='turtle', 41 | ) 42 | 43 | conforms, results_graph, results_text = pyshacl.validate( 44 | data_g, 45 | shacl_graph=shape_g, 46 | debug=True, 47 | ) 48 | assert not conforms 49 | 50 | 51 | if __name__ == "__main__": 52 | exit(test_079()) 53 | -------------------------------------------------------------------------------- /test/issues/test_087.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/87 5 | """ 6 | from pyshacl import validate 7 | 8 | mixed_file_text = """ 9 | @prefix sh: . 10 | @prefix rdf: . 11 | @prefix owl: . 12 | @prefix rdfs: . 13 | @prefix : . 14 | 15 | :TargetClass a owl:Class . 16 | 17 | :Class0 a owl:Class . 18 | 19 | :Class1 a owl:Class ; 20 | rdfs:subClassOf :Class0 . 21 | 22 | :Class2 a owl:Class ; 23 | rdfs:subClassOf :Class1 . 24 | 25 | :Class3 a owl:Class ; 26 | rdfs:subClassOf :Class2 . 27 | 28 | :prop a owl:ObjectProperty . 29 | 30 | :shape a sh:NodeShape ; 31 | sh:targetClass :TargetClass ; 32 | sh:property :haspointshape . 33 | 34 | :haspointshape a sh:PropertyShape ; 35 | sh:path :prop ; 36 | sh:class :Class0 . 37 | 38 | :s0 a :Class0 . 39 | :vav0 a :TargetClass ; 40 | :prop :s0 . 41 | 42 | :s1 a :Class1 . 43 | :vav1 a :TargetClass ; 44 | :prop :s1 . 45 | 46 | :s2 a :Class2 . 47 | :vav2 a :TargetClass ; 48 | :prop :s2 . 49 | 50 | :s3 a :Class3 . 51 | :vav3 a :TargetClass ; 52 | :prop :s3 . 53 | """ 54 | 55 | 56 | def test_087(): 57 | res1 = validate(mixed_file_text, data_graph_format='turtle', shacl_graph_format='turtle', debug=True) 58 | conforms, graph, string = res1 59 | assert conforms 60 | -------------------------------------------------------------------------------- /test/issues/test_108.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/108 5 | """ 6 | from pyshacl import validate 7 | 8 | # from DASH 9 | shacl_file_text = """ 10 | @prefix dash: . 11 | @prefix rdfs: . 12 | @prefix sh: . 13 | @prefix xsd: . 14 | 15 | dash:toString a sh:JSFunction, 16 | sh:SPARQLFunction ; 17 | rdfs:label "to string" ; 18 | dash:cachable true ; 19 | rdfs:comment "Returns a literal with datatype xsd:string that has the input value as its string. If the input value is an (URI) resource then its URI will be used." ; 20 | sh:jsFunctionName "dash_toString" ; 21 | sh:jsLibrary dash:DASHJSLibrary ; 22 | sh:labelTemplate "Convert {$arg} to xsd:string" ; 23 | sh:parameter [ a sh:Parameter ; 24 | sh:description "The input value." ; 25 | sh:name "arg" ; 26 | sh:nodeKind sh:IRIOrLiteral ; 27 | sh:path dash:arg ] ; 28 | sh:prefixes ; 29 | sh:returnType xsd:string ; 30 | sh:select "SELECT (xsd:string($arg) AS ?result) WHERE { }" . 31 | """ 32 | 33 | 34 | def test_108(): 35 | res = validate(shacl_file_text, advanced=True, js=True) 36 | conforms, graph, string = res 37 | assert conforms 38 | -------------------------------------------------------------------------------- /test/issues/test_142.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | https://github.com/RDFLib/pySHACL/issues/142 4 | """ 5 | 6 | import rdflib 7 | 8 | from pyshacl import validate 9 | 10 | 11 | shacl_file = """\ 12 | @prefix owl: . 13 | @prefix rdf: . 14 | @prefix rdfs: . 15 | @prefix sh: . 16 | @prefix ex: . 17 | 18 | ex:PersonShape 19 | a sh:NodeShape ; 20 | sh:targetClass ex:Person ; 21 | sh:property [ 22 | sh:path ex:hasPet ; 23 | sh:class ex:Animal ; 24 | sh:minCount 1 ; 25 | sh:maxCount 1 ; 26 | ] ; 27 | . 28 | """ 29 | ont_file = """\ 30 | @prefix owl: . 31 | @prefix rdf: . 32 | @prefix rdfs: . 33 | @prefix ex: . 34 | 35 | ex:Person a owl:Class . 36 | ex:Animal a owl:Class . 37 | ex:Dog a owl:Class ; rdfs:subClassOf ex:Animal . 38 | """ 39 | 40 | data_file = """\ 41 | @prefix ex: . 42 | ex:Brutus a ex:Dog . 43 | ex:Jane a ex:Person ; ex:hasPet ex:Brutus . 44 | """ 45 | 46 | 47 | def test_142() -> None: 48 | data = rdflib.Graph() 49 | data.parse(data=data_file, format="turtle") 50 | shapes = rdflib.Graph() 51 | shapes.parse(data=shacl_file, format="turtle") 52 | ont = rdflib.Graph() 53 | ont.parse(data=ont_file, format="turtle") 54 | res = validate(data, shacl_graph=shapes, ont_graph=ont) 55 | 56 | conforms, graph, string = res 57 | print(string) 58 | 59 | 60 | if __name__ == "__main__": 61 | test_142() 62 | -------------------------------------------------------------------------------- /test/issues/test_146.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | https://github.com/RDFLib/pySHACL/issues/146 4 | """ 5 | 6 | import warnings 7 | 8 | 9 | def test_146() -> None: 10 | # Ensure that importing pyshacl triggers no warnings. 11 | with warnings.catch_warnings(record=True) as warning_context: 12 | # Cause all warnings to always be triggered. 13 | warnings.simplefilter("always") 14 | # Import pyshacl, which should not trigger any warnings 15 | import pyshacl 16 | 17 | # Verify some things 18 | assert len(warning_context) == 0 19 | 20 | 21 | if __name__ == "__main__": 22 | test_146() 23 | -------------------------------------------------------------------------------- /test/issues/test_148.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | https://github.com/RDFLib/pySHACL/issues/148 4 | """ 5 | 6 | import rdflib 7 | 8 | from pyshacl import validate 9 | 10 | 11 | shacl_file = """\ 12 | @prefix ex: . 13 | @prefix sh: . 14 | @prefix owl: . 15 | @prefix rdf: . 16 | @prefix rdfs: . 17 | 18 | ex:Class a owl:Class . 19 | ex:FailedRule a sh:NodeShape ; 20 | sh:targetClass ex:Class ; 21 | sh:rule [ 22 | a sh:TripleRule ; 23 | sh:object ex:Inferred ; 24 | sh:predicate ex:hasProperty ; 25 | sh:subject sh:this ; 26 | ] . 27 | """ 28 | ont_file = """\ 29 | @prefix ex: . 30 | @prefix owl: . 31 | @prefix rdf: . 32 | @prefix rdfs: . 33 | 34 | ex:Class a owl:Class . 35 | ex:SubClass a owl:Class ; 36 | rdfs:subClassOf ex:Class . 37 | ex:SubSubClass a owl:Class ; 38 | rdfs:subClassOf ex:SubClass . 39 | 40 | """ 41 | 42 | data_file = """\ 43 | @prefix ex: . 44 | @prefix rdf: . 45 | 46 | ex:A a ex:SubSubClass . 47 | """ 48 | 49 | 50 | def test_148() -> None: 51 | data_g = rdflib.Graph() 52 | data_g.parse(data=data_file, format="turtle").parse(data=ont_file) 53 | shapes = rdflib.Graph() 54 | shapes.parse(data=shacl_file, format="turtle") 55 | res = validate(data_g, shacl_graph=shapes, advanced=True) 56 | assert ( 57 | rdflib.URIRef("urn:ex#A"), 58 | rdflib.URIRef("urn:ex#hasProperty"), 59 | rdflib.URIRef("urn:ex#Inferred"), 60 | ) not in data_g 61 | 62 | conforms, graph, string = res 63 | assert conforms 64 | 65 | 66 | if __name__ == "__main__": 67 | test_148() 68 | -------------------------------------------------------------------------------- /test/issues/test_199.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/199 5 | """ 6 | import rdflib 7 | from rdflib.namespace import SH 8 | import pyshacl 9 | 10 | 11 | shapes_data = '''\ 12 | @prefix ex: . 13 | @prefix sh: . 14 | @prefix owl: . 15 | @prefix rdf: . 16 | 17 | 18 | ex:TestConstraintComponent 19 | a sh:ConstraintComponent ; 20 | sh:parameter [ 21 | sh:path ex:theValue ; 22 | ] ; 23 | sh:validator [ 24 | a sh:SPARQLAskValidator ; 25 | sh:message "{$this}: {$theValue}" ; 26 | sh:ask """ 27 | ASK { 28 | FILTER ($this != $this) # Always create a validation report for this constraint component 29 | }""" ; 30 | ] . 31 | 32 | ex:TestClass1 33 | a owl:Class ; 34 | a sh:NodeShape ; 35 | ex:theValue "Literal" . 36 | ex:TestClass2 37 | a owl:Class ; 38 | a sh:NodeShape ; 39 | ex:theValue ex:SomeURI . 40 | ex:TestClass3 41 | a owl:Class ; 42 | a sh:NodeShape ; 43 | ex:theValue _:bnode . 44 | ''' 45 | 46 | 47 | def test_199(): 48 | shape_g = rdflib.Graph().parse(data=shapes_data, format='turtle') 49 | data_g = rdflib.Graph().parse( 50 | data=""" 51 | @prefix ex: . 52 | @prefix sh: . 53 | 54 | ex:A a ex:TestClass1 . 55 | ex:B a ex:TestClass2 . 56 | ex:C a ex:TestClass3 . 57 | """, 58 | format='turtle', 59 | ) 60 | 61 | conforms, results_graph, results_text = pyshacl.validate( 62 | data_g, 63 | shacl_graph=shape_g, 64 | debug=True, 65 | ) 66 | assert not conforms 67 | assert len(list(results_graph[: SH.result])) == 3 68 | 69 | 70 | if __name__ == "__main__": 71 | exit(test_199()) 72 | -------------------------------------------------------------------------------- /test/issues/test_213.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/213 5 | """ 6 | import rdflib 7 | import pyshacl 8 | 9 | shapes_data = '''\ 10 | @prefix ex: . 11 | @prefix rdfs: . 12 | @prefix sh: . 13 | 14 | ex:MyShape 15 | a sh:NodeShape ; 16 | sh:targetClass ex:MyFirstClass ; 17 | sh:property [ 18 | rdfs:comment "This triggers as expected."@en ; 19 | sh:path ex:myProperty ; 20 | sh:minCount 1 ; 21 | ] ; 22 | sh:property [ 23 | rdfs:comment "This does should also trigger, even when there are no myProperty values on path."@en ; 24 | sh:path ex:myProperty ; 25 | sh:qualifiedValueShape [ 26 | sh:class ex:MySecondClass 27 | ] ; 28 | sh:qualifiedMinCount 1 ; 29 | ] 30 | . 31 | ''' 32 | 33 | data_g_text = '''\ 34 | @prefix ex: . 35 | @prefix kb: . 36 | 37 | kb:MyFirstClass-instance-not-ok 38 | a ex:MyFirstClass ; 39 | . 40 | 41 | kb:MyFirstClass-instance-ok 42 | a ex:MyFirstClass ; 43 | ex:myProperty [ 44 | a ex:MySecondClass ; 45 | ] ; 46 | . 47 | ''' 48 | 49 | 50 | def test_213(): 51 | shape_g = rdflib.Graph().parse(data=shapes_data, format='turtle') 52 | data_g = rdflib.Graph().parse(data=data_g_text, format="turtle") 53 | conforms, results_graph, results_text = pyshacl.validate( 54 | data_g, 55 | shacl_graph=shape_g, 56 | debug=True, 57 | meta_shacl=False, 58 | ) 59 | assert not conforms 60 | assert "QualifiedValueShapeConstraintComponent" in results_text 61 | 62 | 63 | if __name__ == "__main__": 64 | exit(test_213()) 65 | -------------------------------------------------------------------------------- /test/issues/test_220/LICENSE.md: -------------------------------------------------------------------------------- 1 | # NIST Software Licensing Statement 2 | 3 | NIST-developed software is provided by NIST as a public service. 4 | You may use, copy, and distribute copies of the software in any 5 | medium, provided that you keep intact this entire notice. You may 6 | improve, modify, and create derivative works of the software or 7 | any portion of the software, and you may copy and distribute such 8 | modifications or works. Modified works should carry a notice 9 | stating that you changed the software and should note the date 10 | and nature of any such change. Please explicitly acknowledge the 11 | National Institute of Standards and Technology as the source of 12 | the software. 13 | 14 | NIST-developed software is expressly provided "AS IS." NIST MAKES 15 | NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY 16 | OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 17 | WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 18 | NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR 19 | WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED 20 | OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES 21 | NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE 22 | SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE 23 | CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE 24 | SOFTWARE. 25 | 26 | You are solely responsible for determining the appropriateness of 27 | using and distributing the software and you assume all risks 28 | associated with its use, including but not limited to the risks 29 | and costs of program errors, compliance with applicable laws, 30 | damage to or loss of data, programs or equipment, and the 31 | unavailability or interruption of operation. This software is not 32 | intended to be used in any situation where a failure could cause 33 | risk of injury or damage to property. The software developed by 34 | NIST employees is not subject to copyright protection within the 35 | United States. 36 | -------------------------------------------------------------------------------- /test/issues/test_220/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/220 5 | 6 | """ 7 | from pyshacl import validate 8 | from pyshacl.rdfutil import load_from_source 9 | 10 | data_graph1 = load_from_source("./test/issues/test_220/kb-REPRODUCTION-1.ttl") 11 | shacl_graph1 = load_from_source("./test/issues/test_220/sh-REPRODUCTION-1.ttl") 12 | data_graph2 = load_from_source("./test/issues/test_220/kb-REPRODUCTION-2.ttl") 13 | shacl_graph2 = load_from_source("./test/issues/test_220/sh-REPRODUCTION-2.ttl") 14 | ont_graph = load_from_source("./test/issues/test_220/owl-REPRODUCTION.ttl") 15 | 16 | 17 | def test_220_1(): 18 | conforms, g, s = validate(data_graph=data_graph1, shacl_graph=shacl_graph1, ont_graph=ont_graph, inference='none') 19 | assert conforms 20 | 21 | 22 | def test_220_2(): 23 | conforms, g, s = validate(data_graph=data_graph2, shacl_graph=shacl_graph2, ont_graph=ont_graph, inference='none') 24 | assert not conforms 25 | assert "Results (2)" in s 26 | 27 | 28 | if __name__ == "__main__": 29 | test_220_1() 30 | test_220_2() 31 | -------------------------------------------------------------------------------- /test/issues/test_220/kb-REPRODUCTION-1.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix kb: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix xsd: . 7 | 8 | kb:thing-PASS-2 9 | a 10 | ex:ThingC , 11 | ex:ThingE 12 | ; 13 | rdfs:comment "This should raise no validation results."@en ; 14 | . 15 | -------------------------------------------------------------------------------- /test/issues/test_220/kb-REPRODUCTION-2.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix kb: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix xsd: . 7 | 8 | kb:thing-PASS-1 9 | a ex:ThingA ; 10 | rdfs:comment "This should raise no validation results."@en ; 11 | . 12 | 13 | kb:thing-PASS-2 14 | a 15 | ex:ThingC , 16 | ex:ThingE 17 | ; 18 | rdfs:comment "This should raise no validation results."@en ; 19 | . 20 | 21 | kb:thing-XFAIL-1 22 | a ex:OneXorThing ; 23 | rdfs:comment "This should raise a validation result, due to not being more specifically a ThingA or ThingB as the SHACL requires when reviewing the OWL disjoint union definition of OneXorThing."@en ; 24 | . 25 | 26 | kb:thing-XFAIL-2 27 | a ex:ThingC ; 28 | rdfs:comment "This should raise a validation result, due to not being a ThingE or ThingF as the SHACL requires when reviewing the entailed superclass TwoXorThing."@en ; 29 | . 30 | -------------------------------------------------------------------------------- /test/issues/test_220/owl-REPRODUCTION.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix xsd: . 6 | 7 | ex:OneXorThing 8 | a owl:Class ; 9 | owl:disjointUnionOf ( 10 | ex:ThingA 11 | ex:ThingB 12 | ) ; 13 | . 14 | 15 | ex:ThingA 16 | a owl:Class ; 17 | rdfs:subClassOf ex:OneXorThing ; 18 | owl:disjointWith ex:ThingB ; 19 | . 20 | 21 | ex:ThingB 22 | a owl:Class ; 23 | rdfs:subClassOf ex:OneXorThing ; 24 | owl:disjointWith ex:ThingA ; 25 | . 26 | 27 | ex:ThingC 28 | a owl:Class ; 29 | rdfs:subClassOf ex:TwoXorThing ; 30 | owl:disjointWith ex:ThingD ; 31 | . 32 | 33 | ex:ThingD 34 | a owl:Class ; 35 | rdfs:subClassOf ex:TwoXorThing ; 36 | owl:disjointWith ex:ThingC ; 37 | . 38 | 39 | ex:ThingE 40 | a owl:Class ; 41 | rdfs:subClassOf ex:TwoXorThing ; 42 | owl:disjointWith ex:ThingF ; 43 | . 44 | 45 | ex:ThingF 46 | a owl:Class ; 47 | rdfs:subClassOf ex:TwoXorThing ; 48 | owl:disjointWith ex:ThingE ; 49 | . 50 | 51 | ex:TwoXorThing 52 | a owl:Class ; 53 | owl:disjointUnionOf 54 | ( 55 | ex:ThingC 56 | ex:ThingD 57 | ) , 58 | ( 59 | ex:ThingE 60 | ex:ThingF 61 | ) 62 | ; 63 | . 64 | -------------------------------------------------------------------------------- /test/issues/test_220/sh-REPRODUCTION-1.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix sh: . 3 | @prefix sh-ex: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix xsd: . 8 | 9 | sh-ex:TwoXorThing-shape 10 | a sh:NodeShape ; 11 | sh:targetClass ex:TwoXorThing ; 12 | sh:xone 13 | ( 14 | [ 15 | a sh:NodeShape ; 16 | sh:class ex:ThingC ; 17 | ] 18 | [ 19 | a sh:NodeShape ; 20 | sh:class ex:ThingD ; 21 | ] 22 | ) , 23 | ( 24 | [ 25 | a sh:NodeShape ; 26 | sh:class ex:ThingE ; 27 | ] 28 | [ 29 | a sh:NodeShape ; 30 | sh:class ex:ThingF ; 31 | ] 32 | ) 33 | ; 34 | . 35 | -------------------------------------------------------------------------------- /test/issues/test_220/sh-REPRODUCTION-2.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix sh: . 3 | @prefix sh-ex: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix xsd: . 8 | 9 | sh-ex:OneXorThing-shape 10 | a sh:NodeShape ; 11 | sh:targetClass ex:OneXorThing ; 12 | sh:xone ( 13 | [ 14 | a sh:NodeShape ; 15 | sh:class ex:ThingA ; 16 | ] 17 | [ 18 | a sh:NodeShape ; 19 | sh:class ex:ThingB ; 20 | ] 21 | ) ; 22 | . 23 | 24 | sh-ex:TwoXorThing-shape 25 | a sh:NodeShape ; 26 | sh:targetClass ex:TwoXorThing ; 27 | sh:xone 28 | ( 29 | [ 30 | a sh:NodeShape ; 31 | sh:class ex:ThingC ; 32 | ] 33 | [ 34 | a sh:NodeShape ; 35 | sh:class ex:ThingD ; 36 | ] 37 | ) , 38 | ( 39 | [ 40 | a sh:NodeShape ; 41 | sh:class ex:ThingE ; 42 | ] 43 | [ 44 | a sh:NodeShape ; 45 | sh:class ex:ThingF ; 46 | ] 47 | ) 48 | ; 49 | . 50 | -------------------------------------------------------------------------------- /test/issues/test_281/data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix schema: . 3 | 4 | ex:exampleSoftware a schema:SoftwareSourceCode ; 5 | schema:codeRepository "https://gitea.example.com/example/example-software.git"^^schema:URL ; 6 | . 7 | -------------------------------------------------------------------------------- /test/issues/test_281/policies.ttl: -------------------------------------------------------------------------------- 1 | @prefix owl: . 2 | @prefix rdf: . 3 | 4 | <> owl:imports . 5 | -------------------------------------------------------------------------------- /test/issues/test_281/policies/gitlab-policy.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix schema: . 3 | @prefix sh: . 4 | 5 | ex:hostingOnGitLabRequired a sh:NodeShape ; 6 | sh:targetClass schema:SoftwareSourceCode ; 7 | 8 | sh:property [ 9 | sh:name "Hosted on Example GitLab" ; 10 | sh:description "Example GitLab must be used to host the repository." ; 11 | 12 | sh:path schema:codeRepository ; 13 | sh:datatype schema:URL ; 14 | sh:pattern "^https://gitlab.example.com/.*" ; 15 | sh:minCount 1 ; 16 | ] ; 17 | 18 | . 19 | -------------------------------------------------------------------------------- /test/issues/test_281/test_281.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/281 5 | """ 6 | import sys 7 | 8 | import rdflib 9 | 10 | import pyshacl 11 | 12 | # Tests are always run from project root, even nested issues tests. 13 | BASE_DIR = "./test/issues/test_281" 14 | 15 | def test_281_a(): 16 | conforms, results_graph, results_text = pyshacl.validate( 17 | f"file:{BASE_DIR}/data.ttl", 18 | shacl_graph=f"file:{BASE_DIR}/policies.ttl", 19 | debug=True, 20 | inference='none', 21 | advanced=False, 22 | meta_shacl=False, 23 | do_owl_imports=True, 24 | ) 25 | assert not conforms 26 | 27 | def test_281_b(): 28 | from pyshacl.rdfutil.load import load_from_source 29 | with open(f"{BASE_DIR}/data.ttl") as data_f: 30 | data_g = load_from_source(data_f, rdf_format="turtle", do_owl_imports=False) 31 | with open(f"{BASE_DIR}/policies.ttl") as policy_f: 32 | policy_g = load_from_source(policy_f, rdf_format="turtle", do_owl_imports=True) 33 | 34 | conforms, results_graph, results_text = pyshacl.validate( 35 | data_g, 36 | shacl_graph=policy_g, 37 | debug=True, 38 | inference='none', 39 | advanced=False, 40 | meta_shacl=False, 41 | do_owl_imports=True, 42 | ) 43 | assert not conforms 44 | 45 | 46 | if __name__ == "__main__": 47 | test_281_a() 48 | sys.exit(test_281_b()) 49 | -------------------------------------------------------------------------------- /test/issues/test_96.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | """ 4 | https://github.com/RDFLib/pySHACL/issues/96 5 | """ 6 | from pyshacl import validate 7 | 8 | mixed_file_text = """ 9 | @prefix sh: . 10 | @prefix rdf: . 11 | @prefix owl: . 12 | @prefix rdfs: . 13 | @prefix : . 14 | 15 | :Class0 a owl:Class . 16 | 17 | :Class1 a owl:Class ; 18 | rdfs:subClassOf :Class0 . 19 | 20 | :Class2 a owl:Class ; 21 | rdfs:subClassOf :Class1 . 22 | 23 | :Class3 a owl:Class ; 24 | rdfs:subClassOf :Class2 . 25 | 26 | :prop a owl:DatatypeProperty . 27 | 28 | :shape a sh:NodeShape ; 29 | sh:targetClass :Class0 ; 30 | sh:property [ 31 | sh:path :prop ; 32 | sh:hasValue "test" ; 33 | sh:minCount 1 ; 34 | ] . 35 | 36 | :s2 a :Class2 ; 37 | :prop "fail" . 38 | 39 | :s3 a :Class3 ; 40 | :prop "fail" . 41 | """ 42 | 43 | 44 | def test_96(): 45 | res1 = validate(mixed_file_text, data_graph_format='turtle', shacl_graph_format='turtle', debug=True) 46 | conforms, _, _ = res1 47 | assert not conforms 48 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/d1.jsonld: -------------------------------------------------------------------------------- 1 | { 2 | "@context": { 3 | "ex": "http://example.com/ex#", 4 | "exOnt": "http://example.com/exOnt#", 5 | "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 6 | "rdfs": "http://www.w3.org/2000/01/rdf-schema#", 7 | "xsd": "http://www.w3.org/2001/XMLSchema#" 8 | }, 9 | "@graph": [ 10 | { 11 | "@id": "ex:Pet1", 12 | "@type": "exOnt:Lizard", 13 | "exOnt:nLegs": 4, 14 | "rdf:label": "Sebastian" 15 | }, 16 | { 17 | "@id": "ex:Human1", 18 | "@type": "exOnt:Human", 19 | "exOnt:hasPet": { 20 | "@id": "ex:Pet1" 21 | }, 22 | "exOnt:nLegs": 2, 23 | "rdf:label": "Amy" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/d1.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix xsd: . 3 | @prefix exOnt: . 4 | @prefix ex: . 5 | 6 | ex:Human1 rdf:type exOnt:Human ; 7 | rdf:label "Amy" ; 8 | exOnt:nLegs "2"^^xsd:integer ; 9 | exOnt:hasPet ex:Pet1 . 10 | 11 | ex:Pet1 rdf:type exOnt:Lizard ; 12 | rdf:label "Sebastian" ; 13 | exOnt:nLegs "4"^^xsd:integer . 14 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/d2.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix xsd: . 3 | @prefix exOnt: . 4 | @prefix ex: . 5 | 6 | ex:Human1 rdf:type exOnt:Human ; 7 | rdf:label "Amy" ; 8 | exOnt:nLegs "2"^^xsd:integer ; 9 | exOnt:hasPet "Sebastian"^^xsd:string . 10 | 11 | ex:Pet1 rdf:type exOnt:Lizard ; 12 | rdf:label "Sebastian" ; 13 | exOnt:nLegs "g"^^xsd:string . 14 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/o1.ttl: -------------------------------------------------------------------------------- 1 | @prefix owl: . 2 | @prefix rdf: . 3 | @prefix rdfs: . 4 | @prefix xsd: . 5 | @prefix exOnt: . 6 | 7 | a owl:Ontology ; 8 | rdfs:label "An example extra-ontology file."@en . 9 | 10 | exOnt:Animal a rdfs:Class ; 11 | rdfs:comment "The parent class for Humans and Pets"@en ; 12 | rdfs:subClassOf owl:Thing . 13 | 14 | exOnt:Human a rdfs:Class ; 15 | rdfs:comment "A Human being"@en ; 16 | rdfs:subClassOf exOnt:Animal . 17 | 18 | exOnt:Pet a rdfs:Class ; 19 | rdfs:comment "An animal owned by a human"@en ; 20 | rdfs:subClassOf exOnt:Animal . 21 | 22 | exOnt:hasPet a rdf:Property ; 23 | rdfs:domain exOnt:Human ; 24 | rdfs:range exOnt:Pet . 25 | 26 | exOnt:nLegs a rdf:Property ; 27 | rdfs:domain exOnt:Animal ; 28 | rdfs:range exOnt:integer . 29 | 30 | exOnt:Lizard a rdfs:Class ; 31 | rdfs:subClassOf exOnt:Pet . 32 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/rules_d.ttl: -------------------------------------------------------------------------------- 1 | # prefix: ex 2 | 3 | @prefix ex: . 4 | @prefix exOnt: . 5 | @prefix owl: . 6 | @prefix rdf: . 7 | @prefix rdfs: . 8 | @prefix xsd: . 9 | 10 | ex:Kate 11 | rdf:type exOnt:Person ; 12 | exOnt:firstName "Kate" ; 13 | exOnt:lastName "Jones" ; 14 | . 15 | 16 | ex:Jenny 17 | rdf:type exOnt:Administrator ; 18 | exOnt:firstName "Jennifer" ; 19 | exOnt:lastName "Wolfeschlegelsteinhausenbergerdorff" ; 20 | . 21 | -------------------------------------------------------------------------------- /test/resources/cmdline_tests/s1.ttl: -------------------------------------------------------------------------------- 1 | @prefix owl: . 2 | @prefix rdf: . 3 | @prefix rdfs: . 4 | @prefix sh: . 5 | @prefix xsd: . 6 | @prefix exShape: . 7 | @prefix exOnt: . 8 | 9 | a owl:Ontology ; 10 | rdfs:label "Example Shapes File"@en . 11 | 12 | exShape:HumanShape a sh:NodeShape ; 13 | sh:property [ 14 | sh:class exOnt:Pet ; 15 | sh:path exOnt:hasPet ; 16 | ] ; 17 | sh:property [ 18 | sh:datatype xsd:integer ; 19 | sh:path exOnt:nLegs ; 20 | sh:maxInclusive 2 ; 21 | sh:minInclusive 2 ; 22 | ] ; 23 | sh:targetClass exOnt:Human . 24 | 25 | exShape:AnimalShape a sh:NodeShape ; 26 | sh:property [ 27 | sh:datatype xsd:integer ; 28 | sh:path exOnt:nLegs ; 29 | sh:maxInclusive 4 ; 30 | sh:minInclusive 1 ; 31 | ] ; 32 | sh:targetClass exOnt:Animal . 33 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/misc/deactivated-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/misc/deactivated-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of deactivated-001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "true"^^xsd:boolean ; 24 | ] ; 25 | . 26 | ex:InvalidResource 27 | rdf:type rdfs:Resource ; 28 | . 29 | ex:TestShape 30 | rdf:type sh:NodeShape ; 31 | sh:datatype xsd:boolean ; 32 | sh:deactivated "true"^^xsd:boolean ; 33 | sh:property ex:TestShape2 ; 34 | sh:targetNode ex:InvalidResource ; 35 | . 36 | ex:TestShape2 37 | rdf:type sh:PropertyShape ; 38 | sh:path ex:property ; 39 | sh:minCount 1 ; 40 | . 41 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/misc/deactivated-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/misc/deactivated-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of deactivated-002" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode 32 ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value 32 ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:TestShape 35 | rdf:type sh:NodeShape ; 36 | sh:datatype xsd:boolean ; 37 | sh:deactivated "false"^^xsd:boolean ; 38 | sh:targetNode 32 ; 39 | . 40 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/misc/severity-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/misc/severity-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:severity 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode "Hello" ; 26 | sh:resultSeverity sh:Warning ; 27 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 28 | sh:sourceShape ex:TestShape ; 29 | sh:value "Hello" ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:TestShape 34 | rdf:type sh:NodeShape ; 35 | sh:datatype xsd:integer ; 36 | sh:severity sh:Warning ; 37 | sh:targetNode "Hello" ; 38 | . 39 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/class-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/class-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:class at node shape 002" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode "String" ; 26 | sh:resultSeverity sh:Violation ; 27 | sh:sourceConstraintComponent sh:ClassConstraintComponent ; 28 | sh:sourceShape ex:TestShape ; 29 | sh:value "String" ; 30 | ] ; 31 | sh:result [ 32 | rdf:type sh:ValidationResult ; 33 | sh:focusNode _:b9751 ; 34 | sh:resultSeverity sh:Violation ; 35 | sh:sourceConstraintComponent sh:ClassConstraintComponent ; 36 | sh:sourceShape ex:TestShape ; 37 | sh:value _:b9751 ; 38 | ] ; 39 | ] ; 40 | . 41 | ex:NamedInstance 42 | rdf:type ex:TestClass ; 43 | . 44 | ex:TestShape 45 | rdf:type sh:NodeShape ; 46 | sh:class ex:TestClass ; 47 | sh:targetClass ex:BNodeClass ; 48 | sh:targetNode ex:NamedInstance ; 49 | sh:targetNode "String" ; 50 | . 51 | _:b9751 52 | rdf:type ex:BNodeClass ; 53 | . 54 | [ 55 | rdf:type ex:BNodeClass ; 56 | rdf:type ex:TestClass ; 57 | ]. 58 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/closed-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/closed-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:closed at node shape 002" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidInstance1 ; 27 | sh:resultPath ex:otherProperty ; 28 | sh:resultSeverity sh:Violation ; 29 | sh:sourceConstraintComponent sh:ClosedConstraintComponent ; 30 | sh:sourceShape ex:MyShape ; 31 | sh:value 4 ; 32 | ] ; 33 | ] ; 34 | . 35 | ex:InvalidInstance1 36 | ex:otherProperty 4 ; 37 | ex:someProperty 3 ; 38 | . 39 | ex:MyShape 40 | rdf:type sh:NodeShape ; 41 | sh:closed "true"^^xsd:boolean ; 42 | sh:ignoredProperties ( 43 | rdf:type 44 | ) ; 45 | sh:property [ 46 | sh:path ex:someProperty ; 47 | ] ; 48 | sh:targetNode ex:InvalidInstance1 ; 49 | sh:targetNode ex:ValidInstance1 ; 50 | . 51 | ex:ValidInstance1 52 | rdf:type ex:SomeClass ; 53 | ex:someProperty 3 ; 54 | . 55 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/datatype-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/datatype-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:datatype at node shape 002" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode "Hello"^^rdf:HTML ; 26 | sh:resultSeverity sh:Violation ; 27 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 28 | sh:sourceShape ex:TestShape ; 29 | sh:value "Hello"^^rdf:HTML ; 30 | ] ; 31 | sh:result [ 32 | rdf:type sh:ValidationResult ; 33 | sh:focusNode "Hello" ; 34 | sh:resultSeverity sh:Violation ; 35 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 36 | sh:sourceShape ex:TestShape ; 37 | sh:value "Hello" ; 38 | ] ; 39 | ] ; 40 | . 41 | ex:TestShape 42 | rdf:type sh:NodeShape ; 43 | sh:datatype rdf:langString ; 44 | sh:targetNode "Hello"^^rdf:HTML ; 45 | sh:targetNode "G'day"@en-AU ; 46 | sh:targetNode "Hallo"@de ; 47 | sh:targetNode "Hello" ; 48 | . 49 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/disjoint-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/disjoint-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:disjoint at node shape 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidResource1 ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:DisjointConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value ex:InvalidResource1 ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:InvalidResource1 35 | ex:property ex:InvalidResource1 ; 36 | ex:property ex:ValidResource1 ; 37 | . 38 | ex:TestShape 39 | rdf:type sh:NodeShape ; 40 | rdfs:label "Test shape" ; 41 | sh:disjoint ex:property ; 42 | sh:targetNode ex:InvalidResource1 ; 43 | sh:targetNode ex:ValidResource1 ; 44 | . 45 | ex:ValidResource1 46 | ex:property ex:InvalidResource1 ; 47 | . 48 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/hasValue-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/hasValue-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:hasValue at node shape 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode "Invalid String" ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:HasValueConstraintComponent ; 29 | sh:sourceShape ex:TestShape 30 | ] ; 31 | ] ; 32 | . 33 | ex:TestShape 34 | rdf:type sh:NodeShape ; 35 | rdfs:label "Test shape" ; 36 | sh:hasValue "Test" ; 37 | sh:targetNode "Invalid String" ; 38 | sh:targetNode "Test" ; 39 | . 40 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/in-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/in-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:in at node shape 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidInstance ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:InConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value ex:InvalidInstance ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:Green 35 | rdf:type ex:TestShape ; 36 | rdfs:label "Green" ; 37 | . 38 | ex:InvalidInstance 39 | rdf:type ex:TestShape ; 40 | rdfs:label "Invalid instance" ; 41 | . 42 | ex:Red 43 | rdf:type ex:TestShape ; 44 | rdfs:label "Red" ; 45 | . 46 | ex:TestShape 47 | rdf:type rdfs:Class ; 48 | rdf:type sh:NodeShape ; 49 | rdfs:label "Test shape" ; 50 | sh:in ( 51 | ex:Green 52 | ex:Red 53 | ex:Yellow 54 | ) ; 55 | . 56 | ex:Yellow 57 | rdf:type ex:TestShape ; 58 | rdfs:label "Yellow" ; 59 | . 60 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/minInclusive-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/minInclusive-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:minInclusive at node shape 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode 7 ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MinInclusiveConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value 7 ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:TestShape 35 | rdf:type sh:NodeShape ; 36 | sh:minInclusive 8 ; 37 | sh:targetNode 7 ; 38 | sh:targetNode 8 ; 39 | sh:targetNode 9 ; 40 | . 41 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/node-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/node-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:node at node shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidInstance ; 26 | sh:resultSeverity sh:Violation ; 27 | sh:sourceConstraintComponent sh:NodeConstraintComponent ; 28 | sh:sourceShape ex:TestClass ; 29 | sh:value ex:InvalidInstance ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidInstance 34 | rdf:type ex:TestClass ; 35 | rdfs:label "Invalid instance" ; 36 | . 37 | ex:TestClass 38 | rdf:type rdfs:Class ; 39 | rdf:type sh:NodeShape ; 40 | rdfs:label "Test class" ; 41 | rdfs:subClassOf rdfs:Resource ; 42 | sh:node [ 43 | sh:class ex:OtherClass ; 44 | ] ; 45 | . 46 | ex:ValidInstance 47 | rdf:type ex:OtherClass ; 48 | rdf:type ex:TestClass ; 49 | rdfs:label "Valid instance" ; 50 | . 51 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/nodeKind-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/nodeKind-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:nodeKind at node shape 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode "true"^^xsd:boolean ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:NodeKindConstraintComponent ; 29 | sh:sourceShape ex:IRITestShape ; 30 | sh:value "true"^^xsd:boolean ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:IRITestShape 35 | rdf:type sh:NodeShape ; 36 | sh:nodeKind sh:IRI ; 37 | sh:targetNode ex:John ; 38 | sh:targetNode "true"^^xsd:boolean ; 39 | . 40 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/not-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/not-001 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:not at node shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidResource1 ; 26 | sh:resultSeverity sh:Violation ; 27 | sh:sourceConstraintComponent sh:NotConstraintComponent ; 28 | sh:sourceShape ex:TestShape ; 29 | sh:value ex:InvalidResource1 ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidResource1 34 | rdf:type rdfs:Resource ; 35 | ex:property "some value" ; 36 | . 37 | ex:TestShape 38 | rdf:type rdfs:Class ; 39 | rdf:type sh:NodeShape ; 40 | rdfs:label "Test shape" ; 41 | rdfs:subClassOf rdfs:Resource ; 42 | sh:not [ 43 | rdf:type sh:NodeShape ; 44 | sh:property [ 45 | sh:path ex:property ; 46 | sh:minCount 1 ; 47 | ] ; 48 | ] ; 49 | sh:targetNode ex:InvalidResource1 ; 50 | sh:targetNode ex:ValidResource1 ; 51 | . 52 | ex:ValidResource1 53 | rdf:type rdfs:Resource ; 54 | . 55 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/not-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/not-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:not at node shape 002" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidInstance1 ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:NotConstraintComponent ; 29 | sh:sourceShape ex:NotExampleShape ; 30 | sh:value ex:InvalidInstance1 ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:InvalidInstance1 35 | ex:property "Some value" ; 36 | . 37 | ex:NotExampleShape 38 | rdf:type sh:NodeShape ; 39 | sh:not [ 40 | rdf:type sh:NodeShape ; 41 | sh:property [ 42 | sh:path ex:property ; 43 | sh:minCount 1 ; 44 | ] ; 45 | ] ; 46 | sh:targetNode ex:InvalidInstance1 ; 47 | sh:targetNode ex:ValidInstance1 ; 48 | . 49 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/node/pattern-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/node/pattern-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:pattern at node shape 002" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode "Alti" ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:PatternConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value "Alti" ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:TestShape 35 | rdf:type sh:NodeShape ; 36 | sh:flags "i" ; 37 | sh:pattern "Aldi" ; 38 | sh:targetNode "Aldi" ; 39 | sh:targetNode "Alti" ; 40 | sh:targetNode "aLdI" ; 41 | . 42 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/path/path-sequence-duplicate-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/path/path-sequence-duplicate-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of path sequence with duplicate 001" ; 16 | owl:imports ; 17 | . 18 | ex:A 19 | ex:p1 [ 20 | ex:p2 "value" ; 21 | ] ; 22 | ex:p1 [ 23 | ex:p2 "value" ; 24 | ] ; 25 | . 26 | ex:GraphValidationTestCase 27 | rdf:type dash:GraphValidationTestCase ; 28 | dash:expectedResult [ 29 | rdf:type sh:ValidationReport ; 30 | sh:conforms "false"^^xsd:boolean ; 31 | sh:result [ 32 | rdf:type sh:ValidationResult ; 33 | sh:focusNode ex:A ; 34 | sh:resultPath ( 35 | ex:p1 36 | ex:p2 37 | ) ; 38 | sh:resultSeverity sh:Violation ; 39 | sh:sourceConstraintComponent sh:NodeKindConstraintComponent ; 40 | sh:sourceShape ex:SP ; 41 | sh:value "value" ; 42 | ] ; 43 | ] ; 44 | . 45 | ex:S 46 | rdf:type sh:NodeShape ; 47 | sh:property ex:SP ; 48 | sh:targetNode ex:A ; 49 | . 50 | ex:SP 51 | a sh:PropertyShape ; 52 | sh:maxCount 1 ; 53 | sh:nodeKind sh:IRI ; 54 | sh:path ( 55 | ex:p1 56 | ex:p2 57 | ) ; 58 | . 59 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/path/path-zeroOrMore-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/path/path-zeroOrMore-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of path sh:zeroOrMorePath 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidResource1 ; 26 | sh:resultPath [ 27 | sh:zeroOrMorePath ex:child ; 28 | ] ; 29 | sh:resultSeverity sh:Violation ; 30 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 31 | sh:sourceShape ex:TestShape ; 32 | ] ; 33 | ] ; 34 | . 35 | ex:InvalidResource1 36 | rdf:type rdfs:Resource ; 37 | . 38 | ex:Person2 39 | ex:child ex:Person3 ; 40 | . 41 | ex:TestShape 42 | rdf:type sh:PropertyShape ; 43 | sh:path [ 44 | sh:zeroOrMorePath ex:child ; 45 | ] ; 46 | sh:minCount 2 ; 47 | sh:targetNode ex:InvalidResource1 ; 48 | sh:targetNode ex:ValidResource1 ; 49 | sh:targetNode ex:ValidResource2 ; 50 | . 51 | ex:ValidResource1 52 | ex:child ex:Person1 ; 53 | . 54 | ex:ValidResource2 55 | ex:child ex:Person2 ; 56 | . 57 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/path/path-zeroOrOne-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/path/path-zeroOrOne-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of path sh:zeroOrOnePath 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidResource1 ; 26 | sh:resultPath [ 27 | sh:zeroOrOnePath ex:child ; 28 | ] ; 29 | sh:resultSeverity sh:Violation ; 30 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 31 | sh:sourceShape ex:TestShape ; 32 | ] ; 33 | ] ; 34 | . 35 | ex:InvalidResource1 36 | rdf:type rdfs:Resource ; 37 | . 38 | ex:Person2 39 | ex:child ex:Person3 ; 40 | . 41 | ex:TestShape 42 | rdf:type sh:PropertyShape ; 43 | sh:path [ 44 | sh:zeroOrOnePath ex:child ; 45 | ] ; 46 | sh:minCount 2 ; 47 | sh:targetNode ex:InvalidResource1 ; 48 | sh:targetNode ex:ValidResource1 ; 49 | sh:targetNode ex:ValidResource2 ; 50 | . 51 | ex:ValidResource1 52 | ex:child ex:Person1 ; 53 | . 54 | ex:ValidResource2 55 | ex:child ex:Person2 ; 56 | . 57 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/property/maxCount-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/property/maxCount-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:maxCount at property shape 002" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidResource ; 26 | sh:resultPath owl:versionInfo ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 29 | sh:sourceShape ex:TestShape-versionInfo ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidResource 34 | rdf:type rdfs:Resource ; 35 | rdfs:label "Invalid resource" ; 36 | owl:versionInfo "1.0" ; 37 | . 38 | ex:TestShape 39 | rdf:type sh:NodeShape ; 40 | rdfs:label "Test shape" ; 41 | sh:property ex:TestShape-versionInfo ; 42 | sh:targetNode ex:InvalidResource ; 43 | sh:targetNode ex:ValidResource ; 44 | . 45 | ex:TestShape-versionInfo 46 | sh:path owl:versionInfo ; 47 | sh:maxCount 0 ; 48 | . 49 | ex:ValidResource 50 | rdf:type rdfs:Resource ; 51 | rdfs:label "Valid resource" ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/property/minCount-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/property/minCount-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:minCount at property shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidPerson ; 26 | sh:resultPath ex:firstName ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 29 | sh:sourceShape ex:PersonShape-firstName ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidPerson 34 | rdf:type ex:Person ; 35 | rdfs:label "Invalid person" ; 36 | . 37 | ex:Person 38 | rdf:type rdfs:Class ; 39 | rdfs:label "Person" ; 40 | rdfs:subClassOf rdfs:Resource ; 41 | . 42 | ex:PersonShape 43 | rdf:type sh:NodeShape ; 44 | sh:property ex:PersonShape-firstName ; 45 | sh:targetClass ex:Person ; 46 | sh:targetNode ex:ValidResource ; 47 | . 48 | ex:PersonShape-firstName 49 | sh:path ex:firstName ; 50 | sh:datatype xsd:string ; 51 | sh:minCount 1 ; 52 | . 53 | ex:ValidResource 54 | rdf:type ex:Person ; 55 | ex:firstName "John" ; 56 | rdfs:label "Valid resource" ; 57 | . 58 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/property/minCount-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/property/minCount-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:minCount at property shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "true"^^xsd:boolean ; 23 | ] ; 24 | . 25 | ex:TestShape 26 | rdf:type sh:NodeShape ; 27 | sh:property [ 28 | sh:path ex:property ; 29 | sh:minCount 0 ; 30 | sh:name "property" ; 31 | ] ; 32 | sh:targetNode ex:ValidResource1 ; 33 | . 34 | ex:ValidResource1 35 | rdf:type rdfs:Resource ; 36 | . 37 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/property/minLength-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/property/minLength-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:minLength at property shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidInstance1 ; 26 | sh:resultPath ex:testProperty ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MinLengthConstraintComponent ; 29 | sh:sourceShape ex:TestShape-testProperty ; 30 | sh:value "A" ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:InvalidInstance1 35 | rdf:type ex:TestShape ; 36 | ex:testProperty "A" ; 37 | . 38 | ex:TestShape 39 | rdf:type rdfs:Class ; 40 | rdf:type sh:NodeShape ; 41 | rdfs:label "Test shape" ; 42 | sh:property ex:TestShape-testProperty ; 43 | . 44 | ex:TestShape-testProperty 45 | sh:path ex:testProperty ; 46 | sh:datatype xsd:string ; 47 | sh:minLength 2 ; 48 | . 49 | ex:ValidInstance1 50 | rdf:type ex:TestShape ; 51 | ex:testProperty "AB" ; 52 | ex:testProperty "ABC" ; 53 | . 54 | ex:ValidInstance2 55 | rdf:type ex:TestShape ; 56 | . 57 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/property/xone-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/property/xone-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | a owl:Ontology ; 15 | rdfs:label "Test of sh:xone at property shape 001" ; 16 | owl:imports ; 17 | . 18 | ex:Bob 19 | a ex:Person ; 20 | ex:value "Robert" ; 21 | . 22 | ex:Dory 23 | a ex:Person ; 24 | ex:value "165"^^xsd:int ; 25 | . 26 | ex:GraphValidationTestCase 27 | a dash:GraphValidationTestCase ; 28 | dash:expectedResult [ 29 | a sh:ValidationReport ; 30 | sh:conforms false ; 31 | sh:result [ 32 | a sh:ValidationResult ; 33 | sh:focusNode ex:Dory ; 34 | sh:resultPath ex:value ; 35 | sh:resultSeverity sh:Violation ; 36 | sh:sourceConstraintComponent sh:XoneConstraintComponent ; 37 | sh:sourceShape ex:TestPropertyShape ; 38 | sh:value "165"^^xsd:int ; 39 | ] ; 40 | ] ; 41 | . 42 | ex:TestPropertyShape 43 | sh:path ex:value ; 44 | sh:xone ( 45 | [ 46 | sh:datatype xsd:string ; 47 | ] 48 | [ 49 | sh:datatype xsd:double ; 50 | ] 51 | [ 52 | sh:datatype xsd:long ; 53 | ] 54 | ) ; 55 | . 56 | ex:XoneConstraintExampleShape 57 | a sh:NodeShape ; 58 | sh:property ex:TestPropertyShape ; 59 | sh:targetClass ex:Person ; 60 | . 61 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/targets/multipleTargets-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/targets/multipleTargets-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of multiple targets 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidResource1 ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:InConstraintComponent ; 29 | sh:sourceShape ex:TestShape ; 30 | sh:value ex:InvalidResource1 ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:InvalidResource1 35 | ex:property1 "Also a value" ; 36 | . 37 | ex:TestShape 38 | rdf:type sh:NodeShape ; 39 | rdfs:label "Test shape" ; 40 | sh:in ( 41 | ex:ValidResource1 42 | ex:ValidResource2 43 | ) ; 44 | sh:targetSubjectsOf ex:property1 ; 45 | sh:targetSubjectsOf ex:property2 ; 46 | . 47 | ex:ValidResource1 48 | ex:property1 "Some value" ; 49 | . 50 | ex:ValidResource2 51 | ex:property2 "Other value" ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/targets/targetClass-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/targets/targetClass-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:targetClass 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidInstance1 ; 26 | sh:resultPath ex:myProperty ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 29 | sh:sourceShape ex:MyShape-myProperty ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidInstance1 34 | rdf:type ex:MyClass ; 35 | ex:myProperty "A" ; 36 | ex:myProperty "B" ; 37 | . 38 | ex:MyClass 39 | rdf:type rdfs:Class ; 40 | . 41 | ex:MyShape 42 | rdf:type sh:NodeShape ; 43 | sh:property ex:MyShape-myProperty ; 44 | sh:targetClass ex:MyClass ; 45 | . 46 | ex:MyShape-myProperty 47 | sh:path ex:myProperty ; 48 | sh:maxCount 1 ; 49 | . 50 | ex:ValidInstance1 51 | rdf:type ex:MyClass ; 52 | ex:myProperty "A" ; 53 | . 54 | ex:ValidInstance2 55 | ex:myProperty "A" ; 56 | ex:myProperty "B" ; 57 | . 58 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/targets/targetClassImplicit-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/targets/targetClassImplicit-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of implicit sh:targetClass 001" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:GraphValidationTestCase 20 | rdf:type dash:GraphValidationTestCase ; 21 | dash:expectedResult [ 22 | rdf:type sh:ValidationReport ; 23 | sh:conforms "false"^^xsd:boolean ; 24 | sh:result [ 25 | rdf:type sh:ValidationResult ; 26 | sh:focusNode ex:InvalidInstance ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:InConstraintComponent ; 29 | sh:sourceShape ex:SuperClass ; 30 | sh:value ex:InvalidInstance ; 31 | ] ; 32 | ] ; 33 | . 34 | ex:InvalidInstance 35 | rdf:type ex:SubClass ; 36 | rdfs:label "Invalid instance" ; 37 | . 38 | ex:SubClass 39 | rdf:type rdfs:Class ; 40 | rdfs:label "Sub class" ; 41 | rdfs:subClassOf ex:SuperClass ; 42 | . 43 | ex:SuperClass 44 | rdf:type rdfs:Class ; 45 | rdf:type sh:NodeShape ; 46 | rdfs:label "Super class" ; 47 | sh:in ( 48 | ex:ValidInstance 49 | ) ; 50 | . 51 | ex:ValidInstance 52 | rdf:type ex:SubClass ; 53 | rdfs:label "Valid instance" ; 54 | . 55 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/targets/targetNode-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/targets/targetNode-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of sh:targetNode 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidResource1 ; 26 | sh:resultPath rdfs:label ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 29 | sh:sourceShape ex:TestShape-label ; 30 | ] ; 31 | ] ; 32 | . 33 | ex:InvalidResource1 34 | rdf:type rdfs:Resource ; 35 | rdfs:label "Invalid resource 1" ; 36 | . 37 | ex:TestShape 38 | rdf:type sh:NodeShape ; 39 | rdfs:label "Test shape" ; 40 | sh:property ex:TestShape-label ; 41 | sh:targetNode ex:InvalidResource1 ; 42 | sh:targetNode ex:ValidResource1 ; 43 | . 44 | ex:TestShape-label 45 | sh:path rdfs:label ; 46 | rdfs:label "label" ; 47 | sh:datatype xsd:string ; 48 | sh:maxCount 0 ; 49 | . 50 | ex:ValidResource1 51 | rdf:type rdfs:Resource ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/dash_tests/core/targets/targetSubjectsOf-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/core/targets/targetSubjectsOf-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | ex:InvalidInstance1 14 | ex:myProperty "A" ; 15 | ex:myProperty "B" ; 16 | . 17 | ex:ValidInstance1 18 | ex:myProperty "A" ; 19 | . 20 | 21 | rdf:type owl:Ontology ; 22 | rdfs:label "Test of sh:targetSubjectsOf 001" ; 23 | owl:imports ; 24 | . 25 | ex:GraphValidationTestCase 26 | rdf:type dash:GraphValidationTestCase ; 27 | dash:expectedResult [ 28 | rdf:type sh:ValidationReport ; 29 | sh:conforms "false"^^xsd:boolean ; 30 | sh:result [ 31 | rdf:type sh:ValidationResult ; 32 | sh:focusNode ex:InvalidInstance1 ; 33 | sh:resultPath ex:myProperty ; 34 | sh:resultSeverity sh:Violation ; 35 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 36 | sh:sourceShape ex:TestShape-myProperty ; 37 | ] ; 38 | ] ; 39 | . 40 | ex:MyClass 41 | rdf:type rdfs:Class ; 42 | . 43 | ex:TestShape 44 | rdf:type sh:NodeShape ; 45 | sh:property ex:TestShape-myProperty ; 46 | sh:targetSubjectsOf ex:myProperty ; 47 | . 48 | ex:TestShape-myProperty 49 | a sh:PropertyShape ; 50 | sh:path ex:myProperty ; 51 | sh:maxCount 1 ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/dash_tests/function/simpleSPARQLFunction.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/sparql/function/simpleSPARQLFunction.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of simpleSPARQLFunction" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | . 19 | ex:booleanFunction 20 | rdf:type sh:SPARQLFunction ; 21 | rdfs:label "boolean function" ; 22 | sh:ask """ASK { 23 | FILTER (true) . 24 | }""" ; 25 | sh:returnType xsd:boolean ; 26 | . 27 | ex:testBooleanFunction 28 | rdf:type dash:FunctionTestCase ; 29 | dash:expectedResult "true"^^xsd:boolean ; 30 | dash:expression "ex:booleanFunction()" ; 31 | . 32 | ex:testWithArguments 33 | rdf:type dash:FunctionTestCase ; 34 | dash:expectedResult "A-B" ; 35 | dash:expression "ex:withArguments(\"A\", \"B\")" ; 36 | . 37 | ex:withArguments 38 | rdf:type sh:SPARQLFunction ; 39 | rdfs:label "with arguments" ; 40 | sh:parameter [ 41 | sh:path ex:arg1 ; 42 | sh:name "arg1" ; 43 | ] ; 44 | sh:parameter [ 45 | sh:path ex:arg2 ; 46 | sh:name "arg2" ; 47 | ] ; 48 | sh:returnType xsd:string ; 49 | sh:select """SELECT ?result 50 | WHERE { 51 | BIND (CONCAT($arg1, \"-\", $arg2) AS ?result) 52 | }""" ; 53 | . 54 | -------------------------------------------------------------------------------- /test/resources/dash_tests/rules/sparql/rectangle.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/shasf/tests/rules/sparql/rectangle.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of rectangle" ; 16 | owl:imports ; 17 | owl:versionInfo "Created with TopBraid Composer" ; 18 | sh:declare [ 19 | rdf:type sh:PrefixDeclaration ; 20 | sh:namespace "http://datashapes.org/shasf/tests/rules/sparql/rectangle.test#"^^xsd:anyURI ; 21 | sh:prefix "ex" ; 22 | ] ; 23 | . 24 | ex:ExampleRectangle 25 | rdf:type ex:Rectangle ; 26 | ex:height 8 ; 27 | ex:width 7 ; 28 | . 29 | ex:InferencingTestCase 30 | rdf:type dash:InferencingTestCase ; 31 | dash:expectedResult [ 32 | rdf:object 56 ; 33 | rdf:predicate ex:area ; 34 | rdf:subject ex:ExampleRectangle ; 35 | ] ; 36 | . 37 | ex:Rectangle 38 | rdf:type rdfs:Class ; 39 | rdfs:subClassOf rdfs:Resource ; 40 | . 41 | ex:RectangleShape 42 | rdf:type sh:NodeShape ; 43 | sh:rule [ 44 | rdf:type sh:SPARQLRule ; 45 | sh:construct """ 46 | CONSTRUCT { 47 | $this ex:area ?area . 48 | } 49 | WHERE { 50 | $this ex:width ?width . 51 | $this ex:height ?height . 52 | BIND (?width * ?height AS ?area) . 53 | } 54 | """ ; 55 | sh:prefixes ; 56 | ] ; 57 | sh:targetClass ex:Rectangle ; 58 | . 59 | -------------------------------------------------------------------------------- /test/resources/dash_tests/rules/triple/person.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/shasf/tests/rules/triple/person 2 | # imports: http://datashapes.org/dash 3 | # prefix: person 4 | 5 | @prefix owl: . 6 | @prefix person: . 7 | @prefix rdf: . 8 | @prefix rdfs: . 9 | @prefix xsd: . 10 | 11 | 12 | rdf:type owl:Ontology ; 13 | owl:imports ; 14 | owl:versionInfo "Created with TopBraid Composer" ; 15 | . 16 | person:JohnDoe 17 | rdf:type person:Person ; 18 | person:firstName "John" ; 19 | person:lastName "Doe" ; 20 | person:zipCode 12345 ; 21 | rdfs:label "John doe" ; 22 | . 23 | person:Person 24 | rdf:type rdfs:Class ; 25 | rdfs:label "Person" ; 26 | . 27 | person:firstName 28 | rdf:type rdf:Property ; 29 | rdfs:domain person:Person ; 30 | rdfs:label "first name" ; 31 | rdfs:range xsd:string ; 32 | . 33 | person:lastName 34 | rdf:type rdf:Property ; 35 | rdfs:domain person:Person ; 36 | rdfs:label "last name" ; 37 | rdfs:range xsd:string ; 38 | . 39 | person:zipCode 40 | rdf:type rdf:Property ; 41 | rdfs:domain person:Person ; 42 | rdfs:label "zip code" ; 43 | rdfs:range xsd:integer ; 44 | . 45 | -------------------------------------------------------------------------------- /test/resources/dash_tests/shapedefs/anon-shape-001.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-001.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of anonymous shape definition 001" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidNode1 ; 26 | sh:resultPath ex:property ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 29 | sh:sourceShape [] ; 30 | ] ; 31 | ] ; 32 | dash:validateShapes "true"^^xsd:boolean ; 33 | . 34 | ex:InvalidNode1 35 | rdf:type ex:Person ; 36 | . 37 | ex:Person 38 | rdf:type rdfs:Class ; 39 | rdfs:label "Person" ; 40 | . 41 | ex:ValidNode1 42 | rdf:type ex:Person ; 43 | ex:property 42 ; 44 | . 45 | [ 46 | rdf:type sh:NodeShape ; 47 | rdfs:label "Anon shape" ; 48 | sh:property [ 49 | sh:path ex:property ; 50 | sh:datatype xsd:integer ; 51 | sh:maxCount 1 ; 52 | sh:minCount 1 ; 53 | sh:name "property" ; 54 | ] ; 55 | sh:targetClass ex:Person ; 56 | ]. 57 | -------------------------------------------------------------------------------- /test/resources/dash_tests/shapedefs/anon-shape-002.test.ttl: -------------------------------------------------------------------------------- 1 | # baseURI: http://datashapes.org/sh/tests/shapedefs/anon-shape-002.test 2 | # imports: http://datashapes.org/dash 3 | # prefix: ex 4 | 5 | @prefix dash: . 6 | @prefix ex: . 7 | @prefix owl: . 8 | @prefix rdf: . 9 | @prefix rdfs: . 10 | @prefix sh: . 11 | @prefix xsd: . 12 | 13 | 14 | rdf:type owl:Ontology ; 15 | rdfs:label "Test of anonymous shape definition 002" ; 16 | owl:imports ; 17 | . 18 | ex:GraphValidationTestCase 19 | rdf:type dash:GraphValidationTestCase ; 20 | dash:expectedResult [ 21 | rdf:type sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ 24 | rdf:type sh:ValidationResult ; 25 | sh:focusNode ex:InvalidNode1 ; 26 | sh:resultPath ex:property ; 27 | sh:resultSeverity sh:Violation ; 28 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 29 | sh:sourceShape [] ; 30 | ] ; 31 | ] ; 32 | dash:validateShapes "true"^^xsd:boolean ; 33 | . 34 | ex:InvalidNode1 35 | rdfs:label "Invalid node 1" ; 36 | . 37 | ex:ValidNode1 38 | ex:property 42 ; 39 | . 40 | [ 41 | rdf:type sh:NodeShape ; 42 | rdfs:label "Anon shape" ; 43 | sh:property [ 44 | sh:path ex:property ; 45 | sh:datatype xsd:integer ; 46 | sh:maxCount 1 ; 47 | sh:minCount 1 ; 48 | sh:name "property" ; 49 | ] ; 50 | sh:targetNode ex:InvalidNode1 ; 51 | sh:targetNode ex:ValidNode1 ; 52 | ]. 53 | -------------------------------------------------------------------------------- /test/resources/js/findBornIn.js: -------------------------------------------------------------------------------- 1 | var EXbornIn = TermFactory.namedNode("http://datashapes.org/sh/tests/js/target/jsTargetType-001.test#bornIn"); 2 | 3 | function findBornIn($country) { 4 | var spo = $data.find(null, EXbornIn, $country); 5 | var accum = []; 6 | for(var t = spo.next(); t; t = spo.next()) { 7 | var subject = t.subject; 8 | accum.push(subject); 9 | } 10 | return accum; 11 | } 12 | -------------------------------------------------------------------------------- /test/resources/js/findThings.js: -------------------------------------------------------------------------------- 1 | var RDFtype = TermFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); 2 | var OWLThing = TermFactory.namedNode("http://www.w3.org/2002/07/owl#Thing"); 3 | 4 | function findThings() { 5 | var spo = $data.find(null, RDFtype, OWLThing); 6 | var accum = []; 7 | for(var t = spo.next(); t; t = spo.next()) { 8 | var subject = t.subject; 9 | accum.push(subject); 10 | } 11 | return accum; 12 | } 13 | -------------------------------------------------------------------------------- /test/resources/js/germanLabel.js: -------------------------------------------------------------------------------- 1 | // From https://www.w3.org/TR/shacl-js/#js-constraints 2 | function validateGermanLabel($this) { 3 | var results = []; 4 | var p = TermFactory.namedNode("http://example.com/ex#germanLabel"); 5 | var s = $data.find($this, p, null); 6 | for(var t = s.next(); t; t = s.next()) { 7 | var object = t.object; 8 | if(!object.isLiteral() || !object.language.startsWith("de")) { 9 | results.push({ 10 | value : object, 11 | path : p, 12 | }); 13 | } 14 | } 15 | return results; 16 | } 17 | -------------------------------------------------------------------------------- /test/resources/js/hasMaxCount.js: -------------------------------------------------------------------------------- 1 | function hasMaxCount($this, $path, $maxCount) { 2 | var spo = $data.find($this, $path, null); 3 | var accum = []; 4 | for(var t = spo.next(); t; t = spo.next()) { 5 | var object = t.object; 6 | accum.push(object); 7 | } 8 | if (accum.length > $maxCount.lex) { 9 | return false; 10 | } 11 | return true; 12 | } 13 | -------------------------------------------------------------------------------- /test/resources/js/hasMaxLength.js: -------------------------------------------------------------------------------- 1 | function hasMaxLength($value, $maxLength) { 2 | if($value.isLiteral()) { 3 | return $value.lex.length <= $maxLength.lex; 4 | } 5 | else if($value.isURI()) { 6 | return $value.uri.length <= $maxLength.lex; 7 | } 8 | else { // Blank node 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/resources/js/multiply.js: -------------------------------------------------------------------------------- 1 | function multiply($op1, $op2) { 2 | return $op1.lex * $op2.lex; 3 | } 4 | -------------------------------------------------------------------------------- /test/resources/js/rectangle.js: -------------------------------------------------------------------------------- 1 | var NS = "http://datashapes.org/js/tests/rules/rectangle.test#"; 2 | 3 | function computeArea($this) { 4 | var width = getProperty($this, "width"); 5 | var height = getProperty($this, "height"); 6 | var area = TermFactory.literal(width.lex * height.lex, width.datatype); 7 | var areaProperty = TermFactory.namedNode(NS + "area"); 8 | return [ 9 | [$this, areaProperty, area] 10 | ]; 11 | } 12 | 13 | function getProperty($this, name) { 14 | var it = $data.find($this, TermFactory.namedNode(NS + name), null); 15 | var result = it.next().object; 16 | it.close(); 17 | return result; 18 | } 19 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/complex/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/complex" ; 8 | mf:include ; 9 | mf:include ; 10 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/complex/shacl-shacl.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix xsd: . 4 | @prefix sh: . 5 | @prefix sht: . 6 | 7 | <> a mf:Manifest ; 8 | mf:entries ( 9 | 10 | ) . 11 | 12 | a sht:Validate ; 13 | rdfs:label "frozen eat your own ( eat your own frozen dogfood )" ; 14 | mf:action [ 15 | sht:dataGraph ; 16 | sht:shapesGraph ] ; 17 | mf:result [a sh:ValidationReport ; 18 | sh:conforms "true"^^xsd:boolean ] ; 19 | mf:status sht:approved . 20 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | mf:include ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/misc/deactivated-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource 12 | rdf:type rdfs:Resource ; 13 | . 14 | ex:TestShape 15 | rdf:type sh:NodeShape ; 16 | sh:datatype xsd:boolean ; 17 | sh:deactivated "true"^^xsd:boolean ; 18 | sh:property ex:TestShape2 ; 19 | sh:targetNode ex:InvalidResource ; 20 | . 21 | ex:TestShape2 22 | rdf:type sh:PropertyShape ; 23 | sh:path ex:property ; 24 | sh:minCount 1 ; 25 | . 26 | <> 27 | rdf:type mf:Manifest ; 28 | mf:entries ( 29 | 30 | ) ; 31 | . 32 | 33 | rdf:type sht:Validate ; 34 | rdfs:label "Test of sh:deactivated 001" ; 35 | mf:action [ 36 | sht:dataGraph <> ; 37 | sht:shapesGraph <> ; 38 | ] ; 39 | mf:result [ 40 | rdf:type sh:ValidationReport ; 41 | sh:conforms "true"^^xsd:boolean ; 42 | ] ; 43 | mf:status sht:approved ; 44 | . 45 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/misc/deactivated-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:datatype xsd:boolean ; 14 | sh:deactivated "false"^^xsd:boolean ; 15 | sh:targetNode 32 ; 16 | . 17 | <> 18 | rdf:type mf:Manifest ; 19 | mf:entries ( 20 | 21 | ) ; 22 | . 23 | 24 | rdf:type sht:Validate ; 25 | rdfs:label "Test of sh:deactivated 002" ; 26 | mf:action [ 27 | sht:dataGraph <> ; 28 | sht:shapesGraph <> ; 29 | ] ; 30 | mf:result [ 31 | rdf:type sh:ValidationReport ; 32 | sh:conforms "false"^^xsd:boolean ; 33 | sh:result [ 34 | rdf:type sh:ValidationResult ; 35 | sh:focusNode 32 ; 36 | sh:resultSeverity sh:Violation ; 37 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 38 | sh:sourceShape ex:TestShape ; 39 | sh:value 32 ; 40 | ] ; 41 | ] ; 42 | mf:status sht:approved ; 43 | . 44 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/misc/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/misc" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/misc/message-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:datatype xsd:integer ; 14 | sh:message "Test message"@en ; 15 | sh:targetNode ex:InvalidNode ; 16 | . 17 | <> 18 | rdf:type mf:Manifest ; 19 | mf:entries ( 20 | 21 | ) ; 22 | . 23 | 24 | rdf:type sht:Validate ; 25 | rdfs:label "Test of custom sh:message 001" ; 26 | rdfs:comment """ 27 | Note: This test verifies that the sh:message is copied into sh:resultMessage. 28 | To pass this test, the test harness needs to preserve all sh:resultMessage triples 29 | that are mentioned in the 'expected' results graph.""" ; 30 | mf:action [ 31 | sht:dataGraph <> ; 32 | sht:shapesGraph <> ; 33 | ] ; 34 | mf:result [ 35 | rdf:type sh:ValidationReport ; 36 | sh:conforms "false"^^xsd:boolean ; 37 | sh:result [ 38 | rdf:type sh:ValidationResult ; 39 | sh:focusNode ex:InvalidNode ; 40 | sh:resultMessage "Test message"@en ; 41 | sh:resultSeverity sh:Violation ; 42 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 43 | sh:sourceShape ex:TestShape ; 44 | sh:value ex:InvalidNode ; 45 | ] ; 46 | ] ; 47 | mf:status sht:approved ; 48 | . 49 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/misc/severity-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:datatype xsd:integer ; 14 | sh:severity sh:Warning ; 15 | sh:targetNode "Hello" ; 16 | . 17 | <> 18 | rdf:type mf:Manifest ; 19 | mf:entries ( 20 | 21 | ) ; 22 | . 23 | 24 | rdf:type sht:Validate ; 25 | rdfs:label "Test of sh:severity 001" ; 26 | mf:action [ 27 | sht:dataGraph <> ; 28 | sht:shapesGraph <> ; 29 | ] ; 30 | mf:result [ 31 | rdf:type sh:ValidationReport ; 32 | sh:conforms "false"^^xsd:boolean ; 33 | sh:result [ 34 | rdf:type sh:ValidationResult ; 35 | sh:focusNode "Hello" ; 36 | sh:resultSeverity sh:Warning ; 37 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 38 | sh:sourceShape ex:TestShape ; 39 | sh:value "Hello" ; 40 | ] ; 41 | ] ; 42 | mf:status sht:approved ; 43 | . 44 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/closed-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | ex:otherProperty 4 ; 13 | ex:someProperty 3 ; 14 | . 15 | ex:MyShape 16 | rdf:type sh:NodeShape ; 17 | sh:closed "true"^^xsd:boolean ; 18 | sh:ignoredProperties ( 19 | rdf:type 20 | ) ; 21 | sh:property [ 22 | sh:path ex:someProperty ; 23 | ] ; 24 | sh:targetNode ex:InvalidInstance1 ; 25 | sh:targetNode ex:ValidInstance1 ; 26 | . 27 | ex:ValidInstance1 28 | rdf:type ex:SomeClass ; 29 | ex:someProperty 3 ; 30 | . 31 | <> 32 | rdf:type mf:Manifest ; 33 | mf:entries ( 34 | 35 | ) ; 36 | . 37 | 38 | rdf:type sht:Validate ; 39 | rdfs:label "Test of sh:closed at node shape 002" ; 40 | mf:action [ 41 | sht:dataGraph <> ; 42 | sht:shapesGraph <> ; 43 | ] ; 44 | mf:result [ 45 | rdf:type sh:ValidationReport ; 46 | sh:conforms "false"^^xsd:boolean ; 47 | sh:result [ 48 | rdf:type sh:ValidationResult ; 49 | sh:focusNode ex:InvalidInstance1 ; 50 | sh:resultPath ex:otherProperty ; 51 | sh:resultSeverity sh:Violation ; 52 | sh:sourceConstraintComponent sh:ClosedConstraintComponent ; 53 | sh:sourceShape ex:MyShape ; 54 | sh:value 4 ; 55 | ] ; 56 | ] ; 57 | mf:status sht:approved ; 58 | . 59 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/datatype-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:datatype rdf:langString ; 14 | sh:targetNode "Hello"^^rdf:HTML ; 15 | sh:targetNode "G'day"@en-AU ; 16 | sh:targetNode "Hallo"@de ; 17 | sh:targetNode "Hello" ; 18 | . 19 | <> 20 | rdf:type mf:Manifest ; 21 | mf:entries ( 22 | 23 | ) ; 24 | . 25 | 26 | rdf:type sht:Validate ; 27 | rdfs:label "Test of sh:datatype at node shape 002" ; 28 | mf:action [ 29 | sht:dataGraph <> ; 30 | sht:shapesGraph <> ; 31 | ] ; 32 | mf:result [ 33 | rdf:type sh:ValidationReport ; 34 | sh:conforms "false"^^xsd:boolean ; 35 | sh:result [ 36 | rdf:type sh:ValidationResult ; 37 | sh:focusNode "Hello"^^rdf:HTML ; 38 | sh:resultSeverity sh:Violation ; 39 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 40 | sh:sourceShape ex:TestShape ; 41 | sh:value "Hello"^^rdf:HTML ; 42 | ] ; 43 | sh:result [ 44 | rdf:type sh:ValidationResult ; 45 | sh:focusNode "Hello" ; 46 | sh:resultSeverity sh:Violation ; 47 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; 48 | sh:sourceShape ex:TestShape ; 49 | sh:value "Hello" ; 50 | ] ; 51 | ] ; 52 | mf:status sht:approved ; 53 | . 54 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/disjoint-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | ex:property ex:InvalidResource1 ; 13 | ex:property ex:ValidResource1 ; 14 | . 15 | ex:TestShape 16 | rdf:type sh:NodeShape ; 17 | rdfs:label "Test shape" ; 18 | sh:disjoint ex:property ; 19 | sh:targetNode ex:InvalidResource1 ; 20 | sh:targetNode ex:ValidResource1 ; 21 | . 22 | ex:ValidResource1 23 | ex:property ex:InvalidResource1 ; 24 | . 25 | <> 26 | rdf:type mf:Manifest ; 27 | mf:entries ( 28 | 29 | ) ; 30 | . 31 | 32 | rdf:type sht:Validate ; 33 | rdfs:label "Test of sh:disjoint at node shape 001" ; 34 | mf:action [ 35 | sht:dataGraph <> ; 36 | sht:shapesGraph <> ; 37 | ] ; 38 | mf:result [ 39 | rdf:type sh:ValidationReport ; 40 | sh:conforms "false"^^xsd:boolean ; 41 | sh:result [ 42 | rdf:type sh:ValidationResult ; 43 | sh:focusNode ex:InvalidResource1 ; 44 | sh:resultSeverity sh:Violation ; 45 | sh:sourceConstraintComponent sh:DisjointConstraintComponent ; 46 | sh:sourceShape ex:TestShape ; 47 | sh:value ex:InvalidResource1 ; 48 | ] ; 49 | ] ; 50 | mf:status sht:approved ; 51 | . 52 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/hasValue-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | rdfs:label "Test shape" ; 14 | sh:hasValue "Test" ; 15 | sh:targetNode "Invalid String" ; 16 | sh:targetNode "Test" ; 17 | . 18 | <> 19 | rdf:type mf:Manifest ; 20 | mf:entries ( 21 | 22 | ) ; 23 | . 24 | 25 | rdf:type sht:Validate ; 26 | rdfs:label "Test of sh:hasValue at node shape 001" ; 27 | mf:action [ 28 | sht:dataGraph <> ; 29 | sht:shapesGraph <> ; 30 | ] ; 31 | mf:result [ 32 | rdf:type sh:ValidationReport ; 33 | sh:conforms "false"^^xsd:boolean ; 34 | sh:result [ 35 | rdf:type sh:ValidationResult ; 36 | sh:focusNode "Invalid String" ; 37 | sh:resultSeverity sh:Violation ; 38 | sh:sourceConstraintComponent sh:HasValueConstraintComponent ; 39 | sh:sourceShape ex:TestShape ; 40 | # See See https://github.com/w3c/data-shapes/issues/111: don't create sh:value "Invalid String" ; 41 | ] ; 42 | ] ; 43 | mf:status sht:approved ; 44 | . 45 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/in-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:Green 12 | rdf:type ex:TestShape ; 13 | rdfs:label "Green" ; 14 | . 15 | ex:InvalidInstance 16 | rdf:type ex:TestShape ; 17 | rdfs:label "Invalid instance" ; 18 | . 19 | ex:Red 20 | rdf:type ex:TestShape ; 21 | rdfs:label "Red" ; 22 | . 23 | ex:TestShape 24 | rdf:type rdfs:Class ; 25 | rdf:type sh:NodeShape ; 26 | rdfs:label "Test shape" ; 27 | sh:in ( 28 | ex:Green 29 | ex:Red 30 | ex:Yellow 31 | ) ; 32 | . 33 | ex:Yellow 34 | rdf:type ex:TestShape ; 35 | rdfs:label "Yellow" ; 36 | . 37 | <> 38 | rdf:type mf:Manifest ; 39 | mf:entries ( 40 | 41 | ) ; 42 | . 43 | 44 | rdf:type sht:Validate ; 45 | rdfs:label "Test of sh:in at node shape 001" ; 46 | mf:action [ 47 | sht:dataGraph <> ; 48 | sht:shapesGraph <> ; 49 | ] ; 50 | mf:result [ 51 | rdf:type sh:ValidationReport ; 52 | sh:conforms "false"^^xsd:boolean ; 53 | sh:result [ 54 | rdf:type sh:ValidationResult ; 55 | sh:focusNode ex:InvalidInstance ; 56 | sh:resultSeverity sh:Violation ; 57 | sh:sourceConstraintComponent sh:InConstraintComponent ; 58 | sh:sourceShape ex:TestShape ; 59 | sh:value ex:InvalidInstance ; 60 | ] ; 61 | ] ; 62 | mf:status sht:approved ; 63 | . 64 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/node" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | mf:include ; 15 | mf:include ; 16 | mf:include ; 17 | mf:include ; 18 | mf:include ; 19 | mf:include ; 20 | mf:include ; 21 | mf:include ; 22 | mf:include ; 23 | mf:include ; 24 | mf:include ; 25 | mf:include ; 26 | mf:include ; 27 | mf:include ; 28 | mf:include ; 29 | mf:include ; 30 | mf:include ; 31 | mf:include ; 32 | mf:include ; 33 | mf:include ; 34 | mf:include ; 35 | mf:include ; 36 | mf:include ; 37 | mf:include ; 38 | mf:include ; 39 | mf:include ; 40 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/minInclusive-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:minInclusive 8 ; 14 | sh:targetNode 7 ; 15 | sh:targetNode 8 ; 16 | sh:targetNode 9 ; 17 | . 18 | <> 19 | rdf:type mf:Manifest ; 20 | mf:entries ( 21 | 22 | ) ; 23 | . 24 | 25 | rdf:type sht:Validate ; 26 | rdfs:label "Test of sh:minInclusive at node shape 001" ; 27 | mf:action [ 28 | sht:dataGraph <> ; 29 | sht:shapesGraph <> ; 30 | ] ; 31 | mf:result [ 32 | rdf:type sh:ValidationReport ; 33 | sh:conforms "false"^^xsd:boolean ; 34 | sh:result [ 35 | rdf:type sh:ValidationResult ; 36 | sh:focusNode 7 ; 37 | sh:resultSeverity sh:Violation ; 38 | sh:sourceConstraintComponent sh:MinInclusiveConstraintComponent ; 39 | sh:sourceShape ex:TestShape ; 40 | sh:value 7 ; 41 | ] ; 42 | ] ; 43 | mf:status sht:approved ; 44 | . 45 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/node-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance 12 | rdf:type ex:TestClass ; 13 | rdfs:label "Invalid instance" ; 14 | . 15 | ex:TestClass 16 | rdf:type rdfs:Class ; 17 | rdf:type sh:NodeShape ; 18 | rdfs:label "Test class" ; 19 | rdfs:subClassOf rdfs:Resource ; 20 | sh:node [ 21 | sh:class ex:OtherClass ; 22 | ] ; 23 | . 24 | ex:ValidInstance 25 | rdf:type ex:OtherClass ; 26 | rdf:type ex:TestClass ; 27 | rdfs:label "Valid instance" ; 28 | . 29 | <> 30 | rdf:type mf:Manifest ; 31 | mf:entries ( 32 | 33 | ) ; 34 | . 35 | 36 | rdf:type sht:Validate ; 37 | rdfs:label "Test of sh:node at node shape 001" ; 38 | mf:action [ 39 | sht:dataGraph <> ; 40 | sht:shapesGraph <> ; 41 | ] ; 42 | mf:result [ 43 | rdf:type sh:ValidationReport ; 44 | sh:conforms "false"^^xsd:boolean ; 45 | sh:result [ 46 | rdf:type sh:ValidationResult ; 47 | sh:focusNode ex:InvalidInstance ; 48 | sh:resultSeverity sh:Violation ; 49 | sh:sourceConstraintComponent sh:NodeConstraintComponent ; 50 | sh:sourceShape ex:TestClass ; 51 | sh:value ex:InvalidInstance ; 52 | ] ; 53 | ] ; 54 | mf:status sht:approved ; 55 | . 56 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/nodeKind-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:IRITestShape 12 | rdf:type sh:NodeShape ; 13 | sh:nodeKind sh:IRI ; 14 | sh:targetNode ex:John ; 15 | sh:targetNode "true"^^xsd:boolean ; 16 | . 17 | <> 18 | rdf:type mf:Manifest ; 19 | mf:entries ( 20 | 21 | ) ; 22 | . 23 | 24 | rdf:type sht:Validate ; 25 | rdfs:label "Test of sh:nodeKind at node shape 001" ; 26 | mf:action [ 27 | sht:dataGraph <> ; 28 | sht:shapesGraph <> ; 29 | ] ; 30 | mf:result [ 31 | rdf:type sh:ValidationReport ; 32 | sh:conforms "false"^^xsd:boolean ; 33 | sh:result [ 34 | rdf:type sh:ValidationResult ; 35 | sh:focusNode "true"^^xsd:boolean ; 36 | sh:resultSeverity sh:Violation ; 37 | sh:sourceConstraintComponent sh:NodeKindConstraintComponent ; 38 | sh:sourceShape ex:IRITestShape ; 39 | sh:value "true"^^xsd:boolean ; 40 | ] ; 41 | ] ; 42 | mf:status sht:approved ; 43 | . 44 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/not-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | rdf:type rdfs:Resource ; 13 | ex:property "some value" ; 14 | . 15 | ex:TestShape 16 | rdf:type rdfs:Class ; 17 | rdf:type sh:NodeShape ; 18 | rdfs:label "Test shape" ; 19 | rdfs:subClassOf rdfs:Resource ; 20 | sh:not [ 21 | rdf:type sh:NodeShape ; 22 | sh:property [ 23 | sh:path ex:property ; 24 | sh:minCount 1 ; 25 | ] ; 26 | ] ; 27 | sh:targetNode ex:InvalidResource1 ; 28 | sh:targetNode ex:ValidResource1 ; 29 | . 30 | ex:ValidResource1 31 | rdf:type rdfs:Resource ; 32 | . 33 | <> 34 | rdf:type mf:Manifest ; 35 | mf:entries ( 36 | 37 | ) ; 38 | . 39 | 40 | rdf:type sht:Validate ; 41 | rdfs:label "Test of sh:not at node shape 001" ; 42 | mf:action [ 43 | sht:dataGraph <> ; 44 | sht:shapesGraph <> ; 45 | ] ; 46 | mf:result [ 47 | rdf:type sh:ValidationReport ; 48 | sh:conforms "false"^^xsd:boolean ; 49 | sh:result [ 50 | rdf:type sh:ValidationResult ; 51 | sh:focusNode ex:InvalidResource1 ; 52 | sh:resultSeverity sh:Violation ; 53 | sh:sourceConstraintComponent sh:NotConstraintComponent ; 54 | sh:sourceShape ex:TestShape ; 55 | sh:value ex:InvalidResource1 ; 56 | ] ; 57 | ] ; 58 | mf:status sht:approved ; 59 | . 60 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/not-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | ex:property "Some value" ; 13 | . 14 | ex:NotExampleShape 15 | rdf:type sh:NodeShape ; 16 | sh:not [ 17 | rdf:type sh:NodeShape ; 18 | sh:property [ 19 | sh:path ex:property ; 20 | sh:minCount 1 ; 21 | ] ; 22 | ] ; 23 | sh:targetNode ex:InvalidInstance1 ; 24 | sh:targetNode ex:ValidInstance1 ; 25 | . 26 | <> 27 | rdf:type mf:Manifest ; 28 | mf:entries ( 29 | 30 | ) ; 31 | . 32 | 33 | rdf:type sht:Validate ; 34 | rdfs:label "Test of sh:not at node shape 002" ; 35 | mf:action [ 36 | sht:dataGraph <> ; 37 | sht:shapesGraph <> ; 38 | ] ; 39 | mf:result [ 40 | rdf:type sh:ValidationReport ; 41 | sh:conforms "false"^^xsd:boolean ; 42 | sh:result [ 43 | rdf:type sh:ValidationResult ; 44 | sh:focusNode ex:InvalidInstance1 ; 45 | sh:resultSeverity sh:Violation ; 46 | sh:sourceConstraintComponent sh:NotConstraintComponent ; 47 | sh:sourceShape ex:NotExampleShape ; 48 | sh:value ex:InvalidInstance1 ; 49 | ] ; 50 | ] ; 51 | mf:status sht:approved ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/pattern-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:flags "i" ; 14 | sh:pattern "Aldi" ; 15 | sh:targetNode "Aldi" ; 16 | sh:targetNode "Alti" ; 17 | sh:targetNode "aLdI" ; 18 | . 19 | <> 20 | rdf:type mf:Manifest ; 21 | mf:entries ( 22 | 23 | ) ; 24 | . 25 | 26 | rdf:type sht:Validate ; 27 | rdfs:label "Test of sh:pattern at node shape 002" ; 28 | mf:action [ 29 | sht:dataGraph <> ; 30 | sht:shapesGraph <> ; 31 | ] ; 32 | mf:result [ 33 | rdf:type sh:ValidationReport ; 34 | sh:conforms "false"^^xsd:boolean ; 35 | sh:result [ 36 | rdf:type sh:ValidationResult ; 37 | sh:focusNode "Alti" ; 38 | sh:resultSeverity sh:Violation ; 39 | sh:sourceConstraintComponent sh:PatternConstraintComponent ; 40 | sh:sourceShape ex:TestShape ; 41 | sh:value "Alti" ; 42 | ] ; 43 | ] ; 44 | mf:status sht:approved ; 45 | . 46 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/qualified-001-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | 3 | ex:i a ex:C1 . 4 | ex:j a ex:C1 , ex:C2 . 5 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/qualified-001-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix sh: . 3 | @prefix ex: . 4 | 5 | ex:s1 a sh:NodeShape ; 6 | sh:targetClass ex:C1 ; 7 | sh:class ex:C2 ; 8 | sh:qualifiedValueShapesDisjoint "1"^^xsd:boolean ; 9 | sh:qualifiedMinCount 5 ; 10 | sh:qualifiedMaxCount 2 . 11 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/qualified-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | @prefix ex: . 10 | 11 | <> a mf:Manifest ; 12 | mf:entries ( 13 | 14 | ) . 15 | 16 | a sht:Validate; 17 | rdfs:label "Test of qualified parameters allowed in node shapes" ; 18 | mf:action [ sht:dataGraph ; 19 | sht:shapesGraph ] ; 20 | mf:result [ rdf:type sh:ValidationReport ; 21 | sh:conforms "false"^^xsd:boolean ; 22 | sh:result [ rdf:type sh:ValidationResult ; 23 | sh:resultSeverity sh:Violation ; 24 | sh:focusNode ex:i ; 25 | sh:value ex:i ; 26 | sh:sourceShape ex:s1 ; 27 | sh:sourceConstraintComponent sh:ClassConstraintComponent ] ] ; 28 | mf:status sht:approved . 29 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/xone-duplicate-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | 3 | ex:i a ex:C1 . 4 | ex:j a ex:C1 , ex:C2 . 5 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/xone-duplicate-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix ex: . 3 | 4 | ex:s1 a sh:NodeShape ; 5 | sh:targetClass ex:C1 ; 6 | sh:xone ( ex:s2 ex:s2 ) . 7 | ex:s2 sh:class ex:C2 . 8 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/node/xone-duplicate.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | @prefix ex: . 10 | 11 | <> a mf:Manifest ; 12 | mf:entries ( 13 | 14 | ) . 15 | 16 | a sht:Validate; 17 | rdfs:label "Test of validation report for shape xone-duplicate by property constraints" ; 18 | mf:action [ sht:dataGraph ; 19 | sht:shapesGraph ] ; 20 | mf:result [ rdf:type sh:ValidationReport ; 21 | sh:conforms "false"^^xsd:boolean ; 22 | sh:result [ rdf:type sh:ValidationResult ; 23 | sh:resultSeverity sh:Violation ; 24 | sh:focusNode ex:i ; 25 | sh:value ex:i ; 26 | sh:sourceShape ex:s1 ; 27 | sh:sourceConstraintComponent sh:XoneConstraintComponent ] ; 28 | sh:result [ rdf:type sh:ValidationResult ; 29 | sh:resultSeverity sh:Violation ; 30 | sh:focusNode ex:j ; 31 | sh:value ex:j ; 32 | sh:sourceShape ex:s1 ; 33 | sh:sourceConstraintComponent sh:XoneConstraintComponent ] ] ; 34 | mf:status sht:approved . 35 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/path" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | mf:include ; 15 | mf:include ; 16 | mf:include ; 17 | mf:include ; 18 | mf:include ; 19 | mf:include ; 20 | mf:include ; 21 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-complex-002-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | 3 | ex:j ex:p ex:i . 4 | 5 | ex:k ex:p ex:j . 6 | 7 | ex:l ex:p ex:j . 8 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-complex-002-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix ex: . 3 | 4 | ex:s1 a sh:PropertyShape ; 5 | sh:targetNode ex:i ; 6 | sh:path ( _:pinv _:pinv ) ; 7 | sh:class ex:C . 8 | 9 | _:pinv sh:inversePath ex:p . 10 | 11 | ex:s2 a sh:PropertyShape ; 12 | sh:targetNode ex:i ; 13 | sh:path ( [ sh:inversePath ex:p ] [ sh:inversePath ex:p ] ) ; 14 | sh:class ex:C . 15 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-sequence-duplicate-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:A 12 | ex:p1 [ 13 | ex:p2 "value" ; 14 | ] ; 15 | ex:p1 [ 16 | ex:p2 "value" ; 17 | ] ; 18 | . 19 | ex:S 20 | rdf:type sh:NodeShape ; 21 | sh:property ex:SP ; 22 | sh:targetNode ex:A ; 23 | . 24 | ex:SP 25 | rdf:type sh:PropertyShape ; 26 | sh:path ( 27 | ex:p1 28 | ex:p2 29 | ) ; 30 | sh:maxCount 1 ; 31 | sh:nodeKind sh:IRI ; 32 | . 33 | <> 34 | rdf:type mf:Manifest ; 35 | mf:entries ( 36 | 37 | ) ; 38 | . 39 | 40 | rdf:type sht:Validate ; 41 | rdfs:label "Test of path sequence with duplicate 001" ; 42 | mf:action [ 43 | sht:dataGraph <> ; 44 | sht:shapesGraph <> ; 45 | ] ; 46 | mf:result [ 47 | rdf:type sh:ValidationReport ; 48 | sh:conforms "false"^^xsd:boolean ; 49 | sh:result [ 50 | rdf:type sh:ValidationResult ; 51 | sh:focusNode ex:A ; 52 | sh:resultPath ( 53 | ex:p1 54 | ex:p2 55 | ) ; 56 | sh:resultSeverity sh:Violation ; 57 | sh:sourceConstraintComponent sh:NodeKindConstraintComponent ; 58 | sh:sourceShape ex:SP ; 59 | sh:value "value" ; 60 | ] ; 61 | ] ; 62 | mf:status sht:approved ; 63 | . 64 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-strange-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | ex:i a ex:C ; 10 | ex:p ex:ip . 11 | ex:ip ex:q ex:ipq . 12 | ex:ipq a ex:C . 13 | ex:pi ex:p ex:i . 14 | 15 | ex:j a ex:C ; 16 | ex:p ex:jp . 17 | ex:jp ex:q ex:jpq . 18 | 19 | ex:s1 a sh:PropertyShape ; 20 | sh:targetClass ex:C ; 21 | sh:path [ rdf:first ex:p ; rdf:rest [ rdf:first ex:q ; rdf:rest rdf:nil ] ; 22 | sh:inversePath ex:p ] ; 23 | sh:class ex:C . 24 | 25 | <> 26 | rdf:type mf:Manifest ; 27 | mf:entries ( 28 | 29 | ) ; 30 | . 31 | 32 | 33 | rdf:type sht:Validate ; 34 | rdfs:label "Test of strange path 001 two valid paths together" ; 35 | mf:action [ 36 | sht:dataGraph <> ; 37 | sht:shapesGraph <> ; 38 | ] ; 39 | mf:result [ 40 | rdf:type sh:ValidationReport ; 41 | sh:conforms "false"^^xsd:boolean ; 42 | sh:result [ a sh:ValidationResult ; 43 | sh:focusNode ex:j ; 44 | sh:value ex:jpq ; 45 | sh:resultPath ( ex:p ex:q ) ; 46 | sh:resultSeverity sh:Violation ; 47 | sh:sourceConstraintComponent sh:ClassConstraintComponent ; 48 | sh:sourceShape ex:s1 ; 49 | ] ; 50 | ] ; 51 | mf:status sht:approved ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-strange-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | ex:i a ex:C ; 10 | ex:p ex:ip . 11 | ex:ip ex:q ex:ipq . 12 | ex:ipq a ex:C . 13 | ex:pi ex:p ex:i . 14 | 15 | ex:j a ex:C ; 16 | ex:p ex:jp . 17 | ex:jp ex:q ex:jpq . 18 | 19 | ex:s1 a sh:PropertyShape ; 20 | sh:targetClass ex:C ; 21 | sh:path [ rdf:first ex:p ; rdf:rest [ rdf:first ex:q ; rdf:rest rdf:nil ] ; 22 | sh:inversePath ( ex:p ) ] ; 23 | sh:class ex:C . 24 | 25 | <> 26 | rdf:type mf:Manifest ; 27 | mf:entries ( 28 | 29 | ) ; 30 | . 31 | 32 | 33 | rdf:type sht:Validate ; 34 | rdfs:label "Test of strange path 002 valid and invalid paths together" ; 35 | mf:action [ 36 | sht:dataGraph <> ; 37 | sht:shapesGraph <> ; 38 | ] ; 39 | mf:result [ 40 | rdf:type sh:ValidationReport ; 41 | sh:conforms "false"^^xsd:boolean ; 42 | sh:result [ a sh:ValidationResult ; 43 | sh:focusNode ex:j ; 44 | sh:value ex:jpq ; 45 | sh:resultPath ( ex:p ex:q ) ; 46 | sh:resultSeverity sh:Violation ; 47 | sh:sourceConstraintComponent sh:ClassConstraintComponent ; 48 | sh:sourceShape ex:s1 ; 49 | ] ; 50 | ] ; 51 | mf:status sht:approved ; 52 | . 53 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-unused-001-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | 3 | ex:i a ex:C . 4 | 5 | ex:j a ex:D . 6 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-unused-001-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix ex: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | 6 | ex:s1 a sh:NodeShape ; 7 | sh:targetNode ex:j, ex:i ; 8 | sh:class ex:C . 9 | 10 | _:p1 sh:inversePath _:p2 . 11 | 12 | _:p2 sh:zeroOrMorePath ( _:p2 ) . 13 | 14 | _:p2 sh:zeroOrOnePath [ rdf:rest rdf:nil ] . 15 | 16 | _:p3 sh:alternativePath ( ex:p ) ; 17 | rdfs:comment "invalid path" . 18 | 19 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-unused-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | <> a mf:Manifest ; 12 | mf:entries ( 13 | 14 | ) . 15 | 16 | a sht:Validate ; 17 | rdfs:label "Test with unused ill-formed path" ; 18 | mf:action [ 19 | sht:dataGraph ; 20 | sht:shapesGraph ] ; 21 | mf:result [ a sh:ValidationReport ; 22 | sh:conforms "false"^^xsd:boolean ; 23 | sh:result [ a sh:ValidationResult ; 24 | sh:focusNode ex:j ; 25 | sh:value ex:j ; 26 | sh:resultSeverity sh:Violation ; 27 | sh:sourceShape ex:s1 ; 28 | sh:sourceConstraintComponent sh:ClassConstraintComponent ] ] ; 29 | mf:status sht:approved . 30 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-zeroOrMore-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | rdf:type rdfs:Resource ; 13 | . 14 | ex:Person2 15 | ex:child ex:Person3 ; 16 | . 17 | ex:TestShape 18 | rdf:type sh:PropertyShape ; 19 | sh:path [ 20 | sh:zeroOrMorePath ex:child ; 21 | ] ; 22 | sh:minCount 2 ; 23 | sh:targetNode ex:InvalidResource1 ; 24 | sh:targetNode ex:ValidResource1 ; 25 | sh:targetNode ex:ValidResource2 ; 26 | . 27 | ex:ValidResource1 28 | ex:child ex:Person1 ; 29 | . 30 | ex:ValidResource2 31 | ex:child ex:Person2 ; 32 | . 33 | <> 34 | rdf:type mf:Manifest ; 35 | mf:entries ( 36 | 37 | ) ; 38 | . 39 | 40 | rdf:type sht:Validate ; 41 | rdfs:label "Test of path sh:zeroOrMorePath 001" ; 42 | mf:action [ 43 | sht:dataGraph <> ; 44 | sht:shapesGraph <> ; 45 | ] ; 46 | mf:result [ 47 | rdf:type sh:ValidationReport ; 48 | sh:conforms "false"^^xsd:boolean ; 49 | sh:result [ 50 | rdf:type sh:ValidationResult ; 51 | sh:focusNode ex:InvalidResource1 ; 52 | sh:resultPath [ 53 | sh:zeroOrMorePath ex:child ; 54 | ] ; 55 | sh:resultSeverity sh:Violation ; 56 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 57 | sh:sourceShape ex:TestShape ; 58 | ] ; 59 | ] ; 60 | mf:status sht:approved ; 61 | . 62 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/path/path-zeroOrOne-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | rdf:type rdfs:Resource ; 13 | . 14 | ex:Person2 15 | ex:child ex:Person3 ; 16 | . 17 | ex:TestShape 18 | rdf:type sh:PropertyShape ; 19 | sh:path [ 20 | sh:zeroOrOnePath ex:child ; 21 | ] ; 22 | sh:minCount 2 ; 23 | sh:targetNode ex:InvalidResource1 ; 24 | sh:targetNode ex:ValidResource1 ; 25 | sh:targetNode ex:ValidResource2 ; 26 | . 27 | ex:ValidResource1 28 | ex:child ex:Person1 ; 29 | . 30 | ex:ValidResource2 31 | ex:child ex:Person2 ; 32 | . 33 | <> 34 | rdf:type mf:Manifest ; 35 | mf:entries ( 36 | 37 | ) ; 38 | . 39 | 40 | rdf:type sht:Validate ; 41 | rdfs:label "Test of path sh:zeroOrOnePath 001" ; 42 | mf:action [ 43 | sht:dataGraph <> ; 44 | sht:shapesGraph <> ; 45 | ] ; 46 | mf:result [ 47 | rdf:type sh:ValidationReport ; 48 | sh:conforms "false"^^xsd:boolean ; 49 | sh:result [ 50 | rdf:type sh:ValidationResult ; 51 | sh:focusNode ex:InvalidResource1 ; 52 | sh:resultPath [ 53 | sh:zeroOrOnePath ex:child ; 54 | ] ; 55 | sh:resultSeverity sh:Violation ; 56 | sh:sourceConstraintComponent sh:MinCountConstraintComponent ; 57 | sh:sourceShape ex:TestShape ; 58 | ] ; 59 | ] ; 60 | mf:status sht:approved ; 61 | . 62 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/datatype-ill-formed-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix xsd: . 2 | @prefix ex: . 3 | 4 | ex:i ex:p "300"^^xsd:byte . 5 | ex:i ex:p "55"^^xsd:integer . 6 | ex:i ex:p "c"^^xsd:byte . 7 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/datatype-ill-formed-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix xsd: . 3 | @prefix ex: . 4 | 5 | ex:s a sh:PropertyShape ; 6 | sh:targetNode ex:i ; 7 | sh:path ex:p ; 8 | sh:datatype xsd:byte . 9 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/datatype-ill-formed.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | @prefix ex: . 10 | 11 | <> rdf:type mf:Manifest ; 12 | mf:entries ( 13 | 14 | ) . 15 | 16 | rdf:type sht:Validate; 17 | rdfs:label "Test of validation report for ill-formed literals" ; 18 | mf:action [ sht:dataGraph ; 19 | sht:shapesGraph ] ; 20 | mf:result [ rdf:type sh:ValidationReport ; 21 | sh:conforms "false"^^xsd:boolean ; 22 | sh:result [ rdf:type sh:ValidationResult ; 23 | sh:resultSeverity sh:Violation ; 24 | sh:focusNode ex:i ; 25 | sh:value "300"^^xsd:byte ; 26 | sh:resultPath ex:p ; 27 | sh:sourceShape ex:s ; 28 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ] ; 29 | sh:result [ rdf:type sh:ValidationResult ; 30 | sh:resultSeverity sh:Violation ; 31 | sh:focusNode ex:i ; 32 | sh:value "c"^^xsd:byte ; 33 | sh:resultPath ex:p ; 34 | sh:sourceShape ex:s ; 35 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ] ; 36 | sh:result [ rdf:type sh:ValidationResult ; 37 | sh:resultSeverity sh:Violation ; 38 | sh:focusNode ex:i ; 39 | sh:value "55"^^xsd:integer ; 40 | sh:resultPath ex:p ; 41 | sh:sourceShape ex:s ; 42 | sh:sourceConstraintComponent sh:DatatypeConstraintComponent ] ] ; 43 | mf:status sht:approved . 44 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/property" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | mf:include ; 15 | mf:include ; 16 | mf:include ; 17 | mf:include ; 18 | mf:include ; 19 | mf:include ; 20 | mf:include ; 21 | mf:include ; 22 | mf:include ; 23 | mf:include ; 24 | mf:include ; 25 | mf:include ; 26 | mf:include ; 27 | mf:include ; 28 | mf:include ; 29 | mf:include ; 30 | mf:include ; 31 | mf:include ; 32 | mf:include ; 33 | mf:include ; 34 | mf:include ; 35 | mf:include ; 36 | mf:include ; 37 | mf:include ; 38 | mf:include ; 39 | mf:include ; 40 | mf:include ; 41 | mf:include ; 42 | mf:include ; 43 | mf:include ; 44 | mf:include ; 45 | mf:include ; 46 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/maxCount-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource 12 | rdf:type rdfs:Resource ; 13 | rdfs:label "Invalid resource" ; 14 | owl:versionInfo "1.0" ; 15 | . 16 | ex:TestShape 17 | rdf:type sh:NodeShape ; 18 | rdfs:label "Test shape" ; 19 | sh:property ex:TestShape-versionInfo ; 20 | sh:targetNode ex:InvalidResource ; 21 | sh:targetNode ex:ValidResource ; 22 | . 23 | ex:TestShape-versionInfo 24 | sh:path owl:versionInfo ; 25 | sh:maxCount 0 ; 26 | . 27 | ex:ValidResource 28 | rdf:type rdfs:Resource ; 29 | rdfs:label "Valid resource" ; 30 | . 31 | <> 32 | rdf:type mf:Manifest ; 33 | mf:entries ( 34 | 35 | ) ; 36 | . 37 | 38 | rdf:type sht:Validate ; 39 | rdfs:label "Test of sh:maxCount at property shape 002" ; 40 | mf:action [ 41 | sht:dataGraph <> ; 42 | sht:shapesGraph <> ; 43 | ] ; 44 | mf:result [ 45 | rdf:type sh:ValidationReport ; 46 | sh:conforms "false"^^xsd:boolean ; 47 | sh:result [ 48 | rdf:type sh:ValidationResult ; 49 | sh:focusNode ex:InvalidResource ; 50 | sh:resultPath owl:versionInfo ; 51 | sh:resultSeverity sh:Violation ; 52 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 53 | sh:sourceShape ex:TestShape-versionInfo ; 54 | ] ; 55 | ] ; 56 | mf:status sht:approved ; 57 | . 58 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/maxLength-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | rdf:type ex:TestShape ; 13 | ex:testProperty "ABC" ; 14 | . 15 | ex:TestShape 16 | rdf:type rdfs:Class ; 17 | rdf:type sh:NodeShape ; 18 | rdfs:label "Test shape" ; 19 | sh:property ex:TestShape-testProperty ; 20 | . 21 | ex:TestShape-testProperty 22 | sh:path ex:testProperty ; 23 | sh:datatype xsd:string ; 24 | sh:maxLength 2 ; 25 | . 26 | ex:ValidInstance1 27 | rdf:type ex:TestShape ; 28 | ex:testProperty "A" ; 29 | ex:testProperty "AB" ; 30 | . 31 | ex:ValidInstance2 32 | rdf:type ex:TestShape ; 33 | . 34 | <> 35 | rdf:type mf:Manifest ; 36 | mf:entries ( 37 | 38 | ) ; 39 | . 40 | 41 | rdf:type sht:Validate ; 42 | rdfs:label "Test of sh:maxLength at property shape 001" ; 43 | mf:action [ 44 | sht:dataGraph <> ; 45 | sht:shapesGraph <> ; 46 | ] ; 47 | mf:result [ 48 | rdf:type sh:ValidationReport ; 49 | sh:conforms "false"^^xsd:boolean ; 50 | sh:result [ 51 | rdf:type sh:ValidationResult ; 52 | sh:focusNode ex:InvalidInstance1 ; 53 | sh:resultPath ex:testProperty ; 54 | sh:resultSeverity sh:Violation ; 55 | sh:sourceConstraintComponent sh:MaxLengthConstraintComponent ; 56 | sh:sourceShape ex:TestShape-testProperty ; 57 | sh:value "ABC" ; 58 | ] ; 59 | ] ; 60 | mf:status sht:approved ; 61 | . 62 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/minCount-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:TestShape 12 | rdf:type sh:NodeShape ; 13 | sh:property [ 14 | sh:path ex:property ; 15 | sh:minCount 0 ; 16 | sh:name "property" ; 17 | ] ; 18 | sh:targetNode ex:ValidResource1 ; 19 | . 20 | ex:ValidResource1 21 | rdf:type rdfs:Resource ; 22 | . 23 | <> 24 | rdf:type mf:Manifest ; 25 | mf:entries ( 26 | 27 | ) ; 28 | . 29 | 30 | rdf:type sht:Validate ; 31 | rdfs:label "Test of sh:minCount at property shape 001" ; 32 | mf:action [ 33 | sht:dataGraph <> ; 34 | sht:shapesGraph <> ; 35 | ] ; 36 | mf:result [ 37 | rdf:type sh:ValidationReport ; 38 | sh:conforms "true"^^xsd:boolean ; 39 | ] ; 40 | mf:status sht:approved ; 41 | . 42 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/minLength-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | rdf:type ex:TestShape ; 13 | ex:testProperty "A" ; 14 | . 15 | ex:TestShape 16 | rdf:type rdfs:Class ; 17 | rdf:type sh:NodeShape ; 18 | rdfs:label "Test shape" ; 19 | sh:property ex:TestShape-testProperty ; 20 | . 21 | ex:TestShape-testProperty 22 | sh:path ex:testProperty ; 23 | sh:datatype xsd:string ; 24 | sh:minLength 2 ; 25 | . 26 | ex:ValidInstance1 27 | rdf:type ex:TestShape ; 28 | ex:testProperty "AB" ; 29 | ex:testProperty "ABC" ; 30 | . 31 | ex:ValidInstance2 32 | rdf:type ex:TestShape ; 33 | . 34 | <> 35 | rdf:type mf:Manifest ; 36 | mf:entries ( 37 | 38 | ) ; 39 | . 40 | 41 | rdf:type sht:Validate ; 42 | rdfs:label "Test of sh:minLength at property shape 001" ; 43 | mf:action [ 44 | sht:dataGraph <> ; 45 | sht:shapesGraph <> ; 46 | ] ; 47 | mf:result [ 48 | rdf:type sh:ValidationReport ; 49 | sh:conforms "false"^^xsd:boolean ; 50 | sh:result [ 51 | rdf:type sh:ValidationResult ; 52 | sh:focusNode ex:InvalidInstance1 ; 53 | sh:resultPath ex:testProperty ; 54 | sh:resultSeverity sh:Violation ; 55 | sh:sourceConstraintComponent sh:MinLengthConstraintComponent ; 56 | sh:sourceShape ex:TestShape-testProperty ; 57 | sh:value "A" ; 58 | ] ; 59 | ] ; 60 | mf:status sht:approved ; 61 | . 62 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/uniqueLang-002-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | 3 | ex:i ex:message "HI"@en, "Hi"@en . 4 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/uniqueLang-002-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix ex: . 3 | @prefix xsd: . 4 | 5 | ex:s1 a sh:PropertyShape ; 6 | sh:targetNode ex:i ; 7 | sh:path ex:message ; 8 | sh:uniqueLang "1"^^xsd:boolean . 9 | 10 | # Note that the value above is "1"^^xsd:boolean, which is distinct from "true"^^xsd:boolean. 11 | # Only true is mentioned in the spec, meaning that "1" will not activate the constraint 12 | # and the constraint is being ignored. 13 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/property/uniqueLang-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | <> a mf:Manifest ; 12 | mf:entries ( 13 | 14 | ) . 15 | 16 | a sht:Validate ; 17 | rdfs:label "Test uniqueLang with other boolean literal for true" ; 18 | mf:action [ 19 | sht:dataGraph ; 20 | sht:shapesGraph ] ; 21 | mf:result [ a sh:ValidationReport ; 22 | sh:conforms "true"^^xsd:boolean ] ; 23 | mf:status sht:approved . 24 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/core/targets" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | mf:include ; 15 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/multipleTargets-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | ex:property1 "Also a value" ; 13 | . 14 | ex:TestShape 15 | rdf:type sh:NodeShape ; 16 | rdfs:label "Test shape" ; 17 | sh:in ( 18 | ex:ValidResource1 19 | ex:ValidResource2 20 | ) ; 21 | sh:targetSubjectsOf ex:property1 ; 22 | sh:targetSubjectsOf ex:property2 ; 23 | . 24 | ex:ValidResource1 25 | ex:property1 "Some value" ; 26 | . 27 | ex:ValidResource2 28 | ex:property2 "Other value" ; 29 | . 30 | <> 31 | rdf:type mf:Manifest ; 32 | mf:entries ( 33 | 34 | ) ; 35 | . 36 | 37 | rdf:type sht:Validate ; 38 | rdfs:label "Test of multiple targets 001" ; 39 | mf:action [ 40 | sht:dataGraph <> ; 41 | sht:shapesGraph <> ; 42 | ] ; 43 | mf:result [ 44 | rdf:type sh:ValidationReport ; 45 | sh:conforms "false"^^xsd:boolean ; 46 | sh:result [ 47 | rdf:type sh:ValidationResult ; 48 | sh:focusNode ex:InvalidResource1 ; 49 | sh:resultSeverity sh:Violation ; 50 | sh:sourceConstraintComponent sh:InConstraintComponent ; 51 | sh:sourceShape ex:TestShape ; 52 | sh:value ex:InvalidResource1 ; 53 | ] ; 54 | ] ; 55 | mf:status sht:approved ; 56 | . 57 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/targetClass-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | rdf:type ex:MyClass ; 13 | ex:myProperty "A" ; 14 | ex:myProperty "B" ; 15 | . 16 | ex:MyClass 17 | rdf:type rdfs:Class ; 18 | . 19 | ex:MyShape 20 | rdf:type sh:NodeShape ; 21 | sh:property ex:MyShape-myProperty ; 22 | sh:targetClass ex:MyClass ; 23 | . 24 | ex:MyShape-myProperty 25 | sh:path ex:myProperty ; 26 | sh:maxCount 1 ; 27 | . 28 | ex:ValidInstance1 29 | rdf:type ex:MyClass ; 30 | ex:myProperty "A" ; 31 | . 32 | ex:ValidInstance2 33 | ex:myProperty "A" ; 34 | ex:myProperty "B" ; 35 | . 36 | <> 37 | rdf:type mf:Manifest ; 38 | mf:entries ( 39 | 40 | ) ; 41 | . 42 | 43 | rdf:type sht:Validate ; 44 | rdfs:label "Test of sh:targetClass 001" ; 45 | mf:action [ 46 | sht:dataGraph <> ; 47 | sht:shapesGraph <> ; 48 | ] ; 49 | mf:result [ 50 | rdf:type sh:ValidationReport ; 51 | sh:conforms "false"^^xsd:boolean ; 52 | sh:result [ 53 | rdf:type sh:ValidationResult ; 54 | sh:focusNode ex:InvalidInstance1 ; 55 | sh:resultPath ex:myProperty ; 56 | sh:resultSeverity sh:Violation ; 57 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 58 | sh:sourceShape ex:MyShape-myProperty ; 59 | ] ; 60 | ] ; 61 | mf:status sht:approved ; 62 | . 63 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/targetClassImplicit-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance 12 | rdf:type ex:SubClass ; 13 | rdfs:label "Invalid instance" ; 14 | . 15 | ex:SubClass 16 | rdf:type rdfs:Class ; 17 | rdfs:label "Sub class" ; 18 | rdfs:subClassOf ex:SuperClass ; 19 | . 20 | ex:SuperClass 21 | rdf:type rdfs:Class ; 22 | rdf:type sh:NodeShape ; 23 | rdfs:label "Super class" ; 24 | sh:in ( 25 | ex:ValidInstance 26 | ) ; 27 | . 28 | ex:ValidInstance 29 | rdf:type ex:SubClass ; 30 | rdfs:label "Valid instance" ; 31 | . 32 | <> 33 | rdf:type mf:Manifest ; 34 | mf:entries ( 35 | 36 | ) ; 37 | . 38 | 39 | rdf:type sht:Validate ; 40 | rdfs:label "Test of implicit sh:targetClass 001" ; 41 | mf:action [ 42 | sht:dataGraph <> ; 43 | sht:shapesGraph <> ; 44 | ] ; 45 | mf:result [ 46 | rdf:type sh:ValidationReport ; 47 | sh:conforms "false"^^xsd:boolean ; 48 | sh:result [ 49 | rdf:type sh:ValidationResult ; 50 | sh:focusNode ex:InvalidInstance ; 51 | sh:resultSeverity sh:Violation ; 52 | sh:sourceConstraintComponent sh:InConstraintComponent ; 53 | sh:sourceShape ex:SuperClass ; 54 | sh:value ex:InvalidInstance ; 55 | ] ; 56 | ] ; 57 | mf:status sht:approved ; 58 | . 59 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/targetNode-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidResource1 12 | rdf:type rdfs:Resource ; 13 | rdfs:label "Invalid resource 1" ; 14 | . 15 | ex:TestShape 16 | rdf:type sh:NodeShape ; 17 | rdfs:label "Test shape" ; 18 | sh:property ex:TestShape-label ; 19 | sh:targetNode ex:InvalidResource1 ; 20 | sh:targetNode ex:ValidResource1 ; 21 | . 22 | ex:TestShape-label 23 | sh:path rdfs:label ; 24 | rdfs:label "label" ; 25 | sh:datatype xsd:string ; 26 | sh:maxCount 0 ; 27 | . 28 | ex:ValidResource1 29 | rdf:type rdfs:Resource ; 30 | . 31 | <> 32 | rdf:type mf:Manifest ; 33 | mf:entries ( 34 | 35 | ) ; 36 | . 37 | 38 | rdf:type sht:Validate ; 39 | rdfs:label "Test of sh:targetNode 001" ; 40 | mf:action [ 41 | sht:dataGraph <> ; 42 | sht:shapesGraph <> ; 43 | ] ; 44 | mf:result [ 45 | rdf:type sh:ValidationReport ; 46 | sh:conforms "false"^^xsd:boolean ; 47 | sh:result [ 48 | rdf:type sh:ValidationResult ; 49 | sh:focusNode ex:InvalidResource1 ; 50 | sh:resultPath rdfs:label ; 51 | sh:resultSeverity sh:Violation ; 52 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 53 | sh:sourceShape ex:TestShape-label ; 54 | ] ; 55 | ] ; 56 | mf:status sht:approved ; 57 | . 58 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/targets/targetSubjectsOf-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex:InvalidInstance1 12 | ex:myProperty "A" ; 13 | ex:myProperty "B" ; 14 | . 15 | ex:MyClass 16 | rdf:type rdfs:Class ; 17 | . 18 | ex:TestShape 19 | rdf:type sh:NodeShape ; 20 | sh:property ex:TestShape-myProperty ; 21 | sh:targetSubjectsOf ex:myProperty ; 22 | . 23 | ex:TestShape-myProperty 24 | rdf:type sh:PropertyShape ; 25 | sh:path ex:myProperty ; 26 | sh:maxCount 1 ; 27 | . 28 | ex:ValidInstance1 29 | ex:myProperty "A" ; 30 | . 31 | <> 32 | rdf:type mf:Manifest ; 33 | mf:entries ( 34 | 35 | ) ; 36 | . 37 | 38 | rdf:type sht:Validate ; 39 | rdfs:label "Test of sh:targetSubjectsOf 001" ; 40 | mf:action [ 41 | sht:dataGraph <> ; 42 | sht:shapesGraph <> ; 43 | ] ; 44 | mf:result [ 45 | rdf:type sh:ValidationReport ; 46 | sh:conforms "false"^^xsd:boolean ; 47 | sh:result [ 48 | rdf:type sh:ValidationResult ; 49 | sh:focusNode ex:InvalidInstance1 ; 50 | sh:resultPath ex:myProperty ; 51 | sh:resultSeverity sh:Violation ; 52 | sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; 53 | sh:sourceShape ex:TestShape-myProperty ; 54 | ] ; 55 | ] ; 56 | mf:status sht:approved ; 57 | . 58 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/validation-reports/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests for validation reports" ; 8 | mf:include ; 9 | . 10 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/validation-reports/shared-data.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | ex:i ex:p ex:j . 3 | ex:i ex:q ex:j . 4 | ex:j ex:r ex:k . 5 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/validation-reports/shared-shapes.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix ex: . 3 | 4 | ex:s1 a sh:NodeShape ; 5 | sh:targetNode ex:i ; 6 | sh:property ex:s2 ; 7 | sh:property ex:s3 . 8 | 9 | ex:s2 sh:path ex:p ; 10 | sh:property ex:s4 . 11 | 12 | ex:s3 sh:path ex:q ; 13 | sh:property ex:s4 . 14 | 15 | ex:s4 sh:path ex:r ; 16 | sh:class ex:C . 17 | -------------------------------------------------------------------------------- /test/resources/sht_tests/core/validation-reports/shared.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix rdfs: . 5 | @prefix sh: . 6 | @prefix sht: . 7 | @prefix xsd: . 8 | 9 | @prefix ex: . 10 | 11 | # This test case is under discussion, as there are different interpretations 12 | # on whether the nested sh:property constraint that is reached twice should 13 | # also be reported twice. 14 | 15 | <> 16 | rdf:type mf:Manifest ; 17 | mf:entries ( 18 | 19 | ) ; 20 | . 21 | 22 | 23 | rdf:type sht:Validate; 24 | rdfs:label "Test of validation report for shape shared by property constraints" ; 25 | mf:action [ 26 | sht:dataGraph ; 27 | sht:shapesGraph 28 | ] ; 29 | mf:result [ 30 | rdf:type sh:ValidationReport ; 31 | sh:conforms "false"^^xsd:boolean ; 32 | sh:result [ 33 | rdf:type sh:ValidationResult ; 34 | sh:resultSeverity sh:Violation ; 35 | sh:focusNode ex:j ; 36 | sh:value ex:k ; 37 | sh:resultPath ex:r ; 38 | sh:sourceShape ex:s4 ; 39 | sh:sourceConstraintComponent sh:ClassConstraintComponent 40 | ] ; 41 | sh:result [ 42 | rdf:type sh:ValidationResult ; 43 | sh:resultSeverity sh:Violation ; 44 | sh:focusNode ex:j ; 45 | sh:value ex:k ; 46 | sh:resultPath ex:r ; 47 | sh:sourceShape ex:s4 ; 48 | sh:sourceConstraintComponent sh:ClassConstraintComponent 49 | ] 50 | ] ; 51 | mf:status sht:approved . 52 | -------------------------------------------------------------------------------- /test/resources/sht_tests/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | mf:include ; 8 | mf:include ; 9 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/component/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/sparql/component" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | mf:include ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | . 12 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/node/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/sparql/node" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | . -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests for pre-binding" ; 8 | mf:include ; 9 | mf:include ; 10 | mf:include ; 11 | mf:include ; 12 | mf:include ; 13 | mf:include ; 14 | mf:include ; 15 | mf:include ; 16 | mf:include ; 17 | mf:include ; 18 | mf:include ; 19 | mf:include ; 20 | mf:include ; 21 | mf:include ; 22 | . 23 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/pre-binding-006.ttl: -------------------------------------------------------------------------------- 1 | @prefix dash: . 2 | @prefix ex: . 3 | @prefix mf: . 4 | @prefix owl: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix sht: . 9 | @prefix xsd: . 10 | 11 | ex: 12 | sh:declare [ 13 | sh:prefix "ex" ; 14 | sh:namespace "http://datashapes.org/sh/tests/sparql/pre-binding/pre-binding-006.test#"^^xsd:anyURI ; 15 | ] . 16 | 17 | ex:TestShape 18 | rdf:type sh:NodeShape ; 19 | rdfs:label "Test shape" ; 20 | sh:sparql ex:TestShape-sparql ; 21 | sh:targetNode ex:InvalidResource ; 22 | . 23 | ex:TestShape-sparql 24 | sh:prefixes ex: ; 25 | sh:select """ 26 | SELECT $this 27 | WHERE { 28 | { 29 | SELECT * 30 | WHERE { 31 | FILTER ($this = ex:InvalidResource) . 32 | } 33 | } 34 | }""" ; 35 | . 36 | ex:ValidResource1 37 | rdf:type rdfs:Resource ; 38 | . 39 | <> 40 | rdf:type mf:Manifest ; 41 | mf:entries ( 42 | 43 | ) ; 44 | . 45 | 46 | rdf:type sht:Validate ; 47 | rdfs:label "Test of pre-binding in nested SELECT" ; 48 | mf:action [ 49 | sht:dataGraph <> ; 50 | sht:shapesGraph <> ; 51 | ] ; 52 | mf:result sht:Failure ; 53 | mf:status sht:approved ; 54 | . 55 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/unsupported-sparql-001.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix sh: . 7 | @prefix sht: . 8 | @prefix xsd: . 9 | 10 | <> 11 | rdf:type mf:Manifest ; 12 | mf:entries ( ) . 13 | 14 | 15 | rdf:type sht:Validate ; 16 | rdfs:label "Test of unsupported MINUS" ; 17 | mf:action [ 18 | sht:dataGraph <> ; 19 | sht:shapesGraph <> ; 20 | ] ; 21 | mf:result sht:Failure ; 22 | mf:status sht:approved . 23 | 24 | ex:TestShape 25 | a sh:NodeShape ; 26 | sh:targetNode ex:InvalidResource ; 27 | sh:sparql [ 28 | sh:select """ 29 | SELECT $this 30 | WHERE { 31 | $this ?x ?any . 32 | MINUS { $this ?x "Value" } 33 | }""" ; 34 | ] . 35 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/unsupported-sparql-002.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix sh: . 7 | @prefix sht: . 8 | @prefix xsd: . 9 | 10 | <> 11 | rdf:type mf:Manifest ; 12 | mf:entries ( ) . 13 | 14 | 15 | rdf:type sht:Validate ; 16 | rdfs:label "Test of unsupported VALUES" ; 17 | mf:action [ 18 | sht:dataGraph <> ; 19 | sht:shapesGraph <> ; 20 | ] ; 21 | mf:result sht:Failure ; 22 | mf:status sht:approved . 23 | 24 | ex:TestShape 25 | a sh:NodeShape ; 26 | sh:targetNode ex:InvalidResource ; 27 | sh:sparql [ 28 | sh:select """ 29 | SELECT $this 30 | WHERE { 31 | VALUES ?any { true } 32 | }""" ; 33 | ] . 34 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/unsupported-sparql-003.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix sh: . 7 | @prefix sht: . 8 | @prefix xsd: . 9 | 10 | <> 11 | rdf:type mf:Manifest ; 12 | mf:entries ( ) . 13 | 14 | 15 | rdf:type sht:Validate ; 16 | rdfs:label "Test of unsupported SERVICE" ; 17 | mf:action [ 18 | sht:dataGraph <> ; 19 | sht:shapesGraph <> ; 20 | ] ; 21 | mf:result sht:Failure ; 22 | mf:status sht:approved . 23 | 24 | ex:TestShape 25 | a sh:NodeShape ; 26 | sh:targetNode ex:InvalidResource ; 27 | sh:sparql [ 28 | sh:select """ 29 | SELECT $this 30 | WHERE { 31 | $this ?x ?any . 32 | SERVICE { 33 | ?a ?b ?c . 34 | } 35 | }""" ; 36 | ] . 37 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/unsupported-sparql-004.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix sh: . 7 | @prefix sht: . 8 | @prefix xsd: . 9 | 10 | <> 11 | rdf:type mf:Manifest ; 12 | mf:entries ( ) . 13 | 14 | 15 | rdf:type sht:Validate ; 16 | rdfs:label "Test of unsupported SELECT" ; 17 | mf:action [ 18 | sht:dataGraph <> ; 19 | sht:shapesGraph <> ; 20 | ] ; 21 | mf:result sht:Failure ; 22 | mf:status sht:approved . 23 | 24 | ex:TestShape 25 | a sh:NodeShape ; 26 | sh:targetNode ex:InvalidResource ; 27 | sh:sparql [ 28 | sh:select """ 29 | SELECT $this 30 | WHERE { 31 | $this ?x ?any . 32 | { 33 | SELECT ?other ?b 34 | WHERE { 35 | ?other ?b ?c . 36 | } 37 | } 38 | }""" ; 39 | ] . 40 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/pre-binding/unsupported-sparql-005.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | @prefix mf: . 3 | @prefix owl: . 4 | @prefix rdf: . 5 | @prefix rdfs: . 6 | @prefix sh: . 7 | @prefix sht: . 8 | @prefix xsd: . 9 | 10 | <> 11 | rdf:type mf:Manifest ; 12 | mf:entries ( ) . 13 | 14 | 15 | rdf:type sht:Validate ; 16 | rdfs:label "Test of unsupported AS ?prebound" ; 17 | mf:action [ 18 | sht:dataGraph <> ; 19 | sht:shapesGraph <> ; 20 | ] ; 21 | mf:result sht:Failure ; 22 | mf:status sht:approved . 23 | 24 | ex:TestShape 25 | a sh:NodeShape ; 26 | sh:targetNode ex:InvalidResource ; 27 | sh:sparql [ 28 | sh:select """ 29 | SELECT $this 30 | WHERE { 31 | BIND (true AS $this) . 32 | }""" ; 33 | ] . 34 | -------------------------------------------------------------------------------- /test/resources/sht_tests/sparql/property/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix mf: . 2 | @prefix rdfs: . 3 | @prefix sht: . 4 | 5 | <> 6 | a mf:Manifest ; 7 | rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/sparql/property" ; 8 | mf:include ; 9 | . -------------------------------------------------------------------------------- /test/test_js/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFLib/pySHACL/98c3304acef48d086b16f9371d5980917cf5fc51/test/test_js/__init__.py -------------------------------------------------------------------------------- /test/test_js/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from pyshacl import extras 3 | 4 | 5 | def pytest_runtest_setup(item): 6 | extras.dev_mode = True 7 | 8 | 9 | def pytest_runtest_teardown(item, call=None): 10 | extras.dev_mode = False 11 | -------------------------------------------------------------------------------- /test/test_js/test_js_constraint.py: -------------------------------------------------------------------------------- 1 | from rdflib import Graph 2 | from pyshacl import validate, extras 3 | 4 | shapes_graph = '''\ 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix xsd: . 9 | @prefix ex: . 10 | 11 | ex:LanguageExampleShape 12 | a sh:NodeShape ; 13 | sh:targetClass ex:Country ; 14 | sh:js [ 15 | a sh:JSConstraint ; 16 | sh:message "Values are literals with German language tag." ; 17 | sh:jsLibrary [ sh:jsLibraryURL "file:./test/resources/js/germanLabel.js" ] ; 18 | sh:jsFunctionName "validateGermanLabel" ; 19 | ] . 20 | ''' 21 | 22 | data_graph = '''\ 23 | @prefix rdf: . 24 | @prefix rdfs: . 25 | @prefix xsd: . 26 | @prefix ex: . 27 | 28 | ex:ValidCountry a ex:Country ; 29 | ex:germanLabel "Spanien"@de . 30 | 31 | ex:InvalidCountry a ex:Country ; 32 | ex:germanLabel "Spain"@en . 33 | ''' 34 | 35 | extras.dev_mode = True 36 | 37 | 38 | def test_js_constraint(): 39 | s1 = Graph().parse(data=shapes_graph, format="turtle") 40 | g1 = Graph().parse(data=data_graph, format="turtle") 41 | conforms, result_graph, result_text = validate(g1, shacl_graph=s1, advanced=True, debug=True, js=True) 42 | assert not conforms 43 | 44 | 45 | if __name__ == "__main__": 46 | test_js_constraint() 47 | -------------------------------------------------------------------------------- /test/test_js/test_js_rules.py: -------------------------------------------------------------------------------- 1 | from rdflib import Graph 2 | from pyshacl import validate 3 | 4 | shapes_graph = '''\ 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix sh: . 8 | @prefix xsd: . 9 | @prefix ex: . 10 | 11 | ex:RectangleShape 12 | a sh:NodeShape ; 13 | sh:targetClass ex:Rectangle ; 14 | sh:rule [ 15 | a sh:JSRule ; # This triple is optional 16 | sh:jsFunctionName "computeArea" ; 17 | sh:jsLibrary [ sh:jsLibraryURL "file:./test/resources/js/rectangle.js"^^xsd:anyURI ] ; 18 | ] ; 19 | sh:property [ 20 | sh:path ex:area ; 21 | sh:datatype xsd:double ; 22 | sh:minCount 1 ; 23 | sh:maxCount 1 ; 24 | ] . 25 | ''' 26 | 27 | data_graph = '''\ 28 | @prefix rdf: . 29 | @prefix rdfs: . 30 | @prefix xsd: . 31 | @prefix ex: . 32 | @prefix exdata: . 33 | 34 | exdata:ExampleRectangle 35 | a ex:Rectangle ; 36 | ex:width 7 ; 37 | ex:height 8 . 38 | ''' 39 | 40 | 41 | def test_js_rules(): 42 | s1 = Graph().parse(data=shapes_graph, format="turtle") 43 | g1 = Graph().parse(data=data_graph, format="turtle") 44 | conforms, result_graph, result_text = validate(g1, shacl_graph=s1, advanced=True, debug=True, js=True) 45 | assert not conforms 46 | 47 | 48 | if __name__ == "__main__": 49 | test_js_rules() 50 | -------------------------------------------------------------------------------- /test/test_schema_org.py: -------------------------------------------------------------------------------- 1 | from pyshacl import validate 2 | import rdflib 3 | 4 | SCHEMA_PATH = "http://datashapes.org/schema.ttl" 5 | 6 | data = """\ 7 | @prefix ex: . 8 | @prefix sch: . 9 | @prefix xsd: . 10 | 11 | ex:asdgjkj a sch:CommunicateAction ; 12 | sch:about [ a sch:GameServer ; 13 | sch:playersOnline "42"^^xsd:integer ] . 14 | """ 15 | 16 | shacl = """\ 17 | # baseURI: http://example.org/myschema 18 | # imports: http://datashapes.org/schema 19 | 20 | @prefix owl: . 21 | @prefix rdf: . 22 | @prefix rdfs: . 23 | @prefix schema: . 24 | @prefix sh: . 25 | @prefix xsd: . 26 | @prefix : . 27 | 28 | 29 | a owl:Ontology ; 30 | rdfs:comment "Dummy Schema importing from Schema.org shape"@en ; 31 | rdfs:label "Schema.org importer" ; 32 | owl:imports . 33 | """ 34 | 35 | 36 | def schema_org(): 37 | dataGraph = rdflib.Graph().parse(data=data, format='ttl') 38 | # print(dataGraph.serialize(format='ttl').decode('utf8')) 39 | 40 | shaclDS = rdflib.Dataset() 41 | shaclGraph = shaclDS.default_context 42 | shaclDS.graph(shaclGraph) 43 | shaclGraph.parse(data=shacl, format='ttl') 44 | 45 | report = validate( 46 | dataGraph, 47 | shacl_graph=shaclDS, 48 | abort_on_first=False, 49 | inference='both', 50 | meta_shacl=False, 51 | debug=False, 52 | advanced=True, 53 | do_owl_imports=True, 54 | ) 55 | 56 | print(report[2]) 57 | 58 | 59 | if __name__ == "__main__": 60 | schema_org() 61 | -------------------------------------------------------------------------------- /test/test_sh_details.py: -------------------------------------------------------------------------------- 1 | import pyshacl 2 | from rdflib.namespace import SH 3 | 4 | 5 | test_node_ttl = """\ 6 | @prefix rdfs: . 7 | @prefix rdf: . 8 | @prefix sh: . 9 | @prefix xsd: . 10 | @prefix ex: . 11 | 12 | 13 | ex:PersonShape 14 | a sh:NodeShape ; 15 | sh:targetClass ex:Person ; 16 | sh:node ex:Shape1 ; 17 | . 18 | 19 | ex:Shape1 20 | a sh:NodeShape ; 21 | sh:node ex:Shape2 ; 22 | sh:property [ 23 | a sh:PropertyShape ; 24 | sh:path ex:familyName ; 25 | sh:datatype xsd:string ; 26 | sh:minCount 1 ; 27 | ] ; 28 | . 29 | 30 | ex:Shape2 31 | a sh:NodeShape ; 32 | sh:property [ 33 | a sh:PropertyShape ; 34 | sh:path ex:givenName ; 35 | sh:datatype xsd:string ; 36 | sh:minCount 1 ; 37 | ] ; 38 | . 39 | 40 | ex:Person1 41 | a ex:Person ; 42 | . 43 | """ 44 | 45 | 46 | def test_node_details(): 47 | conforms, graph, text = pyshacl.validate(test_node_ttl, data_graph_format="turtle") 48 | assert not conforms 49 | top_results = set(graph.objects(None, SH.result)) 50 | assert len(top_results) == 1 51 | top_result = top_results.pop() 52 | details = set(graph.objects(top_result, SH.detail)) 53 | assert len(details) == 2 54 | for r in details: 55 | details = set(graph.objects(r, SH.detail)) 56 | if len(details) == 0: 57 | source_1 = r 58 | elif len(details) == 1: 59 | mid_result = r 60 | assert source_1 61 | assert mid_result 62 | assert (source_1, SH.sourceConstraintComponent, SH.MinCountConstraintComponent) in graph 63 | assert (mid_result, SH.detail / SH.sourceConstraintComponent, SH.MinCountConstraintComponent) in graph 64 | --------------------------------------------------------------------------------