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

Fix #2187, I hope #2188

Merged
merged 6 commits into from
Apr 16, 2022
Merged
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
2 changes: 1 addition & 1 deletion P5/Source/Guidelines/en/TD-DocumentationElements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ to mark any technical term, thus:
<p>In addition to the <gi>content</gi> element, a set of general <gi>constraintSpec</gi> elements can be
used to express rules about the validity of an element. Like some other specification elements, they
are identifiable (using the <att>ident</att> attribute) in order that a TEI customization may
override, delete or change them individually. Each <gi>constraintSpec</gi> can be expressed in any
override, delete, or change them individually. Each <gi>constraintSpec</gi> can be expressed in any
notation which is found useful; the notation used must be recorded using the <att>scheme</att>
attribute.</p>
<p>Schematron is an ISO standard (<ref target="#ISO-19757-3">ISO/IEC 19757-3:2006</ref>) which defines a
Expand Down
33 changes: 22 additions & 11 deletions P5/Source/Specs/constraintSpec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ $Id$
<elementRef key="constraint" minOccurs="0" maxOccurs="1"/>
</sequence>
</content>
<!--
Following <constraintSpec> might be more clearly accomplished
using abstract patterns, but our build process does not
currently support that. For an attempt at using them, see
https://github.com/TEIC/TEI/tree/sydb_issue-2179_1st_via_abstract_pats,
which was my first attempt at doing this. —Syd, 2021-10-13
-->
<constraintSpec scheme="schematron" ident="constraint-unless-delete">
<constraintSpec scheme="schematron" ident="empty-based-on-mode">
<!--
This constraint specification is much like the
"child-constraint-based-on-mode" for <elementSpec>, which
does something something similar (in that it is based on
@mode), but not quite the same.
-->
<constraint>
<sch:rule context="tei:constraintSpec[ @mode eq 'delete' ]">
<sch:report test="child::tei:constraint">This 'constraintSpec' element has a mode= of "delete" even though it has a child constraint. Change the mode= to "add", "change", or "replace", or remove the 'constraint' child.</sch:report>
<sch:rule context="tei:constraintSpec[ @mode eq 'delete']">
<sch:report test="child::*">This constraintSpec element has a mode= of "delete" even though it has child elements. Change the mode= to "add", "change", or "replace", or remove the child elements.</sch:report>
</sch:rule>
<sch:rule context="tei:constraintSpec[ @mode eq 'change']">
<sch:assert test="child::*">This constraintSpec element has a mode= of "change", but does not have any child elements. Specify child elements, or change the mode= to "delete".</sch:assert>
</sch:rule>
<sch:rule context="tei:constraintSpec[ @mode = ('add','replace') ]">
<sch:assert test="child::tei:constraint">This 'constraintSpec' element has a mode= of "<sch:value-of select="@mode"/>", but does not a 'constraint' child element. Specify a constraint or change the mode= to "delete".</sch:assert>
<sch:assert test="child::tei:constraint">This constraintSpec element has a mode= of "<sch:value-of select="@mode"/>", but does not have a child 'constraint' element. Use a child 'constraint' element or change the mode= to "delete" or "change".</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>
Expand Down Expand Up @@ -152,6 +154,15 @@ $Id$
</constraintSpec>
</egXML>
</exemplum>
<remarks xml:lang="en" versionDate="2022-04-09">
<p>A child <gi>constraint</gi> is required when the
<att>mode</att> attribute has the value <val>replace</val> or
<val>add</val> (or is not specified, as <val>add</val> is the
default). No child elements are permitted when the <att>mode</att>
attribute has the value <val>delete</val>. At least one child
element is required when the <att>mode</att> attribute has the
value <val>change</val>.</p>
</remarks>
<listRef>
<ptr target="#TDTAG"/>
</listRef>
Expand Down
6 changes: 6 additions & 0 deletions P5/Source/Specs/elementSpec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ $Id$
</sequence>
</content>
<constraintSpec scheme="schematron" ident="child-constraint-based-on-mode">
<!--
This constraint specification is much like the
"empty-based-on-mode" for <constraintSpec> itself, which does
something something similar (in that it is based on @mode),
but not quite the same.
-->
<constraint>
<sch:rule context="tei:elementSpec[ @mode eq 'delete' ]">
<sch:report test="child::*">This elementSpec element has a mode= of "delete" even though it has child elements. Change the mode= to "add", "change", or "replace", or remove the child elements.</sch:report>
Expand Down
10 changes: 9 additions & 1 deletion P5/Utilities/subset.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
happens to end with a child element.
2020-08-30 by Syd Bauman: Better commenting. Also just copy @xml:id
of bibliographic entries rather than processing them.
2021-10-01 by Syd Bauman: Per #2187, add <constraintSpec> to list
for which we keep_important_stuff_with_contents.
-->

<xsl:output method="xml" indent="no"/>
Expand All @@ -43,7 +45,13 @@

<!-- The important parts get copied over in their entirety: -->
<xsl:template name="keep_important_stuff_with_contents"
match="teiHeader | elementSpec | macroSpec | classSpec | moduleSpec | dataSpec">
match="teiHeader
| elementSpec
| macroSpec
| classSpec
| moduleSpec
| dataSpec
| constraintSpec ">
<xsl:text>&#x0A;</xsl:text>
<xsl:copy-of select="." /> <!--Comments & PIs inside me are copied, too-->
</xsl:template>
Expand Down