There is a lot of difficult logic particularly around
`@书社:archived-as` to remove it if it won’t have any effect. This is
unnecessary and it is probably better to just leave these attributes
untouched (akin to how `<书社:link>` is left untouched when invalid).
<xslt:choose>
<xslt:when test="@namespace-uri='&xml;'"/>
<xslt:when test="$context[self::html:* or self::svg:*] and @namespace-uri='' and @local-name='lang'"/>
<xslt:choose>
<xslt:when test="@namespace-uri='&xml;'"/>
<xslt:when test="$context[self::html:* or self::svg:*] and @namespace-uri='' and @local-name='lang'"/>
- <xslt:when test="@namespace-uri='&书社;' and @local-name='archived-as' and $context-nodes/ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)][position()=1 and not(self::书社:archive)]"/>
- <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping' or @local-name='version')"/>
+ <xslt:when test="$and-version and $THISREV and @namespace-uri='&书社;' and @local-name='version'"/>
+ <xslt:when test="@namespace-uri='&书社;' and (@local-name='destination' or @local-name='disable-output-wrapping')"/>
<xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
<xslt:otherwise>
<xslt:attribute>
<xslt:when test="preceding-sibling::*[@local-name=current()/@local-name and @namespace-uri=current()/@namespace-uri]"/>
<xslt:otherwise>
<xslt:attribute>
<xslt:apply-templates select="@*|node()"/>
</xslt:copy>
</xslt:template>
<xslt:apply-templates select="@*|node()"/>
</xslt:copy>
</xslt:template>
- <xslt:template match="@书社:destination|@书社:disable-output-wrapping|@书社:archived-as[../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]]" mode="书社:apply" priority="1"/>
+ <xslt:template match="@书社:destination|@书社:disable-output-wrapping" mode="书社:apply" priority="1"/>
<xslt:template match="书社:archive" mode="书社:apply" priority="1">
<xslt:copy>
<xslt:template match="书社:archive" mode="书社:apply" priority="1">
<xslt:copy>
- <xslt:for-each select="@*">
- <xslt:choose>
- <xslt:when test="local-name()='archived-as' and namespace-uri()='&书社;' and ../ancestor::*[not(self::书社:apply-attributes-to-root or self::书社:apply-attributes)]"/>
- <xslt:otherwise>
- <xslt:apply-templates select="." mode="书社:apply"/>
- </xslt:otherwise>
- </xslt:choose>
- </xslt:for-each>
+ <xslt:apply-templates select="@*" mode="书社:apply"/>
<xslt:for-each select="node()">
<xslt:choose>
<xslt:when test="self::*">
<xslt:for-each select="node()">
<xslt:choose>
<xslt:when test="self::*">