Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add <constraintDecl> #2594

Merged
merged 9 commits into from
Dec 18, 2024
Merged
5 changes: 1 addition & 4 deletions P5/Source/Guidelines/en/BIB-Bibliography.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1553,13 +1553,10 @@
Press</publisher>, <biblScope unit="pp">141-151</biblScope>. </bibl>

<!--Other-->

<bibl xml:id="NONE">No source, made up for these <title>Guidelines</title>.</bibl>
<bibl xml:id="SELF">Example is copied from the source of these
<title>Guidelines</title>.</bibl>
<bibl xml:id="SELF">Example is copied from the source of these <title>Guidelines</title>.</bibl>
<bibl xml:id="UND">Undetermined.</bibl>


</listBibl>
</div>
<div>
Expand Down
62 changes: 48 additions & 14 deletions P5/Source/Guidelines/en/TD-DocumentationElements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -834,22 +834,23 @@ to mark any technical term, thus:
<att>passive</att> may be supplied only if the attribute <att>active</att> is supplied.</q>. In the
current version of the Guidelines, constraint specifications expressed as Schematron rules have been
added, as follows:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<egXML xmlns="http://www.tei-c.org/ns/Examples" source="#SELF">
<constraintSpec ident="ref-or-key-or-name" scheme="schematron">
<constraint>
<sch:ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
<sch:rule context="tei:relation">
<sch:assert test="@ref or @key or @name">One of the attributes @name, @ref, or @key must be supplied</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>

<constraintSpec ident="active-mutual" scheme="schematron">
<constraint>
<sch:rule context="tei:relation">
<sch:report test="@active and @mutual">Only one of the attributes @active and @mutual may be supplied</sch:report>
</sch:rule>
</constraint>
</constraintSpec>

<constraintSpec ident="active-passive" scheme="schematron">
<constraint>
<sch:rule context="tei:relation">
Expand All @@ -861,18 +862,49 @@ to mark any technical term, thus:
</p>
<p>Note that the <q>tei:</q> prefix needs to be bound to the TEI
namespace using the Schematron language <gi
scheme="Schematron">ns</gi> element, but typically this only
needs to be done once. The following two examples are written
presuming that the namespace binding for <q>tei:</q> has occured
elsewhere. The first example models the constraint that a TEI
<gi>div</gi> must contain either no subdivisions or at least two
of them:
scheme="Schematron">ns</gi> element. This can be done using the
<gi>constraintDecl</gi> element, which may appear in either the
<gi>encodingDesc</gi> or <gi>schemaSpec</gi> element. A
<gi>constraintDecl</gi> contains declarations specific to all
the <gi>constraintSpec</gi> elements in the current TEI document
whose <att>scheme</att> matches that of the
<gi>constraintDecl</gi>.
<egXML xmlns="http://www.tei-c.org/ns/Examples" source="#NONE">
<constraintDecl scheme="schematron" queryBinding="xslt3">
<sch:ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
<sch:ns prefix="xi" uri="http://www.w3.org/2001/XInclude"/>
<sch:let name="edition" value="substring-before( /*/tei:teiHeader//tei:editionStmt/tei:edition/@n, '.')"/>
<sch:let name="uses_old_encoding" value="$edition cast as xs:integer lt 3"/>
</constraintDecl>
</egXML>
In this example the Schematron query language binding is set (to
<val>xslt3</val>) for use by a Schematron processor, two
namespace prefixes are bound to namespace URIs for later use within
<gi>constraint</gi> elements, and the
<code>$uses_old_encoding</code> variable is set (to either
<code>true()</code> or <code>false()</code>) so that Schematron
assertions elsewhere in the TEI document can easily test whether
the edition number of the document being checked is 3 or more. (Presumably
in this project there are minor encoding differences between the older
and newer editions which do not merit an entirely different
schema, but do merit the occasional different constraint.)</p>
<p>The following two examples are written presuming that the
<gi>constraintDecl</gi> above is in force, that is that the
Schematron processor will use an <val>xslt3</val> binding, that
<q>tei:</q> is bound to the TEI namespace, that <q>xi:</q> is
bound to the XInclude namespace, and that the the variable
<code>$uses_old_encoding</code> is defined as a boolean. The
first example models the constraint that a TEI <gi>div</gi> must
contain either no subdivisions or at least two of them, with the
added complication that larger subdivisions are provided as
separate <name>sect<emph>NN</emph>.xml</name> files read in
using XInclude:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<constraintSpec ident="subclauses" scheme="schematron">
<constraint>
<sch:rule context="tei:div">
<sch:report test="count( tei:div ) eq 1">if it contains any subdivisions, a
division must contain at least two of them</sch:report>
<sch:report test="count( tei:div | xi:include[ contains( @href, 'sect') ] ) eq 1">if it contains any
subdivisions, a division must contain at least two of them</sch:report>
</sch:rule>
</constraint>
</constraintSpec>
Expand All @@ -891,8 +923,11 @@ to mark any technical term, thus:
</constraintSpec>
<constraintSpec ident="maintitle" scheme="schematron">
<constraint>
<sch:rule context="tei:teiHeader">
<sch:assert test="tei:fileDesc/tei:titleStmt/tei:title[@type='main']"> a main title must be supplied</sch:assert>
<sch:rule context="tei:teiHeader[ $uses_old_encoding ]">
<sch:assert test="tei:fileDesc/tei:titleStmt/tei:title[@type eq 'main']"> a main title must be supplied</sch:assert>
</sch:rule>
<sch:rule context="tei:teiHeader[ not( $uses_old_encoding ) ]">
<sch:assert test="tei:fileDesc/tei:titleStmt/tei:title[ not( @type eq 'sub' ) ]"> a main title must be supplied</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
Expand All @@ -905,7 +940,6 @@ to mark any technical term, thus:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<constraintSpec ident="alt" scheme="schematron">
<constraint>
<sch:ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
<sch:pattern id="altTags">
<sch:rule context="tei:figure">
<sch:assert test="tei:figDesc or tei:head"> You should provide information in a figure from
Expand All @@ -920,7 +954,6 @@ to mark any technical term, thus:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<constraintSpec ident="tables" scheme="schematron">
<constraint>
<sch:ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
<sch:pattern id="Tables">
<sch:rule context="tei:table">
<sch:assert test="tei:head">A &lt;table> should have a caption, using a &lt;head> element</sch:assert>
Expand Down Expand Up @@ -1842,6 +1875,7 @@ xmlns="http://www.tei-c.org/ns/Examples"><attList>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/model.contentPart.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/sequence.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/alternate.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/constraintDecl.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/constraint.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/constraintSpec.xml"/>
<include xmlns="http://www.w3.org/2001/XInclude" href="../../Specs/attList.xml"/>
Expand Down
96 changes: 96 additions & 0 deletions P5/Source/Specs/constraintDecl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- © TEI Consortium. Dual-licensed under CC-by and BSD2 licenses; see the file COPYING.txt for details. -->
<?xml-model href="https://jenkins.tei-c.org/job/TEIP5-dev/lastSuccessfulBuild/artifact/P5/release/xml/tei/odd/p5.nvdl" type="application/xml" schematypens="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"?>
<elementSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:sch="http://purl.oclc.org/dsdl/schematron" module="tagdocs" ident="constraintDecl">
<gloss versionDate="2023-03-09" xml:lang="en">constraint declaration</gloss>
<desc versionDate="2023-03-09" xml:lang="en">contains declarations pertaining to formal constraints expressed elsewhere in <gi>constraintSpec</gi> elements</desc>
<classes>
<memberOf key="att.global"/>
<memberOf key="model.encodingDescPart"/>
raffazizzi marked this conversation as resolved.
Show resolved Hide resolved
<!-- <constraintDecl> is part of content of <schemaSpec> directly, not via a class -->
</classes>
<content>
<sequence>
<alternate minOccurs="0" maxOccurs="unbounded">
<classRef key="model.identEquiv"/>
<classRef key="model.descLike"/>
</alternate>
<anyElement minOccurs="0" maxOccurs="unbounded"/> <!-- typically <sch:ns> elements -->
</sequence>
</content>
<constraintSpec scheme="schematron" ident="one-constraintDecl-per-scheme">
<!-- Note: the “not a descendant of <egXML>” predicate on the
XPath defining $schemes is required for the P5 build process,
not for normal users. (In P5 build validity of <egXML>s are
tested by changing their namespace to TEI, so the tei: prefix
is not sufficient.) —Syd, 2024-09-19 -->
<constraint>
<sch:rule context="/*[ count( //tei:constraintDecl ) gt 1 ]">
<sch:let name="schemes" value="//tei:constraintDecl[ not(ancestor::*[local-name(.) eq 'egXML'] ) ]/@scheme"/>
<sch:let name="disctinct_schemes" value="distinct-values( $schemes )"/>
<sch:assert test="count( $schemes ) eq count( $disctinct_schemes )">
Each &lt;constraintDecl> element should have a @scheme attribute that is distinct from that of all the other &lt;constraintDecl>s.
</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<attList>
<attDef ident="scheme" usage="req">
<desc versionDate="2023-03-09" xml:lang="en">supplies the name of the language to which the declarations herein apply</desc>
<datatype><dataRef key="teidata.enumerated"/></datatype>
<valList type="semi">
<valItem ident="schematron">
<gloss versionDate="2016-09-27" xml:lang="en">ISO Schematron</gloss>
</valItem>
</valList>
<remarks versionDate="2023-03-09" xml:lang="en">
<p>The declarations contained in a particular
<gi>constraintDecl</gi> (including <att>queryBinding</att>, if
present) apply to the <gi>constraintSpec</gi> elements whose
<att>scheme</att> matches the <att>scheme</att> of the
<gi>constraintDecl</gi>.</p>
</remarks>
</attDef>
<attDef ident="queryBinding" usage="rec">
<gloss xml:lang="en" versionDate="2023-03-09">query language binding</gloss>
<desc xml:lang="en" versionDate="2023-03-09">specifies the query
language binding for rule-based schema expressions in
<gi>constraintSpec</gi> elements that have a matching
<att>scheme</att> attribute</desc>
<datatype><dataRef key="teidata.enumerated"/></datatype>
<valList type="semi">
<valItem ident="exslt"/>
<valItem ident="stx"/>
<valItem ident="xslt"/>
<valItem ident="xslt2"/>
<valItem ident="xslt3"/>
<valItem ident="xpath"/>
<valItem ident="xpath2"/>
<valItem ident="xpath3"/>
<valItem ident="xpath31"/>
<valItem ident="xquery"/>
<valItem ident="xquery3"/>
<valItem ident="xquery31"/>
</valList>
<remarks versionDate="2023-03-09" xml:lang="en">
<p>The suggested values above are the values reserved by the
Schematron specification. Only <val>exslt</val>,
<val>stx</val>, <val>xslt</val>, <val>xslt2</val>,
<val>xslt3</val>, <val>xpath2</val>, and <val>xpath3</val> are
defined by the specification. Most processors only support one
or more of <val>xslt</val>, <val>xslt2</val>, and
<val>xslt3</val>.</p>
</remarks>
</attDef>
</attList>
<exemplum xml:lang="en">
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<constraintDecl scheme="schematron" queryBinding="xslt3">
<sch:ns prefix="wwp" uri="http://www.wwp.northeastern.edu/ns/textbase"/>
Copy link
Member

@ebeshero ebeshero Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not function to deliver a specialized namespace to the constraintSpecs that evoke it, but we don't see this until we attempt to validate XML with the output RNG. I had to declare the sch:ns later on within the <constraintSpec> (immediately within a <constraint> element) for it to be recognized by Schematron and function for validation.

</constraintDecl>
</egXML>
</exemplum>
<listRef>
<ptr target="#TDTAGCONS"/>
</listRef>
</elementSpec>
28 changes: 11 additions & 17 deletions P5/Source/Specs/encodingDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,38 @@ source or sources from which it was derived.</desc>
<desc versionDate="2007-12-20" xml:lang="ko">전자 텍스트와 그것의 원전 텍스트 혹은 텍스트들 사이의 관련성을 기록한다.</desc>
<desc versionDate="2007-05-02" xml:lang="zh-TW">記錄電子文件和其ㄧ個或多個文件來源之間的關係。</desc>
<desc versionDate="2008-04-05" xml:lang="ja">電子テキストとその元資料との関係を示す。</desc>
<desc versionDate="2016-11-17" xml:lang="de">dokumentiert das Verhältnis zwischen dem elektronischen Text und seiner Quelle oder den Quellen, von denen er sich ableitet.</desc>
<desc versionDate="2016-11-17" xml:lang="de">dokumentiert das Verhältnis zwischen dem elektronischen Text und seiner Quelle oder den Quellen, von denen er sich ableitet.</desc>
<desc versionDate="2007-05-04" xml:lang="es">documenta la relación entre un texto electrónico y la fuente o fuentes de las que este deriva.</desc>
<desc versionDate="2007-01-21" xml:lang="it">documenta la relazione fra un documento elettronico e la o le fonti da cui è derivato.</desc>
<classes>
<memberOf key="att.global"/>
<memberOf key="model.teiHeaderPart"/>
</classes>
<content>


<alternate minOccurs="1" maxOccurs="unbounded">
<classRef key="model.encodingDescPart"/>
<classRef key="model.pLike"/>
</alternate>


<alternate minOccurs="1" maxOccurs="unbounded">
<classRef key="model.encodingDescPart"/>
<classRef key="model.pLike"/>
</alternate>
raffazizzi marked this conversation as resolved.
Show resolved Hide resolved
</content>
<exemplum xml:lang="en">
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<encodingDesc>
<p>Basic encoding, capturing lexical information only. All
hyphenation, punctuation, and variant spellings normalized. No
formatting or layout information preserved.</p>
hyphenation, punctuation, and variant spellings normalized. No
formatting or layout information preserved.</p>
</encodingDesc>
</egXML>
</exemplum>
<exemplum xml:lang="fr">
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<encodingDesc>
<projectDesc>
<p>Corpus de
textes sélectionnés pour la formation MISAT, Frejus,
juillet 2010.
</p>
<p>Corpus de textes sélectionnés pour la formation MISAT,
Frejus, juillet 2010.</p>
</projectDesc>
<samplingDecl>
<p>Corpus
d'échantillons de 2000 mots pris au début de chaque texte. </p>
<p>Corpus d'échantillons de 2000 mots pris au début de
chaque texte.</p>
</samplingDecl>
</encodingDesc>
</egXML>
Expand Down
Loading