lib/isodoc/itu/itu.technical-report.xsl in metanorma-itu-2.2.6 vs lib/isodoc/itu/itu.technical-report.xsl in metanorma-itu-2.2.7

- old
+ new

@@ -2682,23 +2682,22 @@ </xsl:attribute-set> <xsl:attribute-set name="table-header-cell-style"> <xsl:attribute name="font-weight">bold</xsl:attribute> - <xsl:attribute name="border">solid black 1pt</xsl:attribute> <xsl:attribute name="padding-left">1mm</xsl:attribute> <xsl:attribute name="padding-right">1mm</xsl:attribute> <xsl:attribute name="display-align">center</xsl:attribute> </xsl:attribute-set> <!-- table-header-cell-style --> <xsl:attribute-set name="table-cell-style"> <xsl:attribute name="display-align">center</xsl:attribute> - <xsl:attribute name="border">solid black 1pt</xsl:attribute> <xsl:attribute name="padding-left">1mm</xsl:attribute> <xsl:attribute name="padding-right">1mm</xsl:attribute> + <xsl:attribute name="border">solid black 1pt</xsl:attribute> <xsl:attribute name="display-align">before</xsl:attribute> </xsl:attribute-set> <!-- table-cell-style --> <xsl:attribute-set name="table-footer-cell-style"> @@ -3437,11 +3436,11 @@ <xsl:for-each select="/*/*[local-name()='annex']"> <xsl:sort select="@displayorder" data-type="number"/> <xsl:apply-templates select="." mode="contents"/> </xsl:for-each> - <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:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0]"> <xsl:sort select="@displayorder" data-type="number"/> <xsl:apply-templates select="." mode="contents"/> </xsl:for-each> </xsl:template> @@ -4386,10 +4385,14 @@ <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/> </xsl:otherwise> </xsl:choose> </xsl:variable> + <xsl:variable name="table_fn_block"> + <xsl:call-template name="table_fn_display"/> + </xsl:variable> + <xsl:variable name="tableWithNotesAndFootnotes"> <fo:table keep-with-previous="always"> <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*"> <xsl:variable name="name" select="local-name()"/> @@ -4452,15 +4455,29 @@ <!-- except gb and bsi --> <xsl:apply-templates select="../*[local-name()='note']"/> + <xsl:variable name="isDisplayRowSeparator"> + + </xsl:variable> + <!-- horizontal row separator --> + <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'"> + <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''"> + <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm"> + <xsl:call-template name="setBordersTableArray"/> + <fo:block font-size="1pt"> </fo:block> + </fo:block-container> + </xsl:if> + </xsl:if> + <!-- fn processing --> - <xsl:call-template name="table_fn_display"/> + <!-- <xsl:call-template name="table_fn_display" /> --> + <xsl:copy-of select="$table_fn_block"/> <!-- for PAS display Notes after footnotes --> </fo:table-cell> </fo:table-row> @@ -4577,10 +4594,32 @@ <xsl:apply-templates/> </fo:table-row> </xsl:template> + <xsl:template name="setBorderUnderRow"> + <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/> + <xsl:choose> + <xsl:when test="$border_under_row_ != ''"> + <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/> + <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable> + <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 --> + <xsl:variable name="border_under_row"> + <xsl:call-template name="split"> + <xsl:with-param name="pText" select="$border_under_row_"/> + </xsl:call-template> + </xsl:variable> + <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]"> + <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <!-- row in table footer (tfoot) --> <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2"> <fo:table-row xsl:use-attribute-sets="table-footer-row-style"> <xsl:call-template name="setTableRowAttributes"/> @@ -4938,12 +4977,20 @@ <!-- ============================ --> <!-- figure's footnotes rendering --> <xsl:template name="fn_display_figure"> + <!-- current figure id --> + <xsl:variable name="figure_id_"> + <xsl:value-of select="@id"/> + <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if> + </xsl:variable> + <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/> + + <!-- all footnotes relates to the current figure --> <xsl:variable name="references"> - <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]"> + <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]"> <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}"> <xsl:apply-templates/> </fn> </xsl:for-each> </xsl:variable> @@ -4952,95 +4999,97 @@ <xsl:variable name="key_iso"> </xsl:variable> - <!-- current hierarchy is 'figure' element --> - <xsl:variable name="following_dl_colwidths"> - <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' --> - <xsl:variable name="simple-table"> - <!-- <xsl:variable name="doc_ns"> - <xsl:if test="$namespace = 'bipm'">bipm</xsl:if> + <fo:block> + + <!-- current hierarchy is 'figure' element --> + <xsl:variable name="following_dl_colwidths"> + <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' --> + <xsl:variable name="simple-table"> + <!-- <xsl:variable name="doc_ns"> + <xsl:if test="$namespace = 'bipm'">bipm</xsl:if> + </xsl:variable> + <xsl:variable name="ns"> + <xsl:choose> + <xsl:when test="normalize-space($doc_ns) != ''"> + <xsl:value-of select="normalize-space($doc_ns)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="substring-before(name(/*), '-')"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> --> + + <xsl:for-each select="*[local-name() = 'dl'][1]"> + <tbody> + <xsl:apply-templates mode="dl"/> + </tbody> + </xsl:for-each> + </xsl:variable> + + <xsl:call-template name="calculate-column-widths"> + <xsl:with-param name="cols-count" select="2"/> + <xsl:with-param name="table" select="$simple-table"/> + </xsl:call-template> + + </xsl:if> </xsl:variable> - <xsl:variable name="ns"> + + <xsl:variable name="maxlength_dt"> + <xsl:for-each select="*[local-name() = 'dl'][1]"> + <xsl:call-template name="getMaxLength_dt"/> + </xsl:for-each> + </xsl:variable> + + <fo:table width="95%" table-layout="fixed"> + <xsl:if test="normalize-space($key_iso) = 'true'"> + <xsl:attribute name="font-size">10pt</xsl:attribute> + + </xsl:if> <xsl:choose> - <xsl:when test="normalize-space($doc_ns) != ''"> - <xsl:value-of select="normalize-space($doc_ns)"/> + <!-- if there 'dl', then set same columns width --> + <xsl:when test="xalan:nodeset($following_dl_colwidths)//column"> + <xsl:call-template name="setColumnWidth_dl"> + <xsl:with-param name="colwidths" select="$following_dl_colwidths"/> + <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/> + </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:value-of select="substring-before(name(/*), '-')"/> + <fo:table-column column-width="5%"/> + <fo:table-column column-width="95%"/> </xsl:otherwise> </xsl:choose> - </xsl:variable> --> + <fo:table-body> + <xsl:for-each select="xalan:nodeset($references)//fn"> + <xsl:variable name="reference" select="@reference"/> + <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note--> + <fo:table-row> + <fo:table-cell> + <fo:block> + <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style"> + <xsl:value-of select="@reference"/> + </fo:inline> + </fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block xsl:use-attribute-sets="figure-fn-body-style"> + <xsl:if test="normalize-space($key_iso) = 'true'"> - <xsl:for-each select="*[local-name() = 'dl'][1]"> - <tbody> - <xsl:apply-templates mode="dl"/> - </tbody> - </xsl:for-each> - </xsl:variable> + <xsl:attribute name="margin-bottom">0</xsl:attribute> - <xsl:call-template name="calculate-column-widths"> - <xsl:with-param name="cols-count" select="2"/> - <xsl:with-param name="table" select="$simple-table"/> - </xsl:call-template> + </xsl:if> + <xsl:copy-of select="./node()"/> + </fo:block> + </fo:table-cell> + </fo:table-row> + </xsl:if> + </xsl:for-each> + </fo:table-body> + </fo:table> - </xsl:if> - </xsl:variable> - - <xsl:variable name="maxlength_dt"> - <xsl:for-each select="*[local-name() = 'dl'][1]"> - <xsl:call-template name="getMaxLength_dt"/> - </xsl:for-each> - </xsl:variable> - - <fo:block> - <fo:table width="95%" table-layout="fixed"> - <xsl:if test="normalize-space($key_iso) = 'true'"> - <xsl:attribute name="font-size">10pt</xsl:attribute> - - </xsl:if> - <xsl:choose> - <!-- if there 'dl', then set same columns width --> - <xsl:when test="xalan:nodeset($following_dl_colwidths)//column"> - <xsl:call-template name="setColumnWidth_dl"> - <xsl:with-param name="colwidths" select="$following_dl_colwidths"/> - <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <fo:table-column column-width="15%"/> - <fo:table-column column-width="85%"/> - </xsl:otherwise> - </xsl:choose> - <fo:table-body> - <xsl:for-each select="xalan:nodeset($references)//fn"> - <xsl:variable name="reference" select="@reference"/> - <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note--> - <fo:table-row> - <fo:table-cell> - <fo:block> - <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style"> - <xsl:value-of select="@reference"/> - </fo:inline> - </fo:block> - </fo:table-cell> - <fo:table-cell> - <fo:block xsl:use-attribute-sets="figure-fn-body-style"> - <xsl:if test="normalize-space($key_iso) = 'true'"> - - <xsl:attribute name="margin-bottom">0</xsl:attribute> - - </xsl:if> - <xsl:copy-of select="./node()"/> - </fo:block> - </fo:table-cell> - </fo:table-row> - </xsl:if> - </xsl:for-each> - </fo:table-body> - </fo:table> </fo:block> </xsl:if> </xsl:template> <!-- fn_display_figure --> @@ -5112,16 +5161,18 @@ <xsl:choose> <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component --> <fo:block margin-bottom="12pt" text-align="left"> - <xsl:variable name="title-where"> + <!-- <xsl:variable name="title-where"> <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key">where</xsl:with-param> </xsl:call-template> </xsl:variable> - <xsl:value-of select="$title-where"/><xsl:text> </xsl:text> + <xsl:value-of select="$title-where"/> --> + <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/> + <xsl:text> </xsl:text> <xsl:apply-templates select="*[local-name()='dt']/*"/> <xsl:text/> <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/> </fo:block> @@ -5129,16 +5180,18 @@ <xsl:when test="$parent = 'formula'"> <!-- a few components --> <fo:block margin-bottom="12pt" text-align="left"> <xsl:attribute name="margin-bottom">6pt</xsl:attribute> - <xsl:variable name="title-where"> + <!-- <xsl:variable name="title-where"> <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key">where</xsl:with-param> </xsl:call-template> </xsl:variable> - <xsl:value-of select="$title-where"/>: + <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> --> + <!-- preceding 'p' with word 'where' --> + <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/> </fo:block> </xsl:when> <!-- END: a few components --> <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure --> <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always"> @@ -5321,10 +5374,13 @@ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/> </xsl:if> </xsl:template> <!-- END: dl --> + <!-- ignore 'p' with 'where' in formula, before 'dl' --> + <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/> + <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']"> <xsl:param name="process">false</xsl:param> <xsl:if test="$process = 'true'"> <fo:block xsl:use-attribute-sets="dl-name-style"> <xsl:apply-templates/> @@ -6158,33 +6214,44 @@ <xsl:template name="add-zero-spaces-java"> <xsl:param name="text" select="."/> <!-- add zero-width space (#x200B) after dot with next non-digit --> <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/> - <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right --> - <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→)','$1​')"/> + <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; --> + <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/> <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after --> <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/> <!-- add zero-width space (#x200B) after characters: 'great than' --> <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' --> <!-- add zero-width space (#x200B) before characters: 'less than' --> <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' --> <!-- add zero-width space (#x200B) before character: { --> <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' --> <!-- add zero-width space (#x200B) after character: , --> <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit --> + <!-- add zero-width space (#x200B) after character: '/' --> + <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' --> - <xsl:value-of select="$text7"/> + <xsl:variable name="text9"> + <xsl:choose> + <xsl:when test="$isGenerateTableIF = 'true'"> + <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs--> + </xsl:when> + <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:value-of select="$text9"/> </xsl:template> <xsl:template name="add-zero-spaces-link-java"> <xsl:param name="text" select="."/> <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. --> <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/> - <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space --> - <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/> + <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ --> + <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/> <!-- remove zero-width space at the end --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/> </xsl:template> <!-- add zero space after dash character (for table's entries) --> @@ -6535,13 +6602,32 @@ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/> </xsl:copy> </xsl:variable> <xsl:copy-of select="$newRow"/> - <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan"> - <xsl:with-param name="previousRow" select="$newRow"/> - </xsl:apply-templates> + <!-- optimize to prevent StackOverflowError, just copy next 'tr' --> + <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/> + <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/> + <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/> + <xsl:choose> + <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0"> + <xsl:copy-of select="following-sibling::tr"/> + </xsl:when> + <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0"> + <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/> + + <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/> + <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan"> + <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/> + </xsl:apply-templates> + </xsl:when> --> + <xsl:otherwise> + <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan"> + <xsl:with-param name="previousRow" select="$newRow"/> + </xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> </xsl:template> <!-- End mode simple-table-rowspan --> <!-- Step 3: add id for each cell --> <!-- mode: simple-table-id --> @@ -6700,10 +6786,31 @@ <xsl:with-param name="tags" select="$formatting_tags"/> <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space --> </xsl:call-template> </xsl:template> + <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting"> + <xsl:variable name="link"> + <link_updated> + <xsl:variable name="target_text"> + <xsl:choose> + <xsl:when test="starts-with(normalize-space(@target), 'mailto:')"> + <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="normalize-space(@target)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="$target_text"/> + </link_updated> + </xsl:variable> + <xsl:for-each select="xalan:nodeset($link)/*"> + <xsl:apply-templates mode="td_text_with_formatting"/> + </xsl:for-each> + </xsl:template> + <xsl:template name="getFormattingTags"> <tags> <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if> <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if> <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if> @@ -7041,11 +7148,11 @@ </xsl:otherwise> </xsl:choose> </xsl:variable> <fo:inline xsl:use-attribute-sets="link-style"> - <xsl:if test="starts-with(normalize-space(@target), 'mailto:')"> + <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])"> <xsl:attribute name="keep-together.within-line">always</xsl:attribute> </xsl:if> <xsl:choose> <xsl:when test="$target_text = ''"> @@ -7404,14 +7511,14 @@ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/> <fo:block xsl:use-attribute-sets="figure-style"> <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/> </fo:block> - <xsl:call-template name="fn_display_figure"/> <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]"> <xsl:call-template name="note"/> </xsl:for-each> + <xsl:call-template name="fn_display_figure"/> <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image --> </fo:block-container> </xsl:template> @@ -7470,11 +7577,17 @@ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when> <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/> + <xsl:variable name="image_width_effective"> + + <xsl:value-of select="$width_effective"/> + + </xsl:variable> + + <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/> <xsl:if test="number($scale) &lt; 100"> <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute> </xsl:if> @@ -8057,10 +8170,17 @@ <fo:bookmark-tree> <xsl:choose> <xsl:when test="$contents_nodes/doc"> <xsl:choose> <xsl:when test="count($contents_nodes/doc) &gt; 1"> + + <xsl:if test="$contents_nodes/collection"> + <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}"> + <fo:bookmark-title>collection.pdf</fo:bookmark-title> + </fo:bookmark> + </xsl:if> + <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> @@ -9940,10 +10060,48 @@ <xsl:with-param name="process">true</xsl:with-param> </xsl:apply-templates> <fo:list-block xsl:use-attribute-sets="list-style"> + <xsl:variable name="provisional_distance_between_starts_"> + <attributes xsl:use-attribute-sets="list-style"> + + </attributes> + </xsl:variable> + <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/> + <xsl:if test="$provisional_distance_between_starts != ''"> + <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute> + </xsl:if> + <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/> + + <!-- increase provisional-distance-between-starts for long lists --> + <xsl:if test="local-name() = 'ol'"> + <!-- Examples: xiii), xviii), xxviii) --> + <xsl:variable name="item_numbers"> + <xsl:for-each select="*[local-name() = 'li']"> + <item><xsl:call-template name="getListItemFormat"/></item> + </xsl:for-each> + </xsl:variable> + + <xsl:variable name="max_length"> + <xsl:for-each select="xalan:nodeset($item_numbers)/item"> + <xsl:sort select="string-length(.)" data-type="number" order="descending"/> + <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if> + </xsl:for-each> + </xsl:variable> + + <!-- base width (provisional-distance-between-starts) for 4 chars --> + <xsl:variable name="addon" select="$max_length - 4"/> + <xsl:if test="$addon &gt; 0"> + <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute> + </xsl:if> + <!-- DEBUG --> + <!-- <xsl:copy-of select="$item_numbers"/> + <max_length><xsl:value-of select="$max_length"/></max_length> + <addon><xsl:value-of select="$addon"/></addon> --> + </xsl:if> + <xsl:if test="*[local-name() = 'name']"> <xsl:attribute name="margin-top">0pt</xsl:attribute> </xsl:if> <xsl:apply-templates select="node()[not(local-name() = 'note')]"/> @@ -10921,11 +11079,11 @@ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b --> <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) --> <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> --> <!-- add &lt; and &gt; to \S --> - <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable> + <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable> <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable> <xsl:variable name="text3"> <text><xsl:for-each select="xalan:nodeset($text2)/text/node()"> <xsl:choose> <xsl:when test="self::text()"> @@ -10943,11 +11101,12 @@ </xsl:variable> <xsl:choose> <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']"> <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY --> - <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable> + <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable> + <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable> <xsl:for-each select="xalan:nodeset($text3)/text/node()"> <xsl:choose> <xsl:when test="self::text()"> <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags"> @@ -11543,9 +11702,26 @@ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:if test="$align = 'indent'"> <xsl:attribute name="margin-left">7mm</xsl:attribute> + </xsl:if> + </xsl:template> + + <xsl:template name="setBlockAttributes"> + <xsl:param name="text_align_default">left</xsl:param> + <xsl:call-template name="setTextAlignment"> + <xsl:with-param name="default" select="$text_align_default"/> + </xsl:call-template> + + <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks --> + <!-- Example: keep-lines-together="true" --> + <xsl:if test="@keep-lines-together = 'true'"> + <xsl:attribute name="keep-together.within-column">always</xsl:attribute> + </xsl:if> + <!-- Example: keep-with-next="true" --> + <xsl:if test="@keep-with-next = 'true'"> + <xsl:attribute name="keep-with-next">always</xsl:attribute> </xsl:if> </xsl:template> <xsl:template name="number-to-words"> <xsl:param name="number"/> \ No newline at end of file