lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-1.4.3 vs lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-1.4.4

- old
+ new

@@ -7,11 +7,11 @@ <xsl:variable name="images" select="document($svg_images)"/> <xsl:param name="basepath"/> - <xsl:key name="kfn" match="itu:fn[local-name(..) = 'p' or ancestor::*[local-name() = 'title']]" use="@reference"/> + <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="debug">false</xsl:variable> <xsl:variable name="pageWidth" select="210"/> @@ -1013,11 +1013,11 @@ <xsl:for-each select="xalan:nodeset($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 = 2"> + <xsl:if test="@level &gt;= 2"> <xsl:attribute name="margin-top">4pt</xsl:attribute> <!-- <xsl:attribute name="margin-left">12mm</xsl:attribute> --> </xsl:if> <fo:list-block provisional-label-separation="3mm"> <xsl:attribute name="provisional-distance-between-starts"> @@ -1029,19 +1029,19 @@ <xsl:when test="string-length(@section) &gt; 5">22mm</xsl:when> <!-- <xsl:when test="@type = 'annex'">20mm</xsl:when> --> <xsl:otherwise>12mm</xsl:otherwise> </xsl:choose> </xsl:if> - <xsl:if test="@level = 2">26mm</xsl:if> + <xsl:if test="@level &gt;= 2"><xsl:value-of select="(@level - 1) * 26"/>mm</xsl:if> </xsl:when> <!-- --> <xsl:otherwise>0mm</xsl:otherwise> </xsl:choose> </xsl:attribute> <fo:list-item> <fo:list-item-label end-indent="label-end()"> - <xsl:if test="@level =2"> - <xsl:attribute name="start-indent">12mm</xsl:attribute> + <xsl:if test="@level &gt;= 2"> + <xsl:attribute name="start-indent"><xsl:value-of select="(@level - 1) * 12"/>mm</xsl:attribute> </xsl:if> <fo:block> <xsl:if test="@section"> <xsl:value-of select="@section"/> </xsl:if> @@ -1256,11 +1256,11 @@ <xsl:value-of select="local-name()"/> </xsl:variable> <xsl:variable name="display"> <xsl:choose> - <xsl:when test="$level &gt;= 3">false</xsl:when> + <xsl:when test="$level &gt; $toc_level">false</xsl:when> <xsl:when test="$section = '' and $type = 'clause' and $level &gt;= 2">false</xsl:when> <xsl:otherwise>true</xsl:otherwise> </xsl:choose> </xsl:variable> @@ -1844,64 +1844,12 @@ </fo:block> </fo:footnote-body> </fo:footnote> </xsl:template> - <xsl:variable name="p_fn"> - <xsl:for-each select="//itu:fn[local-name(..) = 'p' or ancestor::*[local-name() = 'title']][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:variable> - <xsl:template match="itu:fn[local-name(..) = 'p' or ancestor::*[local-name() = 'title']]" priority="2"> - <xsl:variable name="gen_id" select="generate-id(.)"/> - <xsl:variable name="reference" select="@reference"/> - <xsl:variable name="number"> - <!-- <xsl:number level="any" count="itu:p/itu:fn"/> --> - <xsl:value-of select="count(xalan:nodeset($p_fn)//fn[@reference = $reference]/preceding-sibling::fn) + 1"/> - </xsl:variable> - <xsl:variable name="count_title_footnotes" select="count(/itu:itu-standard/itu:bibdata/itu:note[@type='title-footnote'])"/> - <xsl:variable name="count_bibitem_notes" select="count(//itu:bibitem/itu:note)"/> - <xsl:variable name="current_fn_number" select="$number + $count_title_footnotes + $count_bibitem_notes"/> - <xsl:choose> - <xsl:when test="xalan:nodeset($p_fn)//fn[@gen_id = $gen_id]"> - <fo:footnote> - <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="$current_fn_number"/> - </fo:basic-link> - </fo:inline> - <fo:footnote-body> - <fo:block font-size="11pt" margin-bottom="12pt" text-align="justify" font-style="normal" font-weight="normal"> - <xsl:if test="$doctype = 'service-publication'"> - <xsl:attribute name="font-size">10pt</xsl:attribute> - </xsl:if> - <fo:inline id="footnote_{@reference}_{$number}" font-size="85%" padding-right="2mm" keep-with-next.within-line="always" baseline-shift="30%"> - <xsl:value-of select="$current_fn_number"/> - </fo:inline> - <xsl:for-each select="itu:p"> - <xsl:apply-templates/> - </xsl:for-each> - </fo:block> - </fo:footnote-body> - </fo:footnote> - </xsl:when> - <xsl:otherwise> - <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="$current_fn_number"/> - </fo:basic-link> - </fo:inline> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - <xsl:template match="*[local-name()='tt']" priority="2"> <xsl:variable name="element-name"> <xsl:choose> <xsl:when test="ancestor::itu:dd">fo:inline</xsl:when> <xsl:when test="ancestor::itu:title">fo:inline</xsl:when> @@ -2896,10 +2844,83 @@ </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">11pt</xsl:attribute> + <xsl:attribute name="margin-bottom">12pt</xsl:attribute> + <xsl:attribute name="text-align">justify</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">85%</xsl:attribute> + <xsl:attribute name="padding-right">2mm</xsl:attribute> + <xsl:attribute name="baseline-shift">30%</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"/> @@ -3895,10 +3916,110 @@ <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"> + + + <xsl:if test="$doctype = 'service-publication'"> + <xsl:attribute name="font-size">10pt</xsl:attribute> + </xsl:if> + + <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"/> @@ -4106,10 +4227,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']"> @@ -5115,26 +5238,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> @@ -6370,49 +6477,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="."/> @@ -7020,11 +7151,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"> @@ -7660,6 +7815,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