lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.0.4 vs lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.0.5
- old
+ new
@@ -18,16 +18,18 @@
<xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:docidentifier[@type = 'csd']"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="/csd:csd-standard/csd:bibdata/csd:copyright/csd:from"/>
</xsl:variable>
- <xsl:variable name="contents">
+ <xsl:variable name="contents_">
<contents>
<xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
<xsl:call-template name="processMainSectionsDefault_Contents"/>
+ <xsl:call-template name="processTablesFigures_Contents"/>
</contents>
</xsl:variable>
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
<xsl:template match="/">
<xsl:call-template name="namespaceCheck"/>
<fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
@@ -188,11 +190,11 @@
<fo:flow flow-name="xsl-region-body">
<xsl:if test="$debug = 'true'">
<xsl:text disable-output-escaping="yes"><!--</xsl:text>
DEBUG
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
+ contents=<xsl:copy-of select="$contents"/>
<xsl:text disable-output-escaping="yes">--></xsl:text>
</xsl:if>
<fo:block margin-bottom="15pt"> </fo:block>
<fo:block margin-bottom="14pt">
@@ -222,18 +224,17 @@
<xsl:with-param name="name" select="'title-toc'"/>
</xsl:call-template>
</xsl:variable>
<fo:block font-size="14pt" margin-bottom="15.5pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
+ <xsl:for-each select="$contents//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
<fo:block role="TOCI">
<xsl:if test="@level = 1">
<xsl:attribute name="margin-top">6pt</xsl:attribute>
</xsl:if>
-
<fo:list-block>
<xsl:attribute name="provisional-distance-between-starts">
<xsl:choose>
<!-- skip 0 section without subsections -->
<xsl:when test="@section != ''">8mm</xsl:when> <!-- and not(@display-section = 'false') -->
@@ -259,10 +260,31 @@
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
</xsl:for-each>
+
+ <!-- List of Tables -->
+ <xsl:if test="$contents//tables/table">
+ <xsl:call-template name="insertListOf_Title">
+ <xsl:with-param name="title" select="$title-list-tables"/>
+ </xsl:call-template>
+ <xsl:for-each select="$contents//tables/table">
+ <xsl:call-template name="insertListOf_Item"/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <!-- List of Figures -->
+ <xsl:if test="$contents//figures/figure">
+ <xsl:call-template name="insertListOf_Title">
+ <xsl:with-param name="title" select="$title-list-figures"/>
+ </xsl:call-template>
+ <xsl:for-each select="$contents//figures/figure">
+ <xsl:call-template name="insertListOf_Item"/>
+ </xsl:for-each>
+ </xsl:if>
+
</fo:block>
</fo:block-container>
<!-- Foreword, Introduction -->
<xsl:call-template name="processPrefaceSectionsDefault"/>
@@ -292,10 +314,44 @@
<!-- End Document Pages -->
</fo:root>
</xsl:template>
+ <xsl:template name="insertListOf_Title">
+ <xsl:param name="title"/>
+ <fo:block role="TOCI" margin-top="6pt" keep-with-next="always">
+ <xsl:value-of select="$title"/>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template name="insertListOf_Item">
+ <fo:block role="TOCI">
+ <fo:list-block provisional-distance-between-starts="8mm">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block/>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
+ <fo:basic-link internal-destination="{@id}">
+ <xsl:call-template name="setAltText">
+ <xsl:with-param name="value" select="@alt-text"/>
+ </xsl:call-template>
+ <xsl:apply-templates select="." mode="contents"/>
+ <fo:inline keep-together.within-line="always">
+ <fo:leader leader-pattern="dots"/>
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
+ </fo:inline>
+ </fo:basic-link>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:block>
+ </xsl:template>
+
+
<xsl:template match="node()">
<xsl:apply-templates/>
</xsl:template>
<!-- ============================= -->
@@ -502,11 +558,11 @@
</fo:block-container>
</fo:static-content>
</xsl:template>
-<xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
+<xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:key name="bibitems" match="*[local-name() = 'bibitem']" use="@id"/><xsl:key name="bibitems_hidden" match="*[local-name() = 'bibitem'][@hidden='true'] | *[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']" use="@id"/><xsl:variable name="lang">
<xsl:call-template name="getLang"/>
</xsl:variable><xsl:variable name="pageWidth_">
210
</xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
297
@@ -548,11 +604,11 @@
<title-toc lang="zh">
<xsl:text>Contents</xsl:text>
</title-toc>
-
+
<title-descriptors lang="en">Descriptors</title-descriptors>
<title-part lang="en">
@@ -584,11 +640,35 @@
<title-continued lang="ru">(продолжение)</title-continued>
<title-continued lang="en">(continued)</title-continued>
<title-continued lang="fr">(continué)</title-continued>
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
+ <xsl:value-of select="$toc_table_title"/>
+ <xsl:if test="normalize-space($toc_table_title) = ''">
+ <xsl:call-template name="getTitle">
+ <xsl:with-param name="name" select="'title-list-tables'"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable><xsl:variable name="title-list-figures">
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
+ <xsl:value-of select="$toc_figure_title"/>
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
+ <xsl:call-template name="getTitle">
+ <xsl:with-param name="name" select="'title-list-figures'"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable><xsl:variable name="title-list-recommendations">
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
+ <xsl:value-of select="$toc_requirement_title"/>
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
+ <xsl:call-template name="getTitle">
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable><xsl:variable name="bibdata">
<xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
<xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
</xsl:variable><xsl:variable name="linebreak">
</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space"></xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
<xsl:param name="name"/>
<xsl:param name="lang"/>
@@ -1788,10 +1868,34 @@
<xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
<xsl:sort select="@displayorder" data-type="number"/>
<xsl:apply-templates select="." mode="contents"/>
</xsl:for-each>
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
+ <xsl:param name="always"/>
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
+ <xsl:call-template name="processTables_Contents"/>
+ </xsl:if>
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
+ <xsl:call-template name="processFigures_Contents"/>
+ </xsl:if>
+ </xsl:template><xsl:template name="processTables_Contents">
+ <tables>
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
+ <xsl:copy-of select="*[local-name() = 'name']"/>
+ </table>
+ </xsl:for-each>
+ </tables>
+ </xsl:template><xsl:template name="processFigures_Contents">
+ <figures>
+ <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name'] and not(@unnumbered = 'true') and normalize-space(@id) != ''] | //*[@id and starts-with(*[local-name() = 'name'], 'Figure ') and normalize-space(@id) != '']">
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
+ <xsl:copy-of select="*[local-name() = 'name']"/>
+ </figure>
+ </xsl:for-each>
+ </figures>
</xsl:template><xsl:template name="processPrefaceSectionsDefault">
<xsl:for-each select="/*/*[local-name()='preface']/*">
<xsl:sort select="@displayorder" data-type="number"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
@@ -2566,41 +2670,11 @@
<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:call-template name="get_fn_list"/>
</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']"/>
@@ -2657,10 +2731,42 @@
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$footnote_inline"/>
</xsl:otherwise>
</xsl:choose>
+ </xsl:template><xsl:template name="get_fn_list">
+ <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:template><xsl:template name="table_fn_display">
<xsl:variable name="references">
<xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
<xsl:call-template name="create_fn"/>
@@ -2828,11 +2934,11 @@
</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']">
+ </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']">
<xsl:variable name="isAdded" select="@added"/>
@@ -4514,17 +4620,18 @@
<xsl:apply-templates select="."/>
</xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
<xsl:apply-templates mode="bookmarks"/>
</xsl:template><xsl:template name="addBookmarks">
<xsl:param name="contents"/>
- <xsl:if test="xalan:nodeset($contents)//item">
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
+ <xsl:if test="$contents_nodes//item">
<fo:bookmark-tree>
<xsl:choose>
- <xsl:when test="xalan:nodeset($contents)/doc">
+ <xsl:when test="$contents_nodes/doc">
<xsl:choose>
- <xsl:when test="count(xalan:nodeset($contents)/doc) > 1">
- <xsl:for-each select="xalan:nodeset($contents)/doc">
+ <xsl:when test="count($contents_nodes/doc) > 1">
+ <xsl:for-each select="$contents_nodes/doc">
<fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
<xsl:if test="@bundle = 'true'">
<xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
</xsl:if>
<fo:bookmark-title>
@@ -4571,11 +4678,11 @@
</fo:bookmark>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
- <xsl:for-each select="xalan:nodeset($contents)/doc">
+ <xsl:for-each select="$contents_nodes/doc">
<xsl:apply-templates select="contents/item" mode="bookmark"/>
<xsl:call-template name="insertFigureBookmarks">
<xsl:with-param name="contents" select="contents"/>
@@ -4589,57 +4696,113 @@
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
+
+ <xsl:call-template name="insertFigureBookmarks">
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="insertTableBookmarks">
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
+ <xsl:with-param name="lang" select="@lang"/>
+ </xsl:call-template>
+
</xsl:otherwise>
</xsl:choose>
+
+
-
-
</fo:bookmark-tree>
</xsl:if>
</xsl:template><xsl:template name="insertFigureBookmarks">
<xsl:param name="contents"/>
- <xsl:if test="xalan:nodeset($contents)/figure">
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
+ <xsl:if test="$contents_nodes/figure">
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
<fo:bookmark-title>Figures</fo:bookmark-title>
- <xsl:for-each select="xalan:nodeset($contents)/figure">
+ <xsl:for-each select="$contents_nodes/figure">
<fo:bookmark internal-destination="{@id}">
<fo:bookmark-title>
<xsl:value-of select="normalize-space(title)"/>
</fo:bookmark-title>
</fo:bookmark>
</xsl:for-each>
</fo:bookmark>
</xsl:if>
+
+
+ <xsl:if test="$contents_nodes//figures/figure">
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
+
+
+
+ <xsl:variable name="bookmark-title">
+
+ <xsl:value-of select="$title-list-figures"/>
+
+ </xsl:variable>
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
+ <xsl:for-each select="$contents_nodes//figures/figure">
+ <fo:bookmark internal-destination="{@id}">
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
+ </fo:bookmark>
+ </xsl:for-each>
+ </fo:bookmark>
+ </xsl:if>
+
</xsl:template><xsl:template name="insertTableBookmarks">
<xsl:param name="contents"/>
<xsl:param name="lang"/>
- <xsl:if test="xalan:nodeset($contents)/table">
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
+ <xsl:if test="$contents_nodes/table">
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
<fo:bookmark-title>
<xsl:choose>
<xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
<xsl:otherwise>Tables</xsl:otherwise>
</xsl:choose>
</fo:bookmark-title>
- <xsl:for-each select="xalan:nodeset($contents)/table">
+ <xsl:for-each select="$contents_nodes/table">
<fo:bookmark internal-destination="{@id}">
<fo:bookmark-title>
<xsl:value-of select="normalize-space(title)"/>
</fo:bookmark-title>
</fo:bookmark>
</xsl:for-each>
</fo:bookmark>
</xsl:if>
+
+
+ <xsl:if test="$contents_nodes//tables/table">
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
+
+
+
+ <xsl:variable name="bookmark-title">
+
+ <xsl:value-of select="$title-list-tables"/>
+
+ </xsl:variable>
+
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
+
+ <xsl:for-each select="$contents_nodes//tables/table">
+ <fo:bookmark internal-destination="{@id}">
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
+ </fo:bookmark>
+ </xsl:for-each>
+ </fo:bookmark>
+ </xsl:if>
+
</xsl:template><xsl:template name="getLangVersion">
<xsl:param name="lang"/>
<xsl:param name="doctype" select="''"/>
<xsl:param name="title" select="''"/>
<xsl:choose>
@@ -5292,10 +5455,12 @@
<xsl:text>]</xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose> -->
</fo:block>
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
</xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
<xsl:if test="normalize-space() != ''">
<xsl:value-of select="."/>
</xsl:if>
</xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
@@ -5366,30 +5531,15 @@
<xsl:apply-templates/>
</fo:basic-link>
</xsl:template><xsl:template match="*[local-name() = 'author']">
<xsl:text>— </xsl:text>
<xsl:apply-templates/>
- </xsl:template><xsl:variable name="bibitem_hidden_">
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
- <xsl:copy-of select="."/>
- </xsl:for-each>
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
- <xsl:copy-of select="."/>
- </xsl:for-each>
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
-
- <xsl:variable name="bibitemid">
- <xsl:choose>
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
<xsl:choose>
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
+ <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
<fo:inline xsl:use-attribute-sets="eref-style">
<xsl:if test="@type = 'footnote'">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
<xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
<xsl:attribute name="vertical-align">super</xsl:attribute>
@@ -5399,12 +5549,12 @@
<xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
<xsl:variable name="text" select="normalize-space()"/>
-
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
+
+ <fo:basic-link fox:alt-text="{@citeas}">
<xsl:if test="normalize-space(@citeas) = ''">
<xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
</xsl:if>
<xsl:if test="@type = 'inline'">
@@ -5413,18 +5563,25 @@
</xsl:if>
+ <xsl:choose>
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
-
<xsl:apply-templates/>
</fo:basic-link>
-
+
</fo:inline>
</xsl:when>
- <xsl:otherwise>
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
<fo:inline><xsl:apply-templates/></fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template><xsl:template match="*[local-name() = 'tab']">
<!-- zero-space char -->
@@ -6156,34 +6313,56 @@
<!-- <fo:inline><xsl:apply-templates /></fo:inline> -->
<fo:inline font-style="italic"> <!-- BIPM BSI CSD CSA GB IEC IHO ISO ITU JCGM -->
<xsl:apply-templates/>
</fo:inline>
</xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
+
+ <!-- list of footnotes to calculate actual footnotes number -->
+ <xsl:variable name="p_fn_">
+ <xsl:call-template name="get_fn_list"/>
+ </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']"/>
+ <!-- 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:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<fo:footnote>
<xsl:variable name="number">
<xsl:choose>
<xsl:when test="ancestor::*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]">
<xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
</xsl:when>
<xsl:otherwise>
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
+ <xsl:value-of select="$current_fn_number"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+
+ <xsl:variable name="current_fn_number_text">
+ <xsl:value-of select="$number"/>
+
+ </xsl:variable>
+
<fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
- <xsl:value-of select="$number"/>
-
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
+ <xsl:value-of select="$current_fn_number_text"/>
</fo:basic-link>
</fo:inline>
<fo:footnote-body>
<fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
- <xsl:value-of select="$number"/>
-
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
+ <xsl:value-of select="$current_fn_number_text"/>
</fo:inline>
<xsl:apply-templates/>
</fo:block>
</fo:footnote-body>
</fo:footnote>
@@ -6419,9 +6598,81 @@
<xsl:apply-templates/>
</fo:block>
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
+ </xsl:copy>
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+
+ <xsl:variable name="nodes_preface_">
+ <xsl:for-each select="*">
+ <node id="{@id}"/>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
+
+ <xsl:for-each select="*">
+ <xsl:sort select="@displayorder" data-type="number"/>
+
+ <!-- process Section's title -->
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
+ <xsl:if test="$preceding-sibling_id != ''">
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:for-each>
+ </xsl:copy>
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+
+ <xsl:variable name="nodes_sections_">
+ <xsl:for-each select="*">
+ <node id="{@id}"/>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
+
+ <!-- move section 'Normative references' inside 'sections' -->
+ <xsl:for-each select="* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
+ <xsl:sort select="@displayorder" data-type="number"/>
+
+ <!-- process Section's title -->
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
+ <xsl:if test="$preceding-sibling_id != ''">
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:for-each>
+ </xsl:copy>
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
+ <xsl:sort select="@displayorder" data-type="number"/>
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
+ </xsl:for-each>
+ </xsl:copy>
</xsl:template><xsl:template name="convertDate">
<xsl:param name="date"/>
<xsl:param name="format" select="'short'"/>
<xsl:variable name="year" select="substring($date, 1, 4)"/>
<xsl:variable name="month" select="substring($date, 6, 2)"/>
\ No newline at end of file