Skip to content

Commit

Permalink
take a crack at issuing warning when ISO Schematron assertion is made…
Browse files Browse the repository at this point in the history
… without a context
  • Loading branch information
sydb committed Dec 15, 2023
1 parent 2abbebc commit 21ba627
Show file tree
Hide file tree
Showing 40 changed files with 562 additions and 562 deletions.
76 changes: 41 additions & 35 deletions P5/Source/Guidelines/en/TD-DocumentationElements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $Id$
<?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"?>
<div xmlns="http://www.tei-c.org/ns/1.0"
type="div1" xml:id="TD" n="27"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:xi="http://www.w3.org/2001/XInclude" >
<head>Documentation Elements</head>
Expand Down Expand Up @@ -840,22 +841,25 @@ to mark any technical term, thus:
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">
<constraintSpec ident="reforkeyorname" scheme="schematron">
<constraintSpec ident="ref-or-key-or-name" scheme="schematron">
<constraint>
<assert xmlns="http://purl.oclc.org/dsdl/schematron" test="@ref or @key or @name">One of the
attributes 'name', 'ref' or 'key' must be supplied</assert>
<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="activemutual" scheme="schematron">
<constraintSpec ident="active-mutual" scheme="schematron">
<constraint>
<report xmlns="http://purl.oclc.org/dsdl/schematron" test="@active and @mutual">Only one of the
attributes @active and @mutual may be supplied</report>
<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="activepassive" scheme="schematron">
<constraintSpec ident="active-passive" scheme="schematron">
<constraint>
<report xmlns="http://purl.oclc.org/dsdl/schematron" test="@passive and not(@active)">the
attribute 'passive' may be supplied only if the attribute 'active' is supplied</report>
<sch:rule context="tei:relation">
<sch:report test="@passive and not(@active)">the attribute @passive may be supplied only if the attribute @active is supplied</sch:report>
</sch:rule>
</constraint>
</constraintSpec>
</egXML>
Expand All @@ -881,16 +885,16 @@ to mark any technical term, thus:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<constraintSpec ident="introtitle" scheme="schematron">
<constraint>
<assert xmlns="http://purl.oclc.org/dsdl/schematron"
test="tei:fileDesc/tei:titleStmt/tei:title[@type='introductory']"> an introductory component
of the title is expected </assert>
<sch:rule context="tei:title">
<sch:assert test="tei:fileDesc/tei:titleStmt/tei:title[@type='introductory']"> an introductory component of the title is expected</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<constraintSpec ident="maintitle" scheme="schematron">
<constraint>
<assert xmlns="http://purl.oclc.org/dsdl/schematron"
test="tei:fileDesc/tei:titleStmt/tei:title[@type='main']"> a main title must be supplied
</assert>
<sch:rule context="tei:title">
<sch:assert test="tei:fileDesc/tei:titleStmt/tei:title[@type='main']"> a main title must be supplied</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
</egXML>
Expand Down Expand Up @@ -1019,32 +1023,32 @@ to mark any technical term, thus:
<dataFacet name="minInclusive" value="-360.0"/>
</dataRef></egXML>
Note that restrictions are either expressed with <att>restriction</att> or <gi>dataFacet</gi>, never both.</p>
<p>A datatype may be used to constrain the textual content of
an element, rather than the value of an attribute. But because
they are intended for use in defining ranges of attribute
values, datatypes may not contain elements or attributes.</p>
<p>A datatype may be used to constrain the textual content of
an element, rather than the value of an attribute. But because
they are intended for use in defining ranges of attribute
values, datatypes may not contain elements or attributes.</p>
<p>The attributes <att>minOccurs</att> and
<att>maxOccurs</att> are available for the case where an
attribute may take more than one value of the type
specified. For example, the <att>columns</att> attribute of
the <gi>layout</gi> element can have one or two non-negative
integers as its value:
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<attDef ident="columns">
<gloss xml:lang="en" versionDate="2007-06-12">columns</gloss>
<desc versionDate="2005-01-14" xml:lang="en">specifies the number of columns per page</desc>
<datatype minOccurs="1" maxOccurs="2">
<dataRef key="teidata.count"/>
</datatype>
<remarks xml:lang="en" versionDate="2017-07-09">
<p>If a single number is given, all pages referenced
have this number of columns. If two numbers are given,
the number of columns per page varies between the
values supplied. Where <att>columns</att> is omitted
the number is assumed to be <val>1</val>.</p>
</remarks>
</attDef>
</egXML>
<attDef ident="columns">
<gloss xml:lang="en" versionDate="2007-06-12">columns</gloss>
<desc versionDate="2005-01-14" xml:lang="en">specifies the number of columns per page</desc>
<datatype minOccurs="1" maxOccurs="2">
<dataRef key="teidata.count"/>
</datatype>
<remarks xml:lang="en" versionDate="2017-07-09">
<p>If a single number is given, all pages referenced
have this number of columns. If two numbers are given,
the number of columns per page varies between the
values supplied. Where <att>columns</att> is omitted
the number is assumed to be <val>1</val>.</p>
</remarks>
</attDef>
</egXML>
indicating that the <att>target</att> attribute may take any number of values, each being of the
same datatype, namely the TEI data specification <ident>teidata.pointer</ident>. As is usual in XML,
multiple values for a single attribute are separated by one or more white space characters. Hence,
Expand Down Expand Up @@ -1075,7 +1079,9 @@ to mark any technical term, thus:
<datatype><dataRef key="teidata.count"/></datatype>
<constraintSpec ident="lessThan150" scheme="schematron">
<constraint>
<report xmlns="http://purl.oclc.org/dsdl/schematron" test=". >= 150"> age at death must be an integer less than 150 </report>
<sch:rule context="@ageAtDeath">
<sch:assert test=". le 150">age at death must be an integer less than 150</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
</attDef>
Expand Down
2 changes: 2 additions & 0 deletions P5/Source/Guidelines/en/USE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ that practice. -->
scheme="schematron"
ident="no_outputs_nor_predicates_4_my_kids">
<constraint>
<sch:rule context="tei:modelSequence">
<sch:report test="tei:model[@output]" role="warning">The 'model' children
of a 'modelSequence' element inherit the @output attribute of the
parent 'modelSequence', and thus should not have their own</sch:report>
</sch:rule>
</constraint>
</constraintSpec>
Expand Down
10 changes: 6 additions & 4 deletions P5/Source/Specs/ab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
</content>
<constraintSpec ident="abstractModel-structure-ab-in-l-or-lg" scheme="schematron">
<constraint>
<sch:report test="(ancestor::tei:l or ancestor::tei:lg) and not( ancestor::tei:floatingText |parent::tei:figure |parent::tei:note )">
Abstract model violation: Lines may not contain higher-level divisions such as p or ab, unless ab is a child of figure or note, or is a descendant of floatingText.
</sch:report>
<sch:rule context="tei:ab">
<sch:report test="(ancestor::tei:l or ancestor::tei:lg) and not( ancestor::tei:floatingText |parent::tei:figure |parent::tei:note )">
Abstract model violation: Lines may not contain higher-level divisions such as p or ab, unless ab is a child of figure or note, or is a descendant of floatingText.
</sch:report>
</sch:rule>
</constraint>
</constraintSpec>
<exemplum xml:lang="en">
Expand Down Expand Up @@ -67,4 +69,4 @@
<listRef>
<ptr target="#SASE"/>
</listRef>
</elementSpec>
</elementSpec>
22 changes: 11 additions & 11 deletions P5/Source/Specs/addSpan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ $Id$
<gloss versionDate="2007-05-04" xml:lang="es">fragmento de texto añadido</gloss>
<gloss versionDate="2007-01-21" xml:lang="it">porzione di testo aggiunta</gloss>
<gloss versionDate="2018-12-28" xml:lang="ja">追加テキストの範囲</gloss>
<desc versionDate="2005-01-14" xml:lang="en">marks the beginning of a longer sequence of text added by an
author, scribe, annotator or corrector (see also <gi>add</gi>).</desc>
<desc versionDate="2005-01-14" xml:lang="en">marks the beginning of a longer sequence of text added by an author, scribe, annotator or corrector (see also <gi>add</gi>).</desc>
<desc versionDate="2007-12-20" xml:lang="ko">저자, 필기사, 주석자, 또는 교정자에 의해 추가된 긴 연쇄의 텍스트 시작부를 표시한다.(<gi>add</gi> 참조)</desc>
<desc versionDate="2007-05-02" xml:lang="zh-TW">標記由作者、抄寫者、註解者或更正者所加入的較長連續文字之開端 (參照<gi>add</gi>) 。</desc>
<desc versionDate="2008-04-05" xml:lang="ja">著者、筆写者、注釈者、校正者の手による長めの追加テキストを挿入する始
点を示す(<gi>add</gi>も参照のこと)。</desc>
<desc versionDate="2009-11-16" xml:lang="fr">marque le début d'une longue partie de texte ajoutée par un auteur, un copiste, un annotateur ou
un correcteur (voir aussi <gi>add</gi>).</desc>
<desc versionDate="2008-04-05" xml:lang="ja">著者、筆写者、注釈者、校正者の手による長めの追加テキストを挿入する始 点を示す(<gi>add</gi>も参照のこと)。</desc>
<desc versionDate="2009-11-16" xml:lang="fr">marque le début d'une longue partie de texte ajoutée par un auteur, un copiste, un annotateur ou un correcteur (voir aussi <gi>add</gi>).</desc>
<desc versionDate="2007-05-04" xml:lang="es">señala el inicio de un fragmento largo de texto añadido por un autor, un transcriptor, un comentarista o un corrector (ver también <gi>add</gi>).</desc>
<desc versionDate="2007-01-21" xml:lang="it">segnala l'inizio di una porzione di testo più lunga aggiunta
da un autore, un trascrittore, un annotatore o un correttore (vedi anche <gi>add</gi>)</desc>
<desc versionDate="2007-01-21" xml:lang="it">segnala l'inizio di una porzione di testo più lunga aggiunta da un autore, un trascrittore, un annotatore o un correttore (vedi anche <gi>add</gi>)</desc>
<classes>
<memberOf key="att.global"/>
<memberOf key="model.global.edit"/>
Expand All @@ -38,12 +34,16 @@ $Id$
<content><empty/></content>
<constraintSpec ident="addSpan-requires-spanTo" scheme="schematron">
<constraint>
<sch:assert test="@spanTo">The @spanTo attribute of <sch:name/> is required.</sch:assert>
<sch:rule context="tei:addSpan">
<sch:assert test="@spanTo">The @spanTo attribute of <sch:name/> is required.</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<constraintSpec ident="addSpan-requires-spanTo-fr" scheme="schematron" xml:lang="fr">
<constraint>
<sch:assert test="@spanTo">L'attribut spanTo est requis.</sch:assert>
<sch:rule context="tei:addSpan">
<sch:assert test="@spanTo">L'attribut spanTo est requis.</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<exemplum xml:lang="en">
Expand Down Expand Up @@ -94,4 +94,4 @@ $Id$
<listRef>
<ptr target="#PHAD"/>
</listRef>
</elementSpec>
</elementSpec>
10 changes: 6 additions & 4 deletions P5/Source/Specs/alternate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ $Id$
</content>
<constraintSpec ident="alternatechilden" scheme="schematron">
<constraint>
<sch:assert test="count(*)&gt;1">The alternate element must have at least two child elements</sch:assert>
<sch:rule context="tei:alternate">
<sch:assert test="count(*) gt 1">The alternate element must have at least two child elements</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<exemplum xml:lang="en">
<egXML xmlns="http://www.tei-c.org/ns/Examples" xml:lang="en" source="#UND"><content>
<alternate>
<elementRef key="name"/>
<elementRef key="persName"/>
<elementRef key="name"/>
<elementRef key="persName"/>
</alternate>
</content>
</egXML>
Expand All @@ -40,4 +42,4 @@ $Id$
<listRef>
<ptr target="#DEFCON" type="div2"/>
</listRef>
</elementSpec>
</elementSpec>
4 changes: 2 additions & 2 deletions P5/Source/Specs/att.repeatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ $Id$
<att>maxOccurs</att> is 1, when <att>maxOccurs</att> is not specified
<att>minOccurs</att> must always be less than or equal to 1.</desc> -->
<constraint>
<sch:rule context="*[ @minOccurs and @maxOccurs ]">
<sch:rule context="tei:*[ @minOccurs and @maxOccurs ]">
<sch:let name="min" value="@minOccurs cast as xs:integer"/>
<sch:let name="max" value="if ( normalize-space( @maxOccurs ) eq 'unbounded') then -1 else @maxOccurs cast as xs:integer"/>
<sch:assert test="$max eq -1 or $max ge $min">@maxOccurs should be greater than or equal to @minOccurs</sch:assert>
</sch:rule>
<sch:rule context="*[ @minOccurs and not( @maxOccurs ) ]">
<sch:rule context="tei:*[ @minOccurs and not( @maxOccurs ) ]">
<sch:assert test="@minOccurs cast as xs:integer lt 2">When @maxOccurs is not specified, @minOccurs must be 0 or 1</sch:assert>
</sch:rule>
</constraint>
Expand Down
Loading

0 comments on commit 21ba627

Please sign in to comment.