Shape Expressions with Inheritance

Iovka Boneva, Jose Emilio Labra Gayo, Eric Prud’hommeaux, Katherine Thornton, Andra Waagmeester · 2025

Read Shape Expressions with Inheritance by Iovka Boneva, Jose Emilio Labra Gayo, Eric Prud’hommeaux, Katherine Thornton, Andra Waagmeester (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2503-24299.txt.

Introduction

Iovka Boneva and co-authors add inheritance to a data shape language in a 2025 paper. Shape Expressions, or ShEx, check that linked data match a required pattern. Real schemas repeat themselves, though, and copy paste breeds errors. Borrowing from object oriented programming, the team let shapes inherit from parent shapes, reusing and refining their rules.

Syntax and formal meaning are given, extending the current standard's semantics. The validation algorithm extends too, at no extra complexity cost. Data publishers for science and government use such schemas to keep shared datasets honest. Inheritance makes big schema libraries maintainable, the lack that often kills them in practice.

Catalog record

CREATORIovka Boneva, Jose Emilio Labra Gayo, Eric Prud’hommeaux, Katherine Thornton, Andra Waagmeester
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE63 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2503-24299

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Shape Expressions with Inheritance Iovka Boneva, Jose Emilio Labra Gayo, Eric Prud’hommeaux, Katherine Thornton, Andra Waagmeester Abstract We formally introduce an inheritance mechanism for the Shape Expressions language (ShEx). It is inspired by inheritance in object-oriented programming languages, and provides similar advantages such as reuse, modularity, and more flexible data modelling. Using an example, we explain the main features of the inheritance mechanism. We present its syntax and formal semantics. The semantics is an extension of the semantics of ShEx 2.1. It also directly yields a validation algorithm as an extension of the previous ShEx validation algorithms, while maintaining the same algorithmic complexity. 1 Introduction The Shape Expressions language (ShEx) was proposed in 2014 as a concise, high-level language to describe and validate RDF data [ 12 ] . It allows us to define ShEx schemas which are collections of shapes. A shape describes the required properties of an RDF node and constrains their values. ShEx 2.1 was published as a W3C final community report in 2019 1 1 1 https://shex.io/shex-semantics-20191008/ , and it introduced logical operators on top of shapes, yielding shape expressions . They allow describing alternatives with disjunction, or further constraining the shape of the data and data values with conjunction. ShEx has been increasingly adopted in different domains such as HL7 FHIR 2 2 2 https://www.hl7.org/fhir/ and Wikidata [ 17 ] , where it is used to describe data models and to validate entity data. The adoption of ShEx for describing large data models has led to the appearance of collaborative shape schema ecosystems like that of Wikidata 3 3 3 https://www.wikidata.org/wiki/Wikidata:Database_reports/EntitySchema_directory . An important requirement for such ecosystems is to support reusability. The simplest feature for reuse is to import a shape expression that has been defined elsewhere. ShEx 2.1 does offer this possibility and the imported shape expression can be reused as is. Data modelling and reuse often require adapting the existing data and its model to one’s particular needs. Two common adaptation patterns are to restrict the allowed values of existing properties, and to extend the data model and the data with properties that are specific to a new application. Additionally, a commonly-used feature is to define frequently occurring patterns which serve as building blocks of shape expressions. In response to submitted use cases, the ShEx Community Group 4 4 4 https://www.w3.org/community/shex/ has proposed an inheritance mechanism for ShEx that provides the afore-mentioned features. Inspired by inheritance in programming languages, it allows for the definition of a hierarchy of shape expressions. Child shapes can extend their parents with new required properties for RDF nodes, and can impose additional constraints on the properties of their parents. Additionally, as in object-oriented programming languages, a node with a child shape can be used where a parent shape is expected. Multiple inheritance is also allowed. Finally, shape expressions can be made abstract indicating that they cannot be used on their own, but only as building blocks of other expressions. An early version of the inheritance mechanism has been used in [ 13 ] to translate in ShEx the user-facing documentation of data structures in FHIR. In this paper, we introduce the formal semantics for ShEx with inheritance, built as an extension of the formal semantics of ShEx 2.1 [ 4 ] . The formalization posed some challenges, notably for handling multiple inheritance. In particular, we introduce a syntactic restriction on the combined use of inheritance with disjunction. The restriction avoids unnecessary complexity in the language, while still providing the functionality required by the use cases. The ShEx formalization presented here will be submitted for the next version of the ShEx language, currently under standardization by IEEE. 5 5 5 https://standards.ieee.org/ieee/3330/11119/ The paper is organized as follows. In Sect. 2 we give an example illustrating the main features of the inheritance mechanism, and define some preliminary notions. Sect. 3 gives the syntax, and Sect. 4 the semantics of the language. Sect. 5 presents a validation algorithm. We close with a discussion, an overview of related work and a conclusion in Sect. 6 . The proofs omitted in the paper are presented in appendix. A companion webpage [ 1 ] lists the current implementations and provides source code and demonstrations for the examples. 2 Motivating example and background Assume the following constraints on nodes in an RDF graph: T_{\mathit{str}} is satisfied by string literals, T_{\mathit{float}} by float literals, T_{\mathit{any}} by all RDF nodes, T_{\text{"colour"}} is satisfied by the literal "colour" , and T_{\text{"radius"}} by the literal "radius" . A ShEx schema using inheritance is presented in Fig. 1 , we will describe it section by section. The source code for that schema is available on the companion webpage [ 1 ] . The shape expression named Coord describes nodes representing coordinates, i.e. having properties x and y whose values are floats. The shape expression Attribute requires a property name which is a string, and a property value that can be anything. The \mathop{\mathsf{extends}}\_ indicates that the shape expression is being extended. A Colour is a specific kind of attribute (extends on Attribute ) that additionally to the name and value properties requires a scope property whose value is a string. This is captured by the first part of the definition, preceding the \mathbin{\mathsf{and}} keyword. The second part states that the name of a Colour attribute is "colour" . Thus, inheritance provides a mechanism for requiring additional properties (before the \mathbin{\mathsf{and}} ) and restricting existing properties (after the \mathbin{\mathsf{and}} ). Fig. 2 shows an example graph. Nodes a1 , a2 , a3 satisfy Attribute , node a2 satisfies Colour , and node c1 satisfies Coord . \begin{array}[]{rl}\textit{Coord}&\to\langle\,\textit{x}\;\mathsf{@}T_{\mathit{float}}\;\mathbin{\mathsf{;}}\;\textit{y}\;\mathsf{@}T_{\mathit{float}}\,\rangle\\ \textit{Attribute}&\to\mathop{\mathsf{extends}}\_\langle\,\textit{name}\;\mathsf{@}T_{\mathit{str}}\mathbin{\mathsf{;}}\textit{value}\;\mathsf{@}T_{\mathit{any}}\,\rangle\\ \textit{Colour}&\to\mathop{\mathsf{extends}}\;\textit{Attribute}\;\langle\,\textit{scope}\;\mathsf{@}T_{\mathit{str}}\,\rangle\;\;\mathbin{\mathsf{and}}\;\;\langle\,\textit{name}\;\mathsf{@}T_{\text{"colour"}}\,\rangle\\[6.0pt] \mathop{\mathsf{abstract}}\textit{Figure}&\to\mathop{\mathsf{extends}}\_\langle\,\textit{coord}\;\mathsf{@}\textit{Coord}\,\rangle\\ \textit{Circle}&\to\mathop{\mathsf{extends}}\;\textit{Figure}\;\langle\,\textit{attr}\;\mathsf{@}\textit{Radius}\,\rangle\\ \textit{Radius}&\to\mathop{\mathsf{extends}}\;\textit{Attribute}\;\langle\,\varepsilon\,\rangle\mathbin{\mathsf{and}}\langle\,\textit{name}\;\mathsf{@}T_{\text{"radius"}}\;\mathbin{\mathsf{;}}\;\textit{value}\;\mathsf{@}T_{\mathit{float}}\,\rangle\\[6.0pt] \textit{ColouredFigure}&\to\mathop{\mathsf{extends}}\;\textit{Figure}\;\langle\,\textit{attr}\;\mathsf{@}\textit{Colour}\,\rangle\\ \textit{ColouredCircle}&\to\mathop{\mathsf{extends}}\;\textit{Circle},\textit{ColouredFigure}\;\langle\,\varepsilon\,\rangle\end{array} Figure 1: A ShEx schema with inheritance. f1 c1 2.0 4.0 a1 "radius" 10.1 a2 "#ff0000" "colour" "fill" coord x y attr attr name value name value scope f2 c2 0.2 -2.3 a3 "radius" 7.2 coord x y attr name value Figure 2: Example graph with nodes f1 , f2 , a1 , a2 , a3 and strings and float literals. A Figure has coordinates associated with the property coord . The shape expression Figure is marked as \mathop{\mathsf{abstract}} , which indicates that it cannot be directly satisfied, rather one of its non-abstract descendants will be satisfied. A Circle is a Figure that has a Radius attribute reachable through the property attr , which in turn is an Attribute having name "radius" and a float value . Note that the definition of Circle does not have a restriction after the \mathbin{\mathsf{and}} ; in fact the restriction is optional. On the other hand, the extending portion of Radius is \varepsilon , meaning that a Radius does not require additional properties beyond those specified in its parent Attribute . In the example graph, f2 is a Circle , a1 , a3 satisfy Radius . The final part of the example illustrates multiple inheritance. A ColouredCircle extends both on ColouredFigure and Circle which in turn both extend from Figure . Recall that a Figure has one coord property, which is inherited twice by ColouredCircle . The inheritance mechanism ensures that multiply-inherited properties are not used more than once. In this particular example, a ColouredCircle can have only one coord

Read the complete text