Skip to content

Commit

Permalink
Merge pull request #420 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 29, 2024
2 parents 13e770b + c651818 commit 2feb3ce
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 2 deletions.
58 changes: 57 additions & 1 deletion lib/isodoc/ieee/ieee.amendment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7077,6 +7077,7 @@

<fo:block role="SKIP">
<xsl:apply-templates/>
<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
</fo:block>
</fo:table-cell>
</xsl:template> <!-- cell in table header row - 'th' -->
Expand Down Expand Up @@ -7140,6 +7141,8 @@

<xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->

<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>

</fo:block>
</fo:table-cell>
</xsl:template> <!-- td -->
Expand Down Expand Up @@ -9980,6 +9983,9 @@
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(.) = ''">
<xsl:call-template name="add-zero-spaces-link-java">
Expand Down Expand Up @@ -15724,6 +15730,12 @@
<!-- Get or calculate depth of the element -->
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getLevel">
<xsl:param name="depth"/>
<!-- <xsl:message>
<xsl:choose>
<xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
<xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
</xsl:choose>
</xsl:message> -->
<xsl:choose>
<xsl:when test="normalize-space(@depth) != ''">
<xsl:value-of select="@depth"/>
Expand All @@ -15744,15 +15756,45 @@
<xsl:when test="ancestor::*[local-name() = 'preface']">
<xsl:value-of select="$level_total - 2"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections']">
<xsl:value-of select="$level_total - 1"/>
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'bibliography']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="parent::*[local-name() = 'annex']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex']">
<xsl:value-of select="$level_total"/>
</xsl:when>
Expand Down Expand Up @@ -16412,4 +16454,18 @@
</xsl:if>
</xsl:template>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*" mode="set_table_role_skip"/>
<xsl:attribute name="role">SKIP</xsl:attribute>
<xsl:apply-templates select="node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
58 changes: 57 additions & 1 deletion lib/isodoc/ieee/ieee.standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7077,6 +7077,7 @@

<fo:block role="SKIP">
<xsl:apply-templates/>
<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
</fo:block>
</fo:table-cell>
</xsl:template> <!-- cell in table header row - 'th' -->
Expand Down Expand Up @@ -7140,6 +7141,8 @@

<xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->

<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>

</fo:block>
</fo:table-cell>
</xsl:template> <!-- td -->
Expand Down Expand Up @@ -9980,6 +9983,9 @@
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(.) = ''">
<xsl:call-template name="add-zero-spaces-link-java">
Expand Down Expand Up @@ -15724,6 +15730,12 @@
<!-- Get or calculate depth of the element -->
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getLevel">
<xsl:param name="depth"/>
<!-- <xsl:message>
<xsl:choose>
<xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
<xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
</xsl:choose>
</xsl:message> -->
<xsl:choose>
<xsl:when test="normalize-space(@depth) != ''">
<xsl:value-of select="@depth"/>
Expand All @@ -15744,15 +15756,45 @@
<xsl:when test="ancestor::*[local-name() = 'preface']">
<xsl:value-of select="$level_total - 2"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections']">
<xsl:value-of select="$level_total - 1"/>
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'bibliography']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="parent::*[local-name() = 'annex']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex']">
<xsl:value-of select="$level_total"/>
</xsl:when>
Expand Down Expand Up @@ -16412,4 +16454,18 @@
</xsl:if>
</xsl:template>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*" mode="set_table_role_skip"/>
<xsl:attribute name="role">SKIP</xsl:attribute>
<xsl:apply-templates select="node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 2feb3ce

Please sign in to comment.