This book describes two languages for implementing constraints on RDF data, describing the main features of both Shape Expressions (ShEx) and Shapes Constraint Language (SHACL) from a user perspective, and also offering a comparison of the technologies. Throughout this book, we develop a small number of examples that typify validation requirements and demonstrate how they can be met with ShEx and SHACL. The book is not intended to be a formal specification of the languages, for which the interested reader can consult the corresponding reference documents, but rather, it is meant to serve as an introduction to the technologies with some background about the rationale of their design and some points of comparison.
Chapter 1 provides a brief introduction to the topic. Chapter 2 presents a short overview of the RDF data model and RDF-related technologies; this chapter could be skipped by any reader who already knows RDF or Turtle. Chapter 3 helps the reader to understand what to expect from data validation. It describes the problem of RDF validation and some approaches that have been proposed. This book specifically reviews two of these approaches in further detail: ShEx (Chapter 4) and SHACL (Chapter 5). These chapters describe each language and provide a practical introduction using examples. Following the discussion of both languages, Chapter 6 presents some applications using either ShEx, SHACL, or both. Finally, Chapter 7 compares ShEx and SHACL and offers some conclusions.
The goal of this book is to serve as a practical introduction to ShEx and SHACL using examples. While we omitted formal definitions or specifications, references for further reading can be found at the end of each chapter. We give a quick overview of some background and related technologies so that readers without RDF knowledge can follow the book’s contents. Also, it is not necessary to have any prior knowledge of programming or ontologies to understand RDF validation technologies. The intended audience is anyone interested in data representation and quality.
Jose Emilio Labra Gayo, Eric Prud’hommeaux, Iovka Boneva, and Dimitris Kontokostas