I realize there is a whole lot of this thread I have not read (and may not get to for hours … I have 2 more meetings today), but:

What's weird there is this bit:
    <assert test="tei:gloss[ lang('en') ]">
Surely we'd expect <assert test="tei:gloss[@xml:lang='en']">, wouldn't  we? That said, I've never actually used Abstract Patterns in Schematron so I may be missing something obvious.
Nothing to do with abstract pattern vs other use of XPath. The lang() function is an XPath function for testing ancestor-or-self::*/@xml:lang to see if the context item is in the given language or sublanguage of the given language. See https://www.w3.org/TR/xpath-functions-31/#func-lang.

That said, IIRC we require @xml:lang on <gloss>, so just tei:gloss[starts-with( @xml:lang, 'en' )] is probably sufficient if lang() is giving trouble.


The problem seems to be in the generated p5.isosch file, with one or
more of these patterns:

<pattern id="egia-elementSpec" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:elementSpec"/>
              </pattern>
              <pattern id="egia-classSpec" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:classSpec"/>
              </pattern>
              <pattern id="egia-dataSpec" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:dataSpec"/>
              </pattern>
              <pattern id="egia-macroSpec" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:macroSpec"/>
              </pattern>
...

<pattern id="egia-attDef" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:attDef"/>
              </pattern>

...

<pattern id="egia-valItem" is-a="en-gloss-if-any">
                    <param name="gse" value="tei:valItem"/>
              </pattern>

These patterns are used here:

<pattern abstract="true" id="en-gloss-if-any">
       
              <rule context="$gse[tei:gloss]">
                       <assert test="tei:gloss[ lang('en') ]">If there is any gloss
inside <value-of select="name(.)"/>, there must be an English
gloss.</assert>
              </rule>
            </pattern>

What's weird there is this bit:

<assert test="tei:gloss[ lang('en') ]">

Surely we'd expect <assert test="tei:gloss[@xml:lang='en']">, wouldn't
we? That said, I've never actually used Abstract Patterns in Schematron
so I may be missing something obvious.