TEIC / Stylesheets

TEI XSL Stylesheets
228 stars 124 forks source link

failing to handle `<desc type="deprecationInfo">` when testing for out-of-date descriptions #635

Closed sydb closed 9 months ago

sydb commented 9 months ago

I could have sworn we fixed this already, but cannot find an issue or PR about it (whether open or closed).

In common/functions.xsl tei:descOrGlossOutOfDate() is defined as

  <xsl:function name="tei:descOrGlossOutOfDate">
    <xsl:param name="context"/>
    <xsl:for-each select="$context">
      <xsl:variable name="lang" select="tei:generateDocumentationLang(.)[1]"/>
      <xsl:sequence select="tei:desc[@xml:lang='en']/@versionDate gt tei:desc[@xml:lang=$lang]/@versionDate
                         or tei:gloss[@xml:lang='en']/@versionDate gt tei:gloss[@xml:lang=$lang]/@versionDate"></xsl:sequence>
    </xsl:for-each>
  </xsl:function>

In the case of a structure that is being deprecated via @validUntil, it will (or at least should) have both a <desc xml:lang="en"> to describe the thing being described, and a <desc type="deprecationInfo" xml:lang="en">. Thus the XPath on the L side of the 1st gt in the <xsl:sequence> resolves to a sequence of 2 element nodes, and the function dies as gt does not handle sequences.

The fix is to add something like a [not( @type eq 'deprecationInfo') ] predicate to the both the XPaths that seek <desc> elements (on both L and R side of the gt.)