Skip to content

Commit

Permalink
Merge pull request #428 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 1, 2024
2 parents 84e5d23 + 2a7875f commit d9a30b7
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/isodoc/ieee/ieee.amendment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,7 @@
<xsl:template match="ieee:abstract">
<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -2281,6 +2282,7 @@
<xsl:template match="*[local-name() = 'introduction'] | *[local-name() = 'foreword'] | *[local-name() = 'acknowledgements']">
<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13113,6 +13115,29 @@
<!-- END definition -->
<!-- ========== -->

<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="reviews_">
<xsl:for-each select="//*[local-name() = 'review'][@from]">
<xsl:copy>
<xsl:copy-of select="@from"/>
<xsl:copy-of select="@id"/>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="reviews" select="xalan:nodeset($reviews_)"/>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="addReviewHelper">
<!-- if there is review with from="...", then add small helper block for Annot tag adding, see 'review' template -->
<xsl:variable name="curr_id" select="@id"/>
<xsl:variable name="review_id" select="normalize-space($reviews//*[local-name() = 'review'][@from = $curr_id]/@id)"/>
<xsl:if test="$review_id != ''"> <!-- i.e. if review found -->
<fo:block keep-with-next="always" line-height="0.1" id="{$review_id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$review_id}" fox:alt-text="Annot___{$review_id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:if>
<!-- <fo:block>
<curr_id><xsl:value-of select="$curr_id"/></curr_id>
<xsl:copy-of select="$reviews"/>
</fo:block> -->
</xsl:template>

<!-- main sections -->
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">

Expand All @@ -13121,6 +13146,8 @@

<xsl:call-template name="sections_element_style"/>

<xsl:call-template name="addReviewHelper"/>

<xsl:apply-templates/>
</fo:block>

Expand Down Expand Up @@ -13156,6 +13183,7 @@

<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13192,6 +13220,8 @@

<xsl:call-template name="refine_clause_style"/>

<xsl:call-template name="addReviewHelper"/>

<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13244,6 +13274,23 @@

<xsl:variable name="id_from" select="normalize-space(current()/@from)"/>

<xsl:if test="1 = 1">
<xsl:choose>
<!-- if there isn't the attribute '@from', then -->
<xsl:when test="$id_from = ''">
<fo:block id="{@id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@id}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
<!-- if there isn't element with id 'from', then create 'bookmark' here -->
<xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
<xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
</xsl:choose>
</xsl:if>

<xsl:if test="1 = 2">
<xsl:choose>
<!-- if there isn't the attribute '@from', then -->
<xsl:when test="$id_from = ''">
Expand All @@ -13257,6 +13304,7 @@
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
</xsl:choose>
</xsl:if>

</xsl:template>

Expand Down
48 changes: 48 additions & 0 deletions lib/isodoc/ieee/ieee.standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,7 @@
<xsl:template match="ieee:abstract">
<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -2281,6 +2282,7 @@
<xsl:template match="*[local-name() = 'introduction'] | *[local-name() = 'foreword'] | *[local-name() = 'acknowledgements']">
<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13113,6 +13115,29 @@
<!-- END definition -->
<!-- ========== -->

<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="reviews_">
<xsl:for-each select="//*[local-name() = 'review'][@from]">
<xsl:copy>
<xsl:copy-of select="@from"/>
<xsl:copy-of select="@id"/>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="reviews" select="xalan:nodeset($reviews_)"/>

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="addReviewHelper">
<!-- if there is review with from="...", then add small helper block for Annot tag adding, see 'review' template -->
<xsl:variable name="curr_id" select="@id"/>
<xsl:variable name="review_id" select="normalize-space($reviews//*[local-name() = 'review'][@from = $curr_id]/@id)"/>
<xsl:if test="$review_id != ''"> <!-- i.e. if review found -->
<fo:block keep-with-next="always" line-height="0.1" id="{$review_id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$review_id}" fox:alt-text="Annot___{$review_id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:if>
<!-- <fo:block>
<curr_id><xsl:value-of select="$curr_id"/></curr_id>
<xsl:copy-of select="$reviews"/>
</fo:block> -->
</xsl:template>

<!-- main sections -->
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">

Expand All @@ -13121,6 +13146,8 @@

<xsl:call-template name="sections_element_style"/>

<xsl:call-template name="addReviewHelper"/>

<xsl:apply-templates/>
</fo:block>

Expand Down Expand Up @@ -13156,6 +13183,7 @@

<fo:block>
<xsl:call-template name="setId"/>
<xsl:call-template name="addReviewHelper"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13192,6 +13220,8 @@

<xsl:call-template name="refine_clause_style"/>

<xsl:call-template name="addReviewHelper"/>

<xsl:apply-templates/>
</fo:block>
</xsl:template>
Expand Down Expand Up @@ -13244,6 +13274,23 @@

<xsl:variable name="id_from" select="normalize-space(current()/@from)"/>

<xsl:if test="1 = 1">
<xsl:choose>
<!-- if there isn't the attribute '@from', then -->
<xsl:when test="$id_from = ''">
<fo:block id="{@id}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@id}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
<!-- if there isn't element with id 'from', then create 'bookmark' here -->
<xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
<xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@from}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
</xsl:when>
</xsl:choose>
</xsl:if>

<xsl:if test="1 = 2">
<xsl:choose>
<!-- if there isn't the attribute '@from', then -->
<xsl:when test="$id_from = ''">
Expand All @@ -13257,6 +13304,7 @@
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
</xsl:choose>
</xsl:if>

</xsl:template>

Expand Down

0 comments on commit d9a30b7

Please sign in to comment.