working out source from source= attribute
In odds/odd2odd.xsl the function tei:workOutSource() is used (in quite a few places) to find the set of source specifications in effect during customization ODD processing. One step in this process is to look at the ODD file itself and find out what @source, if any, is in effect. At the moment this is done with
<xsl:choose>
<xsl:when test="$e/@source">
<xsl:value-of select="$e/@source"/>
</xsl:when>
<xsl:when test="$e/ancestor::tei:schemaSpec/@source">
<xsl:value-of select="$e/ancestor::tei:schemaSpec/@source"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$DEFAULTSOURCE"/>
</xsl:otherwise>
</xsl:choose>
The cleaned up version of this (in the sydb-radd branch) is
<xsl:variable name="loc" select="( $context/@source, $context/ancestor::schemaSpec/@source, $DEFAULTSOURCE )[1]"/>
Either way, only 2 elements are being checked for the existence of a @source attribute: the current context node, and its ancestor <schemaSpec>. Seems to me that nowadays, since @source is now global, and might be on an <elementSpec>, e.g., that the code should be looking for @source anywhere:
<xsl:variable name="loc">
<!-- set the context node to what it was when we were called -->
<xsl:for-each select="$context">
<!-- and from there search up the tree for the closest @source, or take the default -->
<xsl:value-of select="( ancestor-or-self::*[@source][1]/@source, $DEFAULTSOURCE )[1]"/>
</xsl:for-each>
</xsl:variable>
Which I think could be written
<xsl:variable name="loc" select="( $context/ancestor-or-self::*[@source][1]/@source, $DEFAULTSOURCE )[1]"/>
but I’m not sure.
EIther way, does that make sense, or am I missing something?
P.S. I do not know what the variable name $loc stands for. I figure it is likely for “local source” or “location of the source”, and I lean towards the latter (as in many cases the source is not local). But I don’t know; ; if you do, please speak up.