lib/isodoc/un/un.plenary-attachment.xsl in metanorma-un-0.7.3 vs lib/isodoc/un/un.plenary-attachment.xsl in metanorma-un-0.7.4
- old
+ new
@@ -5,14 +5,16 @@
<xsl:param name="svg_images"/>
<xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
<xsl:variable name="images" select="document($svg_images)"/>
<xsl:param name="basepath"/>
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
+
<xsl:variable name="pageWidth" select="210"/>
<xsl:variable name="pageHeight" select="297"/>
<xsl:variable name="marginLeftRight1" select="40"/>
<xsl:variable name="marginLeftRight2" select="40"/>
<xsl:variable name="marginTop" select="30"/>
@@ -335,11 +337,11 @@
</xsl:call-template>
</xsl:variable>
<xsl:variable name="display">
<xsl:choose>
- <xsl:when test="$level > 3">false</xsl:when>
+ <xsl:when test="$level > $toc_level">false</xsl:when>
<xsl:otherwise>true</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="skip">
@@ -551,35 +553,10 @@
</fo:block>
</fo:block-container>
</xsl:template>
- <xsl:template match="un:title/un:fn | un:p/un:fn[not(ancestor::un:table)] | un:figure/un:name/un:fn" priority="2">
- <fo:footnote keep-with-previous.within-line="always">
- <xsl:variable name="number">
- <xsl:number level="any" count="un:fn[not(ancestor::un:table)]"/>
- </xsl:variable>
- <fo:inline font-size="60%" keep-with-previous.within-line="always" vertical-align="super">
- <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}">
- <xsl:value-of select="$number + count(//un:bibitem/un:note)"/>
- </fo:basic-link>
- </fo:inline>
- <fo:footnote-body>
- <fo:block-container margin-left="-8mm">
- <fo:block font-size="9pt" text-align="justify" line-height="125%" font-weight="normal" text-indent="0" margin-left="8mm">
- <fo:inline id="footnote_{@reference}_{$number}" font-size="60%" keep-with-next.within-line="always" vertical-align="super" padding-right="8mm"> <!-- alignment-baseline="hanging" -->
- <xsl:value-of select="$number + count(//un:bibitem/un:note)"/>
- </fo:inline>
- <xsl:for-each select="un:p">
- <xsl:apply-templates/>
- </xsl:for-each>
- </fo:block>
- </fo:block-container>
- </fo:footnote-body>
- </fo:footnote>
- </xsl:template>
-
<xsl:template match="un:fn/un:p">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
@@ -1643,10 +1620,84 @@
</xsl:attribute-set><xsl:attribute-set name="list-style">
</xsl:attribute-set><xsl:attribute-set name="toc-style">
<xsl:attribute name="line-height">135%</xsl:attribute>
+ </xsl:attribute-set><xsl:attribute-set name="fn-style">
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
+ </xsl:attribute-set><xsl:attribute-set name="fn-num-style">
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <xsl:attribute name="font-size">60%</xsl:attribute>
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
+
+
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
+ <xsl:attribute name="font-style">normal</xsl:attribute>
+ <xsl:attribute name="text-indent">0</xsl:attribute>
+ <xsl:attribute name="start-indent">0</xsl:attribute>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
+ <xsl:attribute name="text-align">justify</xsl:attribute>
+ <xsl:attribute name="line-height">125%</xsl:attribute>
+ <xsl:attribute name="margin-left">8mm</xsl:attribute>
+
+
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
+ <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <xsl:attribute name="font-size">60%</xsl:attribute>
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
+ <xsl:attribute name="padding-right">8mm</xsl:attribute>
+
+
</xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="OLD_processPrefaceSectionsDefault_Contents">
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/>
@@ -2612,10 +2663,108 @@
<xsl:apply-templates mode="process"/>
</fo:block>
</xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='name']" mode="process"/><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
<xsl:apply-templates/>
+ </xsl:template><xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" priority="2" name="fn">
+
+ <!-- list of footnotes to calculate actual footnotes number -->
+ <xsl:variable name="p_fn_">
+ <xsl:choose>
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
+ <fn gen_id="{generate-id(.)}">
+ <xsl:copy-of select="@*"/>
+ <xsl:copy-of select="node()"/>
+ </fn>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- itetation for:
+ footnotes in bibdata/title
+ footnotes in bibliography
+ footnotes in document's body (except table's head/body/foot and figure text)
+ -->
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
+ <fn gen_id="{generate-id(.)}">
+ <xsl:copy-of select="@*"/>
+ <xsl:copy-of select="node()"/>
+ </fn>
+ </xsl:for-each>
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
+ <xsl:sort select="@displayorder" data-type="number"/>
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
+ <!-- copy unique fn -->
+ <fn gen_id="{generate-id(.)}">
+ <xsl:copy-of select="@*"/>
+ <xsl:copy-of select="node()"/>
+ </fn>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
+
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
+ <xsl:variable name="reference" select="@reference"/>
+ <!-- fn sequence number in document -->
+ <xsl:variable name="current_fn_number">
+ <xsl:choose>
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
+ <xsl:otherwise>
+ <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="current_fn_number_text">
+ <xsl:value-of select="$current_fn_number"/>
+
+
+ </xsl:variable>
+
+ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
+ <xsl:variable name="footnote_inline">
+ <fo:inline xsl:use-attribute-sets="fn-num-style">
+
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
+ <xsl:value-of select="$current_fn_number_text"/>
+ </fo:basic-link>
+ </fo:inline>
+ </xsl:variable>
+ <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
+ gen_id=<xsl:value-of select="$gen_id"/> -->
+ <xsl:choose>
+ <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
+ <xsl:copy-of select="$footnote_inline"/>
+ </xsl:when>
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
+ <fo:footnote xsl:use-attribute-sets="fn-style">
+ <xsl:copy-of select="$footnote_inline"/>
+ <fo:footnote-body>
+
+ <fo:block-container text-indent="0" start-indent="0">
+
+
+ <xsl:attribute name="margin-left">-8mm</xsl:attribute>
+
+ <fo:block xsl:use-attribute-sets="fn-body-style">
+
+
+ <fo:inline id="{$ref_id}" xsl:use-attribute-sets="fn-body-num-style">
+
+ <xsl:value-of select="$current_fn_number_text"/>
+ </fo:inline>
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:block-container>
+ </fo:footnote-body>
+ </fo:footnote>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$footnote_inline"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template><xsl:template name="fn_display">
<xsl:variable name="references">
<xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
<xsl:call-template name="create_fn"/>
@@ -2804,10 +2953,12 @@
<xsl:value-of select="@reference"/>
</fo:basic-link>
</fo:inline>
+ </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
+ <fo:inline><xsl:value-of select="."/></fo:inline>
</xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
<fo:inline>
<xsl:apply-templates/>
</fo:inline>
</xsl:template><xsl:template match="*[local-name()='dl']">
@@ -3794,26 +3945,10 @@
<fo:inline id="{@id}">
<!-- for first p in annotation, put <x> -->
<xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
<xsl:apply-templates/>
</fo:inline>
- </xsl:template><xsl:template match="*[local-name() = 'modification']">
- <xsl:variable name="title-modified">
-
-
- <xsl:call-template name="getTitle">
- <xsl:with-param name="name" select="'title-modified'"/>
- </xsl:call-template>
-
- </xsl:variable>
-
- <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
- <xsl:choose>
- <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
- <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates/>
</xsl:template><xsl:template match="*[local-name() = 'xref']">
<fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
<xsl:apply-templates/>
</fo:basic-link>
@@ -5059,49 +5194,73 @@
<!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] -->
<xsl:variable name="termsource_text">
<xsl:apply-templates/>
</xsl:variable>
-
- <xsl:choose>
+ <xsl:copy-of select="$termsource_text"/>
+ <!-- <xsl:choose>
<xsl:when test="starts-with(normalize-space($termsource_text), '[')">
- <!-- <xsl:apply-templates /> -->
<xsl:copy-of select="$termsource_text"/>
</xsl:when>
<xsl:otherwise>
-
-
+ <xsl:if test="$namespace = 'bsi'">
+ <xsl:choose>
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>{</xsl:text></xsl:when>
+ <xsl:otherwise><xsl:text>[</xsl:text></xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
<xsl:text>[</xsl:text>
-
- <!-- <xsl:apply-templates /> -->
+ </xsl:if>
<xsl:copy-of select="$termsource_text"/>
-
-
+ <xsl:if test="$namespace = 'bsi'">
+ <xsl:choose>
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>}</xsl:text></xsl:when>
+ <xsl:otherwise><xsl:text>]</xsl:text></xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
<xsl:text>]</xsl:text>
-
+ </xsl:if>
</xsl:otherwise>
- </xsl:choose>
+ </xsl:choose> -->
</fo:block>
</xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
<xsl:if test="normalize-space() != ''">
<xsl:value-of select="."/>
</xsl:if>
- </xsl:template><xsl:variable name="localized.source">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="key">source</xsl:with-param>
- </xsl:call-template>
- </xsl:variable><xsl:template match="*[local-name() = 'origin']">
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
+ <fo:inline>
+
+
+ <xsl:value-of select="."/>
+ </fo:inline>
+ </xsl:template><xsl:template match="*[local-name() = 'origin']">
<fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
<xsl:if test="normalize-space(@citeas) = ''">
<xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
</xsl:if>
-
<fo:inline xsl:use-attribute-sets="origin-style">
<xsl:apply-templates/>
</fo:inline>
+ </fo:basic-link>
+ </xsl:template><xsl:template match="*[local-name() = 'modification']">
+ <xsl:variable name="title-modified">
- </fo:basic-link>
+
+ <xsl:call-template name="getTitle">
+ <xsl:with-param name="name" select="'title-modified'"/>
+ </xsl:call-template>
+
+ </xsl:variable>
+
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
+ <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates/>
</xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
<fo:inline><xsl:apply-templates/></fo:inline>
</xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
<xsl:if test="normalize-space() != ''">
<xsl:value-of select="."/>
@@ -5707,11 +5866,35 @@
</fo:inline>
</xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
<fo:block-container border="1pt solid black" width="50%">
<fo:block> </fo:block>
</fo:block-container>
- </xsl:template><xsl:template match="*[local-name() = 'toc']">
+ </xsl:template><xsl:variable name="toc_level">
+ <xsl:choose>
+ <xsl:when test="1 = 2"/> <!-- to do https://github.com/metanorma/mn-native-pdf/issues/337: if there is value in xml -->
+ <xsl:otherwise><!-- default value -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable><xsl:template match="*[local-name() = 'toc']">
<xsl:param name="colwidths"/>
<xsl:variable name="colwidths_">
<xsl:choose>
<xsl:when test="not($colwidths)">
<xsl:variable name="toc_table_simple">
@@ -6347,6 +6530,16 @@
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
+ </xsl:template><xsl:template name="setAltText">
+ <xsl:param name="value"/>
+ <xsl:attribute name="fox:alt-text">
+ <xsl:choose>
+ <xsl:when test="normalize-space($value) != ''">
+ <xsl:value-of select="$value"/>
+ </xsl:when>
+ <xsl:otherwise>_</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
</xsl:template></xsl:stylesheet>
\ No newline at end of file