lib/isodoc/cc/cc.standard.xsl in metanorma-cc-1.8.3 vs lib/isodoc/cc/cc.standard.xsl in metanorma-cc-1.8.4
- old
+ new
@@ -5,10 +5,12 @@
<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="19"/>
<xsl:variable name="marginLeftRight2" select="19"/>
<xsl:variable name="marginTop" select="20.2"/>
@@ -327,11 +329,11 @@
</xsl:call-template>
</xsl:variable>
<xsl:variable name="display">
<xsl:choose>
- <xsl:when test="$level > 2">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">
@@ -498,39 +500,11 @@
<xsl:if test="$inline = 'true'">
<fo:block> </fo:block>
</xsl:if>
</xsl:template>
- <!--
- <fn reference="1">
- <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
- </fn>
- -->
- <xsl:template match="csd:p/csd:fn">
- <fo:footnote>
- <xsl:variable name="number">
- <xsl:number level="any" count="csd:p/csd:fn"/>
- </xsl:variable>
- <fo:inline font-size="65%" keep-with-previous.within-line="always" vertical-align="super">
- <fo:basic-link internal-destination="footnote_{@reference}" fox:alt-text="footnote {@reference}">
- <!-- <xsl:value-of select="@reference"/> -->
- <xsl:value-of select="$number + count(//csd:bibitem/csd:note)"/><!-- <xsl:text>)</xsl:text> -->
- </fo:basic-link>
- </fo:inline>
- <fo:footnote-body>
- <fo:block font-size="10pt" margin-bottom="12pt">
- <fo:inline id="footnote_{@reference}" keep-with-next.within-line="always" font-size="60%" vertical-align="super"> <!-- baseline-shift="30%" padding-right="3mm" font-size="60%" alignment-baseline="hanging" -->
- <xsl:value-of select="$number + count(//csd:bibitem/csd:note)"/><!-- <xsl:text>)</xsl:text> -->
- </fo:inline>
- <xsl:for-each select="csd:p">
- <xsl:apply-templates/>
- </xsl:for-each>
- </fo:block>
- </fo:footnote-body>
- </fo:footnote>
- </xsl:template>
-
+
<xsl:template match="csd:p/csd:fn/csd:p">
<xsl:apply-templates/>
</xsl:template>
@@ -1376,10 +1350,81 @@
</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">65%</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">10pt</xsl:attribute>
+ <xsl:attribute name="margin-bottom">12pt</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-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"/>
@@ -2308,10 +2353,106 @@
<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">
+
+
+ <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"/>
@@ -2500,10 +2641,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']">
@@ -3492,26 +3635,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>
@@ -4739,66 +4866,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:call-template name="getTitle">
- <xsl:with-param name="name" select="'title-source'"/>
- </xsl:call-template>
- <xsl:text>: </xsl:text>
-
-
- </fo:inline>
-
<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="."/>
@@ -5401,11 +5535,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 -->
+
+
+
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </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">
@@ -6041,6 +6199,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