Skip to content

Commit

Permalink
Merge pull request #284 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 2, 2024
2 parents a886cc9 + 6253584 commit 646ae3a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 18 deletions.
28 changes: 22 additions & 6 deletions lib/isodoc/un/un.plenary-attachment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4278,8 +4278,10 @@

<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}" role="Lbl">
<xsl:copy-of select="$current_fn_number_text"/>
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}"> <!-- note: role="Lbl" removed in https://github.com/metanorma/mn2pdf/issues/291 -->
<fo:inline role="Lbl"> <!-- need for https://github.com/metanorma/metanorma-iso/issues/1003 -->
<xsl:copy-of select="$current_fn_number_text"/>
</fo:inline>
</fo:basic-link>
</xsl:with-param>
</xsl:call-template>
Expand Down Expand Up @@ -4560,7 +4562,7 @@

<xsl:call-template name="refine_fn-reference-style"/>

<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
<xsl:attribute name="internal-destination">
<xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
Expand Down Expand Up @@ -7006,9 +7008,12 @@
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$alt_text}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
Expand All @@ -7035,6 +7040,14 @@
</fo:inline>
</xsl:template> <!-- link -->

<xsl:template name="getAltText">
<xsl:choose>
<xsl:when test="normalize-space(.) = ''"><xsl:value-of select="@target"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space(translate(normalize-space(), ' —', ' -'))"/></xsl:otherwise>
<!-- <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise> -->
</xsl:choose>
</xsl:template>

<!-- ======================== -->
<!-- Appendix processing -->
<!-- ======================== -->
Expand Down Expand Up @@ -7065,7 +7078,7 @@
<xsl:template match="*[local-name() = 'callout']">
<xsl:choose>
<xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{normalize-space()}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -7094,7 +7107,10 @@
<xsl:template match="*[local-name() = 'xref']">
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<fo:basic-link internal-destination="{@target}" fox:alt-text="{$alt_text}" xsl:use-attribute-sets="xref-style">
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>
Expand Down
28 changes: 22 additions & 6 deletions lib/isodoc/un/un.plenary.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4278,8 +4278,10 @@

<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}" role="Lbl">
<xsl:copy-of select="$current_fn_number_text"/>
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}"> <!-- note: role="Lbl" removed in https://github.com/metanorma/mn2pdf/issues/291 -->
<fo:inline role="Lbl"> <!-- need for https://github.com/metanorma/metanorma-iso/issues/1003 -->
<xsl:copy-of select="$current_fn_number_text"/>
</fo:inline>
</fo:basic-link>
</xsl:with-param>
</xsl:call-template>
Expand Down Expand Up @@ -4560,7 +4562,7 @@

<xsl:call-template name="refine_fn-reference-style"/>

<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
<xsl:attribute name="internal-destination">
<xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
Expand Down Expand Up @@ -7006,9 +7008,12 @@
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$alt_text}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
Expand All @@ -7035,6 +7040,14 @@
</fo:inline>
</xsl:template> <!-- link -->

<xsl:template name="getAltText">
<xsl:choose>
<xsl:when test="normalize-space(.) = ''"><xsl:value-of select="@target"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space(translate(normalize-space(), ' —', ' -'))"/></xsl:otherwise>
<!-- <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise> -->
</xsl:choose>
</xsl:template>

<!-- ======================== -->
<!-- Appendix processing -->
<!-- ======================== -->
Expand Down Expand Up @@ -7065,7 +7078,7 @@
<xsl:template match="*[local-name() = 'callout']">
<xsl:choose>
<xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{normalize-space()}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -7094,7 +7107,10 @@
<xsl:template match="*[local-name() = 'xref']">
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<fo:basic-link internal-destination="{@target}" fox:alt-text="{$alt_text}" xsl:use-attribute-sets="xref-style">
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>
Expand Down
28 changes: 22 additions & 6 deletions lib/isodoc/un/un.recommendation.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4377,8 +4377,10 @@

<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}" role="Lbl">
<xsl:copy-of select="$current_fn_number_text"/>
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}"> <!-- note: role="Lbl" removed in https://github.com/metanorma/mn2pdf/issues/291 -->
<fo:inline role="Lbl"> <!-- need for https://github.com/metanorma/metanorma-iso/issues/1003 -->
<xsl:copy-of select="$current_fn_number_text"/>
</fo:inline>
</fo:basic-link>
</xsl:with-param>
</xsl:call-template>
Expand Down Expand Up @@ -4659,7 +4661,7 @@

<xsl:call-template name="refine_fn-reference-style"/>

<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
<xsl:attribute name="internal-destination">
<xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
Expand Down Expand Up @@ -7105,9 +7107,12 @@
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$alt_text}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
Expand All @@ -7134,6 +7139,14 @@
</fo:inline>
</xsl:template> <!-- link -->

<xsl:template name="getAltText">
<xsl:choose>
<xsl:when test="normalize-space(.) = ''"><xsl:value-of select="@target"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space(translate(normalize-space(), ' —', ' -'))"/></xsl:otherwise>
<!-- <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise> -->
</xsl:choose>
</xsl:template>

<!-- ======================== -->
<!-- Appendix processing -->
<!-- ======================== -->
Expand Down Expand Up @@ -7164,7 +7177,7 @@
<xsl:template match="*[local-name() = 'callout']">
<xsl:choose>
<xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{normalize-space()}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -7193,7 +7206,10 @@
<xsl:template match="*[local-name() = 'xref']">
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<fo:basic-link internal-destination="{@target}" fox:alt-text="{$alt_text}" xsl:use-attribute-sets="xref-style">
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>
Expand Down

0 comments on commit 646ae3a

Please sign in to comment.