# Validating Shacl Constraints over a Sparql Endpoint
Canonical: https://social-archive.org/arc/RbMRdMHa7m
Original URL: https://link.springer.com/chapter/10.1007/978-3-030-30793-6_9
Author: Julien Corman, Fernando Florenzano, Juan L. Reutter, Ognjen Savković
Platform: web
Share mode: full
## Content
## Abstract shacl (Shapes Constraint Language) is a specification for describing and validating RDF graphs that has recently become a W3C recommendation. While the language is gaining traction in the industry, algorithms for shacl constraint validation are still at an early stage. A first challenge comes from the fact that RDF graphs are often exposed as sparql endpoints, and therefore only accessible via queries. Another difficulty is the absence of guidelines about the way recursive constraints should be handled. In this paper, we provide algorithms for validating a graph against a shacl schema, which can be executed over a sparql endpoint. We first investigate the possibility of validating a graph through a single query for non-recursive constraints. Then for the recursive case, since the problem has been shown to be NP-hard, we propose a strategy that consists in evaluating a small number of sparql queries over the endpoint, and using the answers to build a set of propositional formulas that are passed to a SAT solver. Finally, we show that the process can be optimized when dealing with recursive but tractable fragments of shacl, without the need for an external solver. We also present a proof-of-concept evaluation of this last approach. This is a preview of subscription content, [log in via an institution](https://wayf.springernature.com/?redirect_uri=https%3A%2F%2Flink.springer.com%2Fchapter%2F10.1007%2F978-3-030-30793-6_9%3Ferror%3Dcookies_not_supported%26code%3D0231c810-7858-4e62-838d-c6d0b0800f20) to check access. ## Access this chapter [Log in via an institution](https://wayf.springernature.com/?redirect_uri=https%3A%2F%2Flink.springer.com%2Fchapter%2F10.1007%2F978-3-030-30793-6_9%3Ferror%3Dcookies_not_supported%26code%3D0231c810-7858-4e62-838d-c6d0b0800f20) [Institutional subscriptions](https://www.springernature.com/gp/librarians/licensing/agc/ebooks) ## Notes 1. 1.[https://www.w3.org/TR/shacl/](https://www.w3.org/TR/shacl/). 2. 2.[https://w3c.github.io/data-shapes/data-shapes-test-suite/](https://w3c.github.io/data-shapes/data-shapes-test-suite/). 3. 3.with the exception of *Shaclex* [[4](#fn:4)], which can handle recursion, but not recursion and negation together in a principled way. 4. 4.More exactly, *I* is an abstraction, standing for any syntactic constraint over an rdf term: exact value, datatype, regex, etc. 5. 5.shacl paths are built like sparql property paths, but without the *NegatedPropertySet* operator. 6. 6.We omit the trivial FILTER (?y1 =?y1 AND?y2 =?y2) for readability. 7. 7.For some normalized schemas, it could happen that \([\![q_{{{\,\mathrm{def}\,}}(s)} ]\!]^{\mathcal {G}}\) always retrieves all nodes from \(\mathcal {G} \). This would be the case for example if \({{\,\mathrm{def}\,}}(s) = s_1 \wedge s_2\). A simple optimization technique here consists in not executing such queries, and instantiate instead the rule pattern \(p_{{{\,\mathrm{def}\,}}(s)}\) with all nodes retrieved by all other queries (and bound to variable?x). ## References ## Editor information ### Editors and Affiliations ## Rights and permissions ## About this paper ### Cite this paper Corman, J., Florenzano, F., Reutter, J.L., Savković, O. (2019). Validating Shacl Constraints over a Sparql Endpoint. In: Ghidini, C., *et al.* The Semantic Web – ISWC 2019. ISWC 2019. Lecture Notes in Computer Science(), vol 11778. Springer, Cham. https://doi.org/10.1007/978-3-030-30793-6_9 - [.RIS](https://citation-needed.springer.com/v2/references/10.1007/978-3-030-30793-6_9?format=refman&flavour=citation) - [.ENW](https://citation-needed.springer.com/v2/references/10.1007/978-3-030-30793-6_9?format=endnote&flavour=citation) - [.BIB](https://citation-needed.springer.com/v2/references/10.1007/978-3-030-30793-6_9?format=bibtex&flavour=citation) - DOI https://doi.org/10.1007/978-3-030-30793-6_9 - Published 17 October 2019 - Publisher NameSpringer, Cham - Print ISBN978-3-030-30792-9 - Online ISBN978-3-030-30793-6 - eBook Packages [Computer Science](https://link.springer.com/search?facet-content-type=%22Book%22&package=11645&facet-start-year=2019&facet-end-year=2019) [Computer Science (R0)](https://link.springer.com/search?facet-content-type=%22Book%22&package=43710&facet-start-year=2019&facet-end-year=2019) [Springer Nature Proceedings Computer Science](https://link.springer.com/search?facet-content-type=%22Book%22&package=85344&facet-start-year=2019&facet-end-year=2019) ## Publish with us [Policies and ethics](https://www.springernature.com/gp/policies/book-publishing-policies) ## Societies and partnerships - [![the Semantic Web Science Association](https://published-with.public.springernature.app/img/swsa.jpg) the Semantic Web Science Association](http://swsa.semanticweb.org/) 1. DBpedia. [wiki.dbpedia.org/downloads-2016-10](https://wiki.dbpedia.org/downloads-2016-10) 2. Extended version. [https://www.inf.unibz.it/krdb/tech-reports/](https://www.inf.unibz.it/krdb/tech-reports/) 3. SHACL Test Suite. [w3c.github.io/data-shapes/data-shapes-test-suite/](http://w3c.github.io/data-shapes/data-shapes-test-suite/) 4. Shaclex. [http://github.com/labra/shaclex/](http://github.com/labra/shaclex/) [↩](#fnref:4) 5. Shex.js. [http://github.com/shexSpec/shex.js/](http://github.com/shexSpec/shex.js/) 6. Source code and experiment’s material. [http://github.com/rdfshapes/shacl-sparql](http://github.com/rdfshapes/shacl-sparql) 7. Stardog ICV. [https://www.stardog.com/blog/data-quality-with-icv/](https://www.stardog.com/blog/data-quality-with-icv/) 8. TopBraid Composer. [http://www.topquadrant.com/products/topbraid-composer/](http://www.topquadrant.com/products/topbraid-composer/) 9. Boneva, I., Labra Gayo, J.E., Prud’hommeaux, E.G.: Semantics and validation of shapes schemas for RDF. In: ISWC 2017 [Google Scholar](https://scholar.google.com/scholar?&q=Boneva%2C%20I.%2C%20Labra%20Gayo%2C%20J.E.%2C%20Prud%E2%80%99hommeaux%2C%20E.G.%3A%20Semantics%20and%20validation%20of%20shapes%20schemas%20for%20RDF.%20In%3A%20ISWC%202017) 10. Corman, J., Reutter, J.L., Savković, O.: Semantics and validation of recursive SHACL. In: Vrandečić, D., Bontcheva, K., Suárez-Figueroa, M.C., Presutti, V., Celino, I., Sabou, M., Kaffee, L.-A., Simperl, E. (eds.) ISWC 2018. LNCS, vol. 11136, pp. 318–336. Springer, Cham (2018). [https://doi.org/10.1007/978-3-030-00671-6_19](https://doi.org/10.1007/978-3-030-00671-6_19) [Chapter](https://link.springer.com/doi/10.1007/978-3-030-00671-6_19) [Google Scholar](https://scholar.google.com/scholar_lookup?&title=Semantics%20and%20validation%20of%20recursive%20SHACL&pages=318-336&publication_year=2018%202018%202018&author=Corman%2CJ&author=Reutter%2CJL&author=Savkovi%C4%87%2CO) 11. Corman, J., Reutter, J.L., Savković, O.: Semantics and validation of recursive SHACL (extended version). Technical report KRDB18-1, Free University Bozen-Bolzano (2018). [https://www.inf.unibz.it/krdb/tech-reports/](https://www.inf.unibz.it/krdb/tech-reports/) [Google Scholar](https://scholar.google.com/scholar_lookup?&title=Semantics%20and%20Validation%20of%20Recursive%20SHACL&pages=318-336&publication_year=2018&author=Corman%2CJulien&author=Reutter%2CJuan%20L.&author=Savkovi%C4%87%2COgnjen) 12. Corman, J., Reutter, J.L., Savković, O.: A tractable notion of stratification for SHACL. In: ISWC 2018 [Google Scholar](https://scholar.google.com/scholar?&q=Corman%2C%20J.%2C%20Reutter%2C%20J.L.%2C%20Savkovi%C4%87%2C%20O.%3A%20A%20tractable%20notion%20of%20stratification%20for%20SHACL.%20In%3A%20ISWC%202018) 13. Kontokostas, D., et al.: Test-driven evaluation of linked data quality. In: WWW (2014) [Google Scholar](https://scholar.google.com/scholar?&q=Kontokostas%2C%20D.%2C%20et%20al.%3A%20Test-driven%20evaluation%20of%20linked%20data%20quality.%20In%3A%20WWW%20%282014%29) 14. Motik, B., Horrocks, I., Sattler, U.: Bridging the gap between OWL and relational databases. Web Semant.: Sci. Serv. Agents World Wide Web **7** (2), 74–89 (2009) [Article](https://doi.org/10.1016%2Fj.websem.2009.02.001) [Google Scholar](https://scholar.google.com/scholar_lookup?&title=Bridging%20the%20gap%20between%20OWL%20and%20relational%20databases&journal=Web%20Semant.%3A%20Sci.%20Serv.%20Agents%20World%20Wide%20Web&volume=7&issue=2&pages=74-89&publication_year=2009&author=Motik%2CB&author=Horrocks%2CI&author=Sattler%2CU) 15. Reutter, J.L., Soto, A., Vrgoč, D.: Recursion in SPARQL. In: Arenas, M., et al. (eds.) ISWC 2015. LNCS, vol. 9366, pp. 19–35. Springer, Cham (2015). [https://doi.org/10.1007/978-3-319-25007-6_2](https://doi.org/10.1007/978-3-319-25007-6_2) [Chapter](https://link.springer.com/doi/10.1007/978-3-319-25007-6_2) [Google Scholar](https://scholar.google.com/scholar_lookup?&title=Recursion%20in%20SPARQL&pages=19-35&publication_year=2015%202015%202015&author=Reutter%2CJL&author=Soto%2CA&author=Vrgo%C4%8D%2CD) 16. Staworko, S., Boneva, I., Labra Gayo, J.E., Hym, S., Prud’hommeaux, E.G., Solbrig, H.: Complexity and expressiveness of ShEx for RDF. In: ICDT (2015) [Google Scholar](https://scholar.google.com/scholar?&q=Staworko%2C%20S.%2C%20Boneva%2C%20I.%2C%20Labra%20Gayo%2C%20J.E.%2C%20Hym%2C%20S.%2C%20Prud%E2%80%99hommeaux%2C%20E.G.%2C%20Solbrig%2C%20H.%3A%20Complexity%20and%20expressiveness%20of%20ShEx%20for%20RDF.%20In%3A%20ICDT%20%282015%29) 17. Tao, J., Sirin, E., Bao, J., McGuinness, D.L.: Integrity constraints in owl. In: AAAI (2010) [Google Scholar](https://scholar.google.com/scholar?&q=Tao%2C%20J.%2C%20Sirin%2C%20E.%2C%20Bao%2C%20J.%2C%20McGuinness%2C%20D.L.%3A%20Integrity%20constraints%20in%20owl.%20In%3A%20AAAI%20%282010%29) [↩](#fnref:17)
## Media
1. image: https://social-archiver-api.social-archive.org/media/archives/arc/VDJ8rhwIuG/media/0.jpg
