<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:lang="en">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Graph schema validation at last? Revisiting the Stemmarest data model with Neo4J and SHACL</title>
        <author>Tara Lee Andrews</author>
      </titleStmt>
      <publicationStmt>
        <p>Tag layer of the DHSS Meta-Tagging Project. The article text is reproduced from the
           staged copy named in sourceDesc and is not altered; the tags are held separately in
           standOff so that overlapping and nested spans are preserved.</p>
      </publicationStmt>
      <sourceDesc>
        <bibl>
          <title>Graph schema validation at last? Revisiting the Stemmarest data model with Neo4J and SHACL</title>
          <date>2023</date>
          <publisher>Digital Humanities 2023 (DH2023), Graz</publisher>
          <idno type="DOI">10.5281/zenodo.8107471</idno>
          
          <idno type="record">stemmarest2023-shacl</idno>
          <note type="staged-file">stemmarest2023-shacl.txt, the project's staged copy</note>
          <note type="text-sha1">16a0fc45ba86c37046cb00ea2d4f0df0df375611</note>
          <note type="rights">cc-by</note>
        </bibl>
      </sourceDesc>
    </fileDesc>
    <profileDesc>
      <textClass><keywords><term>digital-humanities</term></keywords></textClass>
      <particDesc>
        <person xml:id="paper"><p>the paper's own words</p></person>
        <person xml:id="tagger"><p>the tag layer; a sentence written by the tagger about the
          paper, always anchored to a quotation but not itself a quotation</p></person>
      </particDesc>
    </profileDesc>
    <revisionDesc>
      <change when="2026-10-06"
              who="build_paper_edition.py">50 spans located by searching the stored text for the quote's exact words, allowing any whitespace between them</change>
    </revisionDesc>
  </teiHeader>
  <standOff>
    <spanGrp type="tags">
      <span xml:id="t0" from="#a1" to="#a5" type="object_of_study" ana="#object_of_study" resp="#paper">The variant graph data model used to represent text collations, and whether its constraints can be expressed formally.</span>
      <span xml:id="t1" from="#a48" to="#a49" type="claim_type" ana="#claim_type" resp="#paper">method</span>
      <span xml:id="t2" from="#a32" to="#a33" type="phenomenon" ana="#phenomenon" resp="#paper">graph schema validation</span>
      <span xml:id="t3" from="#a38" to="#a39" type="method" ana="#method" resp="#paper">review<term>review</term></span>
      <span xml:id="t4" from="#a26" to="#a27" type="mechanisms" ana="#mechanisms[0]" resp="#tagger">An ontology describes what kinds of thing exist and how they relate, but cannot forbid a combination that is well-typed and still wrong</span>
      <span xml:id="t5" from="#a22" to="#a23" type="mechanisms" ana="#mechanisms[1]" resp="#tagger">The hard constraints are cross-object: an entity appearing in one structure must be consistent with its membership elsewhere</span>
      <span xml:id="t6" from="#a24" to="#a25" type="mechanisms" ana="#mechanisms[2]" resp="#tagger">Some constraints are global properties of the whole graph and cannot be checked object by object at all</span>
      <span xml:id="t7" from="#a30" to="#a31" type="mechanisms" ana="#mechanisms[3]" resp="#tagger">The original failure was not a modelling mistake but a mismatch of purpose - OWL was built for open-world inference and editors want description and consistency</span>
      <span xml:id="t8" from="#a48" to="#a49" type="mechanisms" ana="#mechanisms[4]" resp="#tagger">Constraints only bite if the store can undo a rejected write, so validation needs transactions and rollback underneath it</span>
      <span xml:id="t9" from="#a50" to="#a51" type="mechanisms" ana="#mechanisms[5]" resp="#tagger">Allowing arbitrary code inside constraints erases the code/data boundary that sustainability practice depends on, which the author treats as a feature</span>
      <span xml:id="t10" from="#a26" to="#a27" type="limitations" ana="#limitations[0]" resp="#tagger">The author&#x27;s own earlier Stemmarest ontology describes the data adequately but cannot express the model&#x27;s constraints, which still have to be written in program code.<note>what this limits: any use of the ontology to enforce the model: WHILE THE STEMMAREST ONTOLOGY CAN DESCRIBE THE DATA REASONABLY WELL, IT IS NOT AN ADEQUATE TOOL FOR SETTING CONSTRAINTS; THESE MUST STILL BE DESCRIBED IN CODE</note></span>
      <span xml:id="t11" from="#a42" to="#a43" type="limitations" ana="#limitations[1]" resp="#tagger">RDF*, the extension the interoperability half of the proposal depends on, is acknowledged to be immature.<note>what this limits: the interoperability half of the proposal: RDF* IS STILL IN AN EARLY PHASE OF DEVELOPMENT</note></span>
      <span xml:id="t12" from="#a50" to="#a51" type="limitations" ana="#limitations[2]" resp="#tagger">SHACL&#x27;s SPARQL/Javascript constraint components undermine the separation of code from data that sustainability practice normally treats as the gold standard.<note>what this limits: the sustainability claim for SHACL: constraint components CHALLENGE THE IDEA OF THE SEPARATION OF PROGRAM CODE AND DATA THAT IS THE USUAL GOLD STANDARD</note></span>
      <span xml:id="t13" from="#a6" to="#a9" type="limitations" ana="#limitations[3]" resp="#tagger">The 2020 ontology attempt failed because RDF and OWL handle property attributes badly, and the model depends on them<note>what this limits: any RDF/OWL serialisation of a property-bearing graph: THE ONTOLOGY WAS NOT SUITABLE FOR EXPRESSING THE FULL DATA MODEL ... NOT LEAST BECAUSE ALL OF THEM ... RELY ON PROP[erty attributes]</note></span>
      <span xml:id="t14" from="#a34" to="#a35" type="limitations" ana="#limitations[4]" resp="#tagger">The graph database&#x27;s own constraint mechanism reaches only data properties, not structure<note>what this limits: the graph-database alternative: CONSTRAINT ENFORCEMENT IN NEO4J ... IS INDEED LIMITED STRICTLY TO DATA PROPERTIES OF NODES AND RELATIONSHIPS, not structure</note></span>
      <span xml:id="t15" from="#a42" to="#a43" type="limitations" ana="#limitations[5]" resp="#tagger">The extension that would fix the property problem is not yet mature<note>what this limits: the same scope as limitations[1] - the fix for the property problem is immature</note></span>
      <span xml:id="t16" from="#a36" to="#a37" type="limitations" ana="#limitations[6]" resp="#tagger">Linked-data stores are in no better position, having relied on ontologies alone<note>what this limits: the linked-data alternative: LOD STORES ... HAVE SO FAR DEPENDED MORE OR LESS ENTIRELY ON ONTOLOGY SPECIFICATIONS, WITH LIMITATIONS AS DESCRIBED ABOVE</note></span>
      <span xml:id="t17" from="#a16" to="#a17" type="senses" ana="#senses[0]" resp="#tagger" cert="1.0">schema - as DESCRIPTION: says what classes exist and how they may relate, which an ontology does well</span>
      <span xml:id="t18" from="#a20" to="#a21" type="senses" ana="#senses[1]" resp="#tagger" cert="1.0">schema - as CONSTRAINT: forbids configurations that are well-typed and still wrong, which is what validation actually needs</span>
      <span xml:id="t19" from="#a34" to="#a35" type="senses" ana="#senses[2]" resp="#tagger" cert="1.0">the graph problem - LOCAL: a property on a single node or relationship, which Neo4J can already enforce</span>
      <span xml:id="t20" from="#a24" to="#a25" type="senses" ana="#senses[3]" resp="#tagger" cert="1.0">the graph problem - GLOBAL: a property of the whole graph, such as the edited text not looping back on itself, which nothing local can check</span>
      <span xml:id="t21" from="#a28" to="#a29" type="senses" ana="#senses[4]" resp="#tagger" cert="1.0">OWL&#x27;s purpose - as intended: open-world inference, deriving new facts from stated ones</span>
      <span xml:id="t22" from="#a30" to="#a31" type="senses" ana="#senses[5]" resp="#tagger" cert="1.0">OWL&#x27;s purpose - as wanted by editors: formalisation, description and consistency, which is a different job it was not built for</span>
      <span xml:id="t23" from="#a44" to="#a47" type="alternatives" ana="#alternatives.claim_type" resp="#tagger">claim_type: method<note>a second reading reaching the same value. Recorded: method — note: a second reading reaching the same value from a different sentence. Not applied - a person decides.</note></span>
      <span xml:id="t24" from="#a14" to="#a15" type="claim_relations" ana="#claim_relations[0]" resp="#tagger">builds-on → Andrews (2020), the 2020 attempt to build an ontology for the variant graph / Stemmarest</span>
      <span xml:id="t25" from="#a30" to="#a31" type="claim_relations" ana="#claim_relations[1]" resp="#tagger">extends → Vogeler (2021) on graph-based models for critical edition and the unexploited affordance of OWL</span>
      <span xml:id="t26" from="#a48" to="#a49" type="claim_relations" ana="#claim_relations[2]" resp="#tagger">builds-on → SHACL (Shapes Constraint Language), Knublauch and Kontokostas (2017)</span>
      <span xml:id="t27" from="#a42" to="#a43" type="claim_relations" ana="#claim_relations[3]" resp="#tagger">builds-on → RDF* (Arndt et al., 2021)</span>
      <span xml:id="t28" from="#a14" to="#a15" type="claim_relations" ana="#claim_relations[4]" resp="#tagger">critiques → the author&#x27;s own 2020 attempt to build a variant-graph ontology</span>
      <span xml:id="t29" from="#a32" to="#a33" type="claim_relations" ana="#claim_relations[5]" resp="#tagger">critiques → the argument that graph databases lack the sustainability foundations of XML or relational schemas</span>
      <span xml:id="t30" from="#a28" to="#a29" type="claim_relations" ana="#claim_relations[6]" resp="#tagger">extends → Vogeler on graph-based models for critical edition</span>
      <span xml:id="t31" from="#a52" to="#a53" type="claim_relations" ana="#claim_relations[7]" resp="#tagger">supports → the codework literature arguing that code embodies scholarship</span>
      <span xml:id="t32" from="#a48" to="#a49" type="concept_edges" ana="#concept_edges[0]" resp="#tagger">SHACL —contrasted-with→ ontology<note>strength of the relation: 1</note><term>SHACL</term><term>ontology</term></span>
      <span xml:id="t33" from="#a42" to="#a43" type="concept_edges" ana="#concept_edges[2]" resp="#tagger">RDF* —operationalised-as→ property attributes<note>strength of the relation: 1
Audit 2026-09-28: DOUBTFUL - read against its span and kept, but RDF* allows properties on relationships; operationalised-as &#x27;property attributes&#x27; is the wrong type.</note><term>RDF*</term><term>property attributes</term></span>
      <span xml:id="t34" from="#a6" to="#a9" type="concept_edges" ana="#concept_edges[3]" resp="#tagger">property attributes —distinct-from→ OWL<note>strength of the relation: 1
Audit 2026-09-28: DOUBTFUL - read against its span and kept, but OWL does not handle property attributes; distinct-from paraphrases an inability.</note><term>property attributes</term><term>OWL</term></span>
      <span xml:id="t35" from="#a18" to="#a19" type="concept_edges" ana="#concept_edges[4]" resp="#tagger">witness —part-of→ tradition<note>strength of the relation: 1</note><term>witness</term><term>tradition</term></span>
      <span xml:id="t36" from="#a18" to="#a19" type="concept_edges" ana="#concept_edges[5]" resp="#tagger">EVIDENCE CORRECTED (RE-GROUNDED) · stemma —part-of→ tradition<note>EVIDENCE CORRECTED: RE-GROUNDED. The old span attested &#x27;stemma&#x27; only inside &#x27;Stemmarest&#x27;, the TOOL&#x27;S OWN NAME - a run of letters, not the word. This clause writes both terms and states the containment in the paper&#x27;s own verb: a stemma BELONGS TO a tradition. — strength of the relation: 1</note><term>stemma</term><term>tradition</term></span>
      <span xml:id="t37" from="#a1" to="#a5" type="concept_edges" ana="#concept_edges[8]" resp="#tagger">Stemmarest —operationalised-as→ variant graph<note>strength of the relation: 1
Audit 2026-09-28: DOUBTFUL - read against its span and kept, but Stemmarest USES the variant graph model; operationalised-as is the wrong type.</note><term>Stemmarest</term><term>variant graph</term></span>
      <span xml:id="t38" from="#a10" to="#a13" type="concept_edges" ana="#concept_edges[11]" resp="#tagger">critical apparatus —part-of→ digital scholarly edition<note>strength of the relation: 1
Audit 2026-09-28: DOUBTFUL - read against its full span and kept, but the span says ontologies were proposed for aspects of digital scholarly edition and specifically for critical apparatus; part-of is loose.</note><term>critical apparatus</term><term>digital scholarly edition</term></span>
      <span xml:id="t39" from="#a7" to="#a8" type="content_tags" ana="#content_tags.findings[0]" resp="#tagger">An ontology could not express the variant graph model, because the model relies on property attributes that RDF and OWL handle badly.</span>
      <span xml:id="t40" from="#a14" to="#a15" type="content_tags" ana="#content_tags.findings[1]" resp="#tagger">The 2020 project showed that ontologies, and OWL in particular, are inadequate as a validation model for graph-based data.</span>
      <span xml:id="t41" from="#a11" to="#a12" type="content_tags" ana="#content_tags.findings[2]" resp="#tagger">The concern being answered is that graph databases lack the schema enforcement that gives XML and relational data their sustainability and interoperability.<note>about this quote: THE QUOTE IS A CONCERN THE PAPER SETS OUT TO ADDRESS, NOT ITS FINDING - it completes a sentence that says the project was undertaken &#x27;to address the concerns, frequently heard&#x27; that.</note></span>
      <span xml:id="t42" from="#a26" to="#a27" type="content_tags" ana="#content_tags.findings[3]" resp="#tagger">an ontology can describe the model adequately and still be unable to constrain it, leaving the constraints in code</span>
      <span xml:id="t43" from="#a6" to="#a9" type="content_tags" ana="#content_tags.findings[4]" resp="#tagger">the failure traces to RDF and OWL handling properties on relationships badly</span>
      <span xml:id="t44" from="#a42" to="#a43" type="content_tags" ana="#content_tags.findings[5]" resp="#tagger">RDF* supplies the missing ability to put properties on relationships, though it is early</span>
      <span xml:id="t45" from="#a48" to="#a49" type="content_tags" ana="#content_tags.findings[6]" resp="#tagger">SHACL constraints plus a transactional store can enforce the cross-object consistency an ontology cannot</span>
      <span xml:id="t46" from="#a2" to="#a3" type="content_tags" ana="#content_tags.definitions[0]" resp="#tagger">variant graph<term>variant graph</term></span>
      <span xml:id="t47" from="#a45" to="#a46" type="content_tags" ana="#content_tags.definitions[1]" resp="#tagger">SHACL<term>SHACL</term></span>
      <span xml:id="t48" from="#a40" to="#a41" type="content_tags" ana="#content_tags.definitions[2]" resp="#tagger">RDF*<term>RDF*</term></span>
      <span xml:id="t49" from="#a2" to="#a4" type="content_tags" ana="#content_tags.definitions[3]" resp="#tagger">variant graph<term>variant graph</term></span>
    </spanGrp>
  </standOff>
  <text>
    <body>
        <p><anchor xml:id="a0"/> <anchor xml:id="a1"/>In 2020 there was an attempt to create an ontology   (Andrews, 2020) for <anchor xml:id="a2"/>the variant graph, which is a data model used in tools such as CollateX<anchor xml:id="a3"/> (Haentjens Dekker et al., 2015), Stemmarest   (Andrews, 2019), and TraVIZ (Jänicke et al., 2015) to represent and visualize text collations and certain sorts of annotation<anchor xml:id="a4"/>.<anchor xml:id="a5"/> <anchor xml:id="a6"/>The conclusion was that the ontology was not suitable for expressing the full data model employed in variant graphs, not least because all of them (Stemmarest most heavily) <anchor xml:id="a7"/>rely on property attributes, which RDF and OWL do not handle well and which can therefore not be suitably represented in an ontology definition<anchor xml:id="a8"/>.<anchor xml:id="a9"/></p>
        <p><anchor xml:id="a10"/>Indeed, although ontologies have in the meantime been proposed for various aspects of digital scholarly edition   (NIE-INE, 2019) and specifically for critical apparatus   (Giovannetti, 2021) and an opportunity to discuss these together would be very welcome, one major motivation for undertaking the 2020 project at all was to address the concerns, frequently heard by the author in a very heavily XML-based community, that since graph databases do not tend to have schemas and certainly have no way to enforce these schemas, <anchor xml:id="a11"/>they lack the foundations for sustainability and interoperability that TEI XML schemas or, indeed, relational database schemas provide<anchor xml:id="a12"/>.<anchor xml:id="a13"/> Many of those who expressed concerns went on to point to ontologies as examples of schemas that can be used to validate RDF data.</p>
        <p><anchor xml:id="a14"/>What the 2020 project showed, in the end, was the inadequacy of ontologies and especially OWL as a validation model for graph-based data.<anchor xml:id="a15"/> <anchor xml:id="a16"/>While many of the classes used by Stemmarest and their relationships to each other can be described adequately in OWL, the model relies upon many additional constraints that, while seemingly simple, go beyond OWL’s capabilities.<anchor xml:id="a17"/> <anchor xml:id="a18"/>For example, in the Stemmarest ontology we can say that a Witness can belong to a Tradition and also to one or more Stemmata, and that a Tradition can contain multiple Stemmata.<anchor xml:id="a19"/> <anchor xml:id="a20"/>However, one of the important aspects of validation is to prevent inattentive mistakes in the data model.<anchor xml:id="a21"/> <anchor xml:id="a22"/>For example, if a witness W appears in a stemma belonging to tradition A, the model software should ensure that W also belongs to tradition A as a witness and not, for example, an unrelated tradition B; moreover, W should not appear in any stemmata of tradition B.<anchor xml:id="a23"/> <anchor xml:id="a24"/>Even more intractable problems arise with more complex specifications: for example, the need to ensure that the variant graph is self-consistent, so that a user cannot create a situation in the model where a portion of the edited text loops back onto itself or is omitted altogether.<anchor xml:id="a25"/> <anchor xml:id="a26"/>Thus, while the Stemmarest ontology can describe the data reasonably well, it is not an adequate tool for setting constraints; these must still be described in code.<anchor xml:id="a27"/></p>
        <p><anchor xml:id="a28"/>Vogeler   (2021, p. 80) notes in his discussion of graph-based models for critical edition that “the formal affordance of OWL is not really exploited in Digital Scholarly Editions”.<anchor xml:id="a29"/> <anchor xml:id="a30"/>We would argue here that most editors are less interested in the sort of open-world inference for which OWL was intended (though Vogeler makes a case for why it might be interesting), as opposed to the formalisation, description, and consistency of their data.<anchor xml:id="a31"/> <anchor xml:id="a32"/>In this sense, the critics of graph-based models do have a point; how do we validate our graphs?<anchor xml:id="a33"/> <anchor xml:id="a34"/>Constraint enforcement in Neo4J, perhaps the most popular graph database, is indeed limited strictly to data properties of nodes and relationships   (Neo4J, Inc., 2022).<anchor xml:id="a35"/> <anchor xml:id="a36"/>The situation is hardly better for LOD stores, which have so far depended more or less entirely on ontology specifications, with limitations as described above, to describe their data.<anchor xml:id="a37"/></p>
        <p><anchor xml:id="a38"/>Recently, however, there have been two intriguing developments in the Semantic Web world that are especially relevant to digital humanities projects, not least Stemmarest.<anchor xml:id="a39"/> The first of these is <anchor xml:id="a40"/>RDF*, an extension to RDF that allows an entire triple to be the subject or object in further triple statements<anchor xml:id="a41"/>   (Arndt et al., 2021). <anchor xml:id="a42"/>While it is still in an early phase of development, RDF* provides the long-awaited ability to set context for LOD statements, and promises to triple stores the same ability to set properties on relationships that graph databases such as Neo4J have always provided; this in turn has opened the way for Stemmarest, and many other projects besides, to take advantage of Neo4J’s powerful graph traversal and analysis algorithms while preserving full interoperability with LOD formats.<anchor xml:id="a43"/></p>
        <p><anchor xml:id="a44"/>The second major development is <anchor xml:id="a45"/>SHACL (Shapes Constraint Language), a language whose purpose is to define a set of constraints against which RDF graphs can be validated<anchor xml:id="a46"/>   (Knublauch and Kontokostas, 2017).<anchor xml:id="a47"/> <anchor xml:id="a48"/>This language solves exactly the problem that ontologies do not; specifically, in conjunction with a database that supports transactions and their rollbacks such as Neo4J, a set of SHACL constraints can ensure the consistency of data added to the graph, so that (to take the example above) a witness from one text tradition cannot be included in a stemma belonging to an entirely different tradition.<anchor xml:id="a49"/></p>
        <p>Perhaps the most intriguing feature of SHACL is the ability to include “constraint components” expressed in SPARQL or Javascript, providing more or less limitless possibilities for formalising complex models. <anchor xml:id="a50"/>In a sense, this affordance challenges the idea of the separation of program code and data that is the usual gold standard for sustainability efforts, insofar as constraints can be expressed as arbitrarily complex programming logic, embedded in RDF or Turtle files and saved as a schema alongside the data itself.<anchor xml:id="a51"/></p>
        <p><anchor xml:id="a52"/>The SHACL model thus provides a fascinating way to bring the intellectual contributions inherent in codework   (Zundert, 2016; Antonijevic Ubois, van Zundert, and Andrews, 2018) across the “sustainability divide” that allows them to be properly valued and conserved as scholarship; at the same time, it points to a promising future model of digital work in the humanities, in which domain-specific code can live alongside the data, to be processed by more generic (and thus, hopefully, more long-lived) software platforms.<anchor xml:id="a53"/></p>
    </body>
  </text>
</TEI>
