Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions P5/Source/Specs/attList.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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" module="tagdocs" xml:id="gi-attList" ident="attList">
<elementSpec xmlns="http://www.tei-c.org/ns/1.0" module="tagdocs" xml:id="gi-attList" ident="attList" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<gloss versionDate="2020-12-20" xml:lang="en">attribute list</gloss>
<gloss versionDate="2007-06-12" xml:lang="fr">liste d'attributs</gloss>
<desc versionDate="2005-01-14" xml:lang="en">contains documentation for all the attributes associated with this element, as a series of <gi>attDef</gi> elements.</desc>
Expand All @@ -21,6 +21,66 @@
<elementRef key="attList"/>
</alternate>
</content>
<constraintSpec ident="no_duplicate_attrs" scheme="schematron" xml:lang="en">
<desc>Because it is illegal in XML to have two attributes with the
same name on the same element instance, it is illegal in TEI to
have two <gi>attDef</gi> elements with the same values of
<att>ns</att> and <att>ident</att> in a single <gi>attList</gi>,
unless the parent <gi>attList</gi> has an <att>org</att> of
<val>choice</val>. This applies regardless of the <att>mode</att>
of each <gi>attDef</gi>.</desc>
<constraint>
<sch:rule context="tei:attList[ not( ancestor::tei:attList ) ]">
<!--
Set up a dummy string that contains at least 1 character that
is not legal in a URI, and thus cannot be a namespace.
-->
<sch:let name="notanamespace" value="'☮🄯'"/>
<!-- generate a sequence of my <attDef> descendants -->
<sch:let name="defs" value="descendant::tei:attDef"/>
<!--
get a sequence of @ns & @ident combinations of those
<attDef>s, except ignore those whose parent is an
<attList> that is an alternation, and for which we have
already recorded this @ident. Thus if we see
<attList org="choice">
<attDef ident="klaatu"/>
<attDef ident="bodsworth"/>
<attDef ident="rugglesby"/>
<attDef ident="klaatu"/>
</attList>
The sequence should be ('klaatu','bodsworth','rugglesby','').
-->
<sch:let name="nsidents"
value="for $ad in $defs return
if ( $ad[
parent::tei:attList[ @org eq 'choice']
and
preceding-sibling::tei:attDef[
@ident eq $ad/@ident
and
( @ns, $notanamespace )[1] eq ( $ad/@ns, $notanamespace )[1]
]
]
)
then ''
else normalize-space( if ($ad/@ns) then 'Q{'||$ad/@ns||'}'||$ad/@ident else $ad/@ident )
"/>
<!-- get a sequence of any that occur 2+ times: -->
<sch:let name="dups" value="for $a in $nsidents return ( $nsidents[ . eq $a ][2] )"/>
<!-- remove any duplicates from the list of duplicates (-: -->
<sch:let name="distinct_dups" value="distinct-values( $dups )"/>
<!--
if there are any values in list of distinct duplicates (other than null),
warn user about them:
-->
<sch:assert test="count( $distinct_dups[ . ne ''] ) eq 0">
Within the attribute list defined in <sch:value-of select="ancestor::*[@ident][1]/@ident"/>,
the following attributes have been defined multiple times: <sch:value-of select="$distinct_dups"/>.
</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
<attList>
<attDef ident="org">
<gloss versionDate="2007-07-04" xml:lang="en">organization</gloss>
Expand Down Expand Up @@ -103,7 +163,9 @@
<datatype maxOccurs="unbounded"><dataRef key="teidata.pointer"/></datatype>
</attDef>
<attDef ident="mutual" usage="opt">
<desc versionDate="2005-07-24" xml:lang="en">supplies a list of participants amongst all of whom the relationship holds equally.</desc>
<desc versionDate="2005-07-24" xml:lang="en">supplies a list
of participants amongst all of whom the relationship holds
equally.</desc>
<datatype maxOccurs="unbounded"><dataRef key="teidata.pointer"/></datatype>
</attDef>
</attList>
Expand Down
268 changes: 263 additions & 5 deletions P5/Test/detest.odd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<titleStmt>
<title>Testing errors</title>
<author>Lou Burnard</author>
<author>Sebastian Rhatz</author>
<author xml:id="sbauman.emt">Syd Bauman</author>
</titleStmt>
<publicationStmt>
<p>Published along with TEI P5 as part of its build process test suite</p>
Expand All @@ -20,6 +22,14 @@
<change when="2024-10-29" who="#sbauman.emt">
Added <att>xml:lang</att> to every <gi>constraintSpec</gi>
</change>
<change when="2024-03-13" who="#sbauman.emt">
Add specifications for several new elements
(<gi>no_duplicate_attrs_1_invalid</gi>,
<gi>no_duplicate_attrs_2_valid</gi>,
<gi>no_duplicate_attrs_3_invalid</gi>, and
<gi>no_duplicate_attrs_4_invalid</gi>) that exercise the new
<name>no_duplicate_attrs</name> constraint.
</change>
<change when="2023-08-06" who="#sbauman.emt">
Add the <name>add_missing_scheme</name> and
<name>replace_missing_scheme</name> tests for
Expand Down Expand Up @@ -97,9 +107,7 @@
<constraintSpec mode="add" ident="c2" scheme="schematron" xml:lang="en">
<constraint>
<sch:rule context="tei:p|tei:q">
<sch:report test="contains(@rend,' ')">
multi-valued rend is not supported
</sch:report>
<sch:report test="contains(@rend,' ')"> multi-valued rend is not supported </sch:report>
</sch:rule>
</constraint>
</constraintSpec>
Expand Down Expand Up @@ -175,7 +183,7 @@
<elementSpec ident="div" mode="change">
<constraintSpec mode="add" ident="canondiv" scheme="schematron" xml:lang="en">
<constraint>
<sch:rule context="div">
<sch:rule context="tei:div">
<sch:report test="@type eq 'canon' and parent::tei:div/@type eq 'canon'">
divs of type 'canon' may not be nested
</sch:report>
Expand Down Expand Up @@ -375,7 +383,10 @@
</attList>
</elementSpec>
<elementSpec ident="blort2" mode="add">
<desc xml:lang="en" versionDate="2015-03-27">another completely spurious element made up for testing purposes only</desc>
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="model.pPart.data"/>
</classes>
Expand Down Expand Up @@ -548,6 +559,253 @@
</listRef>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_1_valid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attDef ident="bad" ns="https://www.teitube.com/watch?v=enuOArEfqGo"/>
<attDef ident="good" ns="https://www.teitube.com/watch?v=6YdkQWN59HY"/>
<attDef ident="better" ns="https://www.teitube.com/watch?v=qSzYchDIk7E"/>
<attDef ident="best" ns="https://www.teitube.com/watch?v=klsEniiVg74"/>
<attDef ident="bad" ns="https://www.teitube.com/watch?v=Qikp08PPBf0"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-15">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be valid because
although there are two <att>bad</att> attributes defined
as siblings, they have different namespaces.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema, which is
a good thing, becase defining an attribute twice like
that is an error in at least RELAX NG and DTD.</p>
</remarks>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_1_invalid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attDef ident="bad"/>
<attDef ident="good"/>
<attDef ident="better"/>
<attDef ident="best"/>
<attDef ident="bad"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-13">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be invalid because there
are two <att>bad</att> attributes defined as siblings.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema, which is
a good thing, becase defining an attribute twice like
that is an error in at least RELAX NG and DTD.</p>
</remarks>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_2_valid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attDef ident="have"/>
<attList org="choice">
<attDef ident="fun"/>
<attDef ident="fun"/>
<attDef ident="fun"/>
</attList>
<attDef ident="til"/>
<attDef ident="her"/>
<attDef ident="daddy"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-13">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be valid because,
although there are three <att>fun</att> attributes
defined as siblings, they are in alternation with one
another.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema.</p>
</remarks>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_3_invalid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attList org="choice">
<attDef ident="Your"/>
<attDef ident="My"/>
</attList>
<attDef ident="spirit"/>
<attDef ident="and"/>
<attList org="choice">
<attDef ident="my"/>
<attDef ident="your"/>
</attList>
<attDef ident="voice"/>
<attDef ident="in"/>
<attDef ident="one"/>
<attDef ident="combined"/>
<attDef ident="The"/>
<attDef ident="Phantom"/>
<attDef ident="of"/>
<attDef ident="the"/>
<attDef ident="Opera"/>
<attDef ident="is"/>
<attDef ident="there"/>
<attDef ident="Inside"/>
<attList org="choice">
<attDef ident="my"/>
<attDef ident="your"/>
</attList>
<attDef ident="mind"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-13">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be invalid because there
are both two <att>my</att> and two <att>your</att>
attributes defined, and although each is in an alternate
group, the two <att>my</att> attributes are not in
alternation with one another (nor are the two
<att>your</att>s).</p>
<p>Note that the <att>Your</att> vs <att>your</att> and
<att>The</att> vs <att>the</att> are not problems at all
— XML is completely case sensitive, those are different
attributes.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema, which is
a good thing, becase defining an attribute twice like
that is an error in at least RELAX NG and DTD.</p>
</remarks>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_3_valid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attList org="choice">
<attDef ident="Your"/>
<attDef ident="My"/>
</attList>
<attDef ident="spirit"/>
<attDef ident="and"/>
<attList org="choice">
<attDef ident="my" ns="https://www.teitube.com/watch?v=TM23gaT4zkY"/>
<attDef ident="your" ns="https://www.teitube.com/watch?v=j9qLfyLowjg"/>
</attList>
<attDef ident="voice"/>
<attDef ident="in"/>
<attDef ident="one"/>
<attDef ident="combined"/>
<attDef ident="The"/>
<attDef ident="Phantom"/>
<attDef ident="of"/>
<attDef ident="the"/>
<attDef ident="Opera"/>
<attDef ident="is"/>
<attDef ident="there"/>
<attDef ident="Inside"/>
<attList org="choice">
<attDef ident="my" ns="https://www.teitube.com/watch?v=FKHMRGMkQHU"/>
<attDef ident="your" ns="https://www.teitube.com/watch?v=TQGQgiKDBbU"/>
</attList>
<attDef ident="mind"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-15">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be valid because although there
are both two <att>my</att> and two <att>your</att>
attributes defined that are not in alternation, they are
in different namespaces.</p>
<p>Note that the <att>Your</att> vs <att>your</att> and
<att>The</att> vs <att>the</att> are not problems at all
— XML is completely case sensitive, those are different
attributes.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema, which is
a good thing, becase defining an attribute twice like
that is an error in at least RELAX NG and DTD.</p>
</remarks>
</elementSpec>

<elementSpec ident="no_duplicate_attrs_4_invalid" mode="add">
<desc xml:lang="en" versionDate="2024-03-13">
Another completely spurious element made up for testing purposes only.
For information on what is being tested, see <gi>remarks</gi>.
</desc>
<classes>
<memberOf key="att.global"/>
</classes>
<content><empty/></content>
<attList>
<attDef ident="all"/>
<attDef ident="the"/>
<attDef ident="leaves"/>
<attDef ident="are"/>
<attDef ident="brown"/>
<attList>
<attDef ident="and"/>
<attList>
<attDef ident="the"/>
<attDef ident="sky"/>
</attList>
<attDef ident="is"/>
</attList>
<attDef ident="gray"/>
</attList>
<remarks xml:lang="en" versionDate="2024-03-13">
<p>Here we are testing the Schematron that tests for duplicate
atttribute defintions, i.e. <name>no_duplicate_attrs</name>.</p>
<p>This <gi>attList</gi> should be invalid due to the
two definitions of the <att>the</att> attribute, which
are not in alternation.</p>
<p>Note that because this element is not a member of any
model class nor in any other element’s content model, it
will probably not show up in an output schema, which is
a good thing, becase defining an attribute twice like
that is an error in at least RELAX NG and DTD.</p>
</remarks>
</elementSpec>

<specGrpRef target="#limit_attrs_on_elementRef"/>
<elementSpec ident="test_elementRef_attr_constraints" mode="add">
<desc xml:lang="en" versionDate="2024-05-02">yet another completely spurious element made up for testing purposes only</desc>
Expand Down
Loading