lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.0.4 vs lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.0.5

- old
+ new

@@ -34,11 +34,11 @@ <!-- Example: <item level="1" id="Foreword" display="true">Foreword</item> <item id="term-script" display="false">3.2</item> --> - <xsl:variable name="contents"> + <xsl:variable name="contents_"> <contents> <!-- <xsl:apply-templates select="/itu:itu-standard/itu:preface/node()" mode="contents"/> --> <xsl:apply-templates select="/itu:itu-standard/itu:sections/itu:clause[@type='scope']" mode="contents"/> <!-- @id = 'scope' --> <!-- Normative references --> @@ -51,12 +51,16 @@ <!-- Bibliography --> <xsl:apply-templates select="/itu:itu-standard/itu:bibliography/itu:references[not(@normative='true')]" mode="contents"/> <!-- @id = 'bibliography' --> <xsl:apply-templates select="//itu:table" mode="contents"/> + <xsl:call-template name="processTablesFigures_Contents"> + <xsl:with-param name="always" select="$doctype = 'technical-report' or $doctype = 'technical-paper'"/> + </xsl:call-template> </contents> </xsl:variable> + <xsl:variable name="contents" select="xalan:nodeset($contents_)"/> <xsl:variable name="doctypeTitle"> <xsl:choose> <xsl:when test="/itu:itu-standard/itu:bibdata/itu:ext/itu:doctype[@language = $lang]"> <xsl:value-of select="/itu:itu-standard/itu:bibdata/itu:ext/itu:doctype[@language = $lang]"/> @@ -971,15 +975,15 @@ </fo:block> <xsl:if test="$debug = 'true'"> <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text> DEBUG - contents=<xsl:copy-of select="xalan:nodeset($contents)"/> + contents=<xsl:copy-of select="$contents"/> <xsl:text disable-output-escaping="yes">--&gt;</xsl:text> </xsl:if> - <xsl:if test="xalan:nodeset($contents)//item[@display = 'true'] and $doctype != 'resolution' and $doctype != 'service-publication'"> + <xsl:if test="$contents//item[@display = 'true'] and $doctype != 'resolution' and $doctype != 'service-publication'"> <fo:block break-after="page"/> <fo:block-container> <fo:block role="TOC"> <fo:block margin-top="6pt" text-align="center" font-weight="bold" role="H1"> <xsl:call-template name="getLocalizedString"> @@ -990,11 +994,11 @@ <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key">Page.sg</xsl:with-param> </xsl:call-template> </fo:block> - <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"> + <xsl:for-each select="$contents//item[@display = 'true']"> <fo:block role="TOCI"> <xsl:if test="@level = 1"> <xsl:attribute name="margin-top">6pt</xsl:attribute> </xsl:if> <xsl:if test="@level &gt;= 2"> @@ -1043,76 +1047,46 @@ </fo:list-item> </fo:list-block> </fo:block> </xsl:for-each> - - <xsl:if test="$doctype = 'technical-report' or $doctype = 'technical-paper'"> - <xsl:if test="//itu:table[@id and itu:name]"> - <xsl:variable name="title-list-tables"> - <xsl:call-template name="getTitle"> - <xsl:with-param name="name" select="'title-list-tables'"/> - </xsl:call-template> - </xsl:variable> - - <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always"> - <xsl:value-of select="$title-list-tables"/> - </fo:block> + + <!-- 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> <fo:block margin-top="6pt" text-align="end" font-weight="bold" keep-with-next="always"> <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key">Page.sg</xsl:with-param> </xsl:call-template> </fo:block> - <fo:block-container> - <xsl:for-each select="//itu:table[@id and itu:name]"> - <fo:block text-align-last="justify" margin-top="6pt" role="TOCI"> - <fo:basic-link internal-destination="{@id}" fox:alt-text="{itu:name}"> - <xsl:apply-templates select="itu:name" mode="contents"/> - <fo:inline keep-together.within-line="always"> - <fo:leader leader-pattern="dots"/> - <fo:page-number-citation ref-id="{@id}"/> - </fo:inline> - </fo:basic-link> - </fo:block> + <xsl:for-each select="$contents//tables/table"> + <xsl:call-template name="insertListOf_Item"/> </xsl:for-each> - </fo:block-container> + </fo:block-container> </xsl:if> - - <xsl:if test="//itu:figure[@id and itu:name]"> - <xsl:variable name="title-list-figures"> - <xsl:call-template name="getTitle"> - <xsl:with-param name="name" select="'title-list-figures'"/> - </xsl:call-template> - </xsl:variable> - - - <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always"> - <xsl:value-of select="$title-list-figures"/> - </fo:block> + + <!-- 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> <fo:block margin-top="6pt" text-align="end" font-weight="bold" keep-with-next="always"> <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key">Page.sg</xsl:with-param> </xsl:call-template> </fo:block> - <fo:block-container> - <xsl:for-each select="//itu:figure[@id and itu:name]"> - <fo:block text-align-last="justify" margin-top="6pt" role="TOCI"> - <fo:basic-link internal-destination="{@id}" fox:alt-text="{itu:name}"> - <xsl:apply-templates select="itu:name" mode="contents"/> - <fo:inline keep-together.within-line="always"> - <fo:leader leader-pattern="dots"/> - <fo:page-number-citation ref-id="{@id}"/> - </fo:inline> - </fo:basic-link> - </fo:block> + <xsl:for-each select="$contents//figures/figure"> + <xsl:call-template name="insertListOf_Item"/> </xsl:for-each> - </fo:block-container> + </fo:block-container> </xsl:if> - </xsl:if> - </fo:block> + + </fo:block> </fo:block-container> </xsl:if> </fo:flow> </fo:page-sequence> @@ -1206,10 +1180,32 @@ </fo:root> </xsl:template> + <xsl:template name="insertListOf_Title"> + <xsl:param name="title"/> + <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always"> + <xsl:value-of select="$title"/> + </fo:block> + </xsl:template> + + <xsl:template name="insertListOf_Item"> + <fo:block text-align-last="justify" margin-top="6pt" role="TOCI"> + <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:page-number-citation ref-id="{@id}"/> + </fo:inline> + </fo:basic-link> + </fo:block> + </xsl:template> + <xsl:template match="node()"> <xsl:apply-templates/> </xsl:template> <!-- ============================= --> @@ -2062,11 +2058,11 @@ <xsl:with-param name="text" select="substring($text, 2)"/> </xsl:call-template> </xsl:if> </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 @@ -2106,11 +2102,11 @@ <title-toc lang="zh"> <xsl:text>Contents</xsl:text> </title-toc> - + <title-descriptors lang="en">Descriptors</title-descriptors> <title-part lang="en"> @@ -2142,11 +2138,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">&#8232;</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"/> @@ -3356,10 +3376,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> @@ -4195,41 +4239,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']"/> @@ -4290,10 +4304,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"/> @@ -4467,11 +4513,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"/> @@ -6177,17 +6223,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) &gt; 1"> - <xsl:for-each select="xalan:nodeset($contents)/doc"> + <xsl:when test="count($contents_nodes/doc) &gt; 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> @@ -6234,11 +6281,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"/> @@ -6252,57 +6299,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> @@ -6955,10 +7058,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()"> @@ -7029,30 +7134,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> @@ -7062,29 +7152,36 @@ <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'"> </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 --> @@ -7841,27 +7938,49 @@ <!-- <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:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/> + <xsl:value-of select="$current_fn_number"/> </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> @@ -8103,9 +8222,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