lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.0.8 vs lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.1.0

- old
+ new

@@ -564,11 +564,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:param name="add_math_as_text">true</xsl:param><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 @@ -579,25 +579,12 @@ </xsl:variable><xsl:variable name="marginLeftRight2" select="normalize-space($marginLeftRight2_)"/><xsl:variable name="marginTop_"> 20.2 </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_"> 20.3 </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_"> - - <title-edition lang="en"> - - <xsl:text>Edition </xsl:text> - - </title-edition> - <title-edition lang="fr"> - <xsl:text>Édition </xsl:text> - </title-edition> - <title-edition lang="ru"> - <xsl:text>Издание </xsl:text> - </title-edition> - <!-- These titles of Table of contents renders different than determined in localized-strings --> <title-toc lang="en"> <xsl:text>Contents</xsl:text> @@ -673,11 +660,11 @@ </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: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="hair_space"> </xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle"> <xsl:param name="name"/> <xsl:param name="lang"/> <xsl:variable name="lang_"> <xsl:choose> <xsl:when test="$lang != ''"> @@ -721,11 +708,11 @@ </xsl:attribute-set><xsl:template name="insertRootStyle"> <xsl:param name="root-style"/> <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/> <xsl:variable name="additional_fonts_"> - <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']"> + <xsl:for-each select="//*[contains(local-name(), '-standard')][1]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value'] | //*[contains(local-name(), '-standard')][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']"> <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if> </xsl:for-each> </xsl:variable> <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/> @@ -796,11 +783,10 @@ </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style"> - <xsl:attribute name="margin-left">0mm</xsl:attribute> </xsl:attribute-set><xsl:attribute-set name="sourcecode-style"> <xsl:attribute name="white-space">pre</xsl:attribute> <xsl:attribute name="wrap-option">wrap</xsl:attribute> <xsl:attribute name="role">Code</xsl:attribute> @@ -883,10 +869,11 @@ <xsl:attribute name="margin-left">12.5mm</xsl:attribute> + </xsl:attribute-set><xsl:attribute-set name="example-name-style"> <xsl:attribute name="keep-with-next">always</xsl:attribute> <xsl:attribute name="margin-bottom">12pt</xsl:attribute> @@ -1942,33 +1929,45 @@ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@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="."/> </xsl:for-each> - </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text"> - <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable> - <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/> - <xsl:call-template name="replace_fo_inline"> - <xsl:with-param name="text" select="$text"/> - </xsl:call-template> - </xsl:template><xsl:template name="replace_fo_inline"> + </xsl:template><xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable><xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable><xsl:template match="text()" name="text"> + + <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable> + <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/> + <xsl:call-template name="replace_fo_inline_tags"> + <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text"/> + </xsl:call-template> + + </xsl:template><xsl:template name="replace_fo_inline_tags"> + <xsl:param name="tag_open"/> + <xsl:param name="tag_close"/> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, $tag_open)"> <xsl:value-of select="substring-before($text, $tag_open)"/> - <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> + <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> --> <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/> - <xsl:value-of select="substring-before($text_after, $tag_close)"/> - <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> - <xsl:call-template name="replace_fo_inline"> + <fo:inline keep-together.within-line="always"> + <xsl:value-of select="substring-before($text_after, $tag_close)"/> + </fo:inline> + <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> --> + <xsl:call-template name="replace_fo_inline_tags"> + <xsl:with-param name="tag_open" select="$tag_open"/> + <xsl:with-param name="tag_close" select="$tag_close"/> <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/> </xsl:call-template> </xsl:when> <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> </xsl:choose> </xsl:template><xsl:template match="*[local-name()='br']"> <xsl:value-of select="$linebreak"/> + </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']"> + <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline> </xsl:template><xsl:template match="*[local-name()='copyright-statement']"> <fo:block xsl:use-attribute-sets="copyright-statement-style"> <xsl:apply-templates/> </fo:block> </xsl:template><xsl:template match="*[local-name()='copyright-statement']//*[local-name()='title']"> @@ -2030,12 +2029,27 @@ <xsl:call-template name="paragraph"> <xsl:with-param name="margin" select="$margin"/> </xsl:call-template> </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1"> - <!-- <xsl:call-template name="add-zero-spaces"/> --> - <xsl:call-template name="add-zero-spaces-java"/> + <xsl:choose> + <xsl:when test="parent::*[local-name() = 'keep-together_within-line']"> + <xsl:value-of select="."/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="addZeroWidthSpacesToTextNodes"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes"> + <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable> + <!-- <xsl:copy-of select="$text"/> --> + <xsl:for-each select="xalan:nodeset($text)/text/node()"> + <xsl:choose> + <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when> + <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> + </xsl:choose> + </xsl:for-each> </xsl:template><xsl:template match="*[local-name()='table']" name="table"> <xsl:variable name="table-preamble"> @@ -2155,20 +2169,13 @@ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']"> <fo:table-column column-width="{@width}"/> </xsl:for-each> </xsl:when> <xsl:otherwise> - <xsl:for-each select="xalan:nodeset($colwidths)//column"> - <xsl:choose> - <xsl:when test=". = 1 or . = 0"> - <fo:table-column column-width="proportional-column-width(2)"/> - </xsl:when> - <xsl:otherwise> - <fo:table-column column-width="proportional-column-width({.})"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> + <xsl:call-template name="insertTableColumnWidth"> + <xsl:with-param name="colwidths" select="$colwidths"/> + </xsl:call-template> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']"> @@ -2328,10 +2335,11 @@ <xsl:variable name="string_with_added_zerospaces"> <xsl:call-template name="add-zero-spaces-java"> <xsl:with-param name="text" select="$td_text"/> </xsl:call-template> </xsl:variable> + <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> --> <xsl:call-template name="tokenize"> <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> --> <!-- 2009 thinspace --> <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> --> <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space --> @@ -2340,10 +2348,11 @@ <xsl:variable name="max_length"> <xsl:call-template name="max_length"> <xsl:with-param name="words" select="xalan:nodeset($words)"/> </xsl:call-template> </xsl:variable> + <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> --> <width> <xsl:variable name="divider"> <xsl:choose> <xsl:when test="td[$curr-col]/@divide"> <xsl:value-of select="td[$curr-col]/@divide"/> @@ -2372,10 +2381,14 @@ <xsl:with-param name="cols-count" select="$cols-count"/> <xsl:with-param name="curr-col" select="$curr-col +1"/> <xsl:with-param name="table" select="$table"/> </xsl:call-template> </xsl:if> + </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text"> + <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message> + <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> --> + <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/> </xsl:template><xsl:template match="text()" mode="td_text"> <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text> </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text"> <xsl:value-of select="*[local-name()='origin']/@citeas"/> </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text"> @@ -2473,20 +2486,13 @@ <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']"> <fo:table-column column-width="{@width}"/> </xsl:for-each> </xsl:when> <xsl:otherwise> - <xsl:for-each select="xalan:nodeset($colwidths)//column"> - <xsl:choose> - <xsl:when test=". = 1 or . = 0"> - <fo:table-column column-width="proportional-column-width(2)"/> - </xsl:when> - <xsl:otherwise> - <fo:table-column column-width="proportional-column-width({.})"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> + <xsl:call-template name="insertTableColumnWidth"> + <xsl:with-param name="colwidths" select="$colwidths"/> + </xsl:call-template> </xsl:otherwise> </xsl:choose> <fo:table-body> <fo:table-row> @@ -3023,12 +3029,14 @@ <xsl:variable name="key_iso"> <!-- and (not(../@class) or ../@class !='pseudocode') --> </xsl:variable> + <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/> + <xsl:choose> - <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component --> + <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component --> <fo:block margin-bottom="12pt" text-align="left"> <xsl:variable name="title-where"> <xsl:call-template name="getLocalizedString"> @@ -3039,11 +3047,11 @@ <xsl:apply-templates select="*[local-name()='dt']/*"/> <xsl:text/> <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/> </fo:block> - </xsl:when> + </xsl:when> <!-- END: only one component --> <xsl:when test="$parent = 'formula'"> <!-- a few components --> <fo:block margin-bottom="12pt" text-align="left"> @@ -3053,12 +3061,12 @@ <xsl:with-param name="key">where</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:value-of select="$title-where"/> </fo:block> - </xsl:when> - <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> + </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"> @@ -3067,15 +3075,15 @@ <xsl:with-param name="key">key</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:value-of select="$title-key"/> </fo:block> - </xsl:when> + </xsl:when> <!-- END: definition list in a figure --> </xsl:choose> <!-- a few components --> - <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)"> + <xsl:if test="$onlyOneComponent = 'false'"> <fo:block> @@ -3110,46 +3118,59 @@ </xsl:variable> <tbody> <xsl:apply-templates mode="dl"/> </tbody> </xsl:variable> - <!-- html-table<xsl:copy-of select="$html-table"/> --> + <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> --> <xsl:variable name="colwidths"> <xsl:call-template name="calculate-column-widths"> <xsl:with-param name="cols-count" select="2"/> <xsl:with-param name="table" select="$html-table"/> </xsl:call-template> </xsl:variable> - <!-- colwidths=<xsl:copy-of select="$colwidths"/> --> + <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> --> <xsl:variable name="maxlength_dt"> <xsl:call-template name="getMaxLength_dt"/> </xsl:variable> + <xsl:variable name="isContainsKeepTogetherTag_"> + false + </xsl:variable> + <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/> + <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> --> <xsl:call-template name="setColumnWidth_dl"> <xsl:with-param name="colwidths" select="$colwidths"/> <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/> + <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/> </xsl:call-template> + <fo:table-body> <xsl:apply-templates> <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/> </xsl:apply-templates> </fo:table-body> </fo:table> </fo:block> </fo:block> - </xsl:if> + </xsl:if> <!-- END: a few components --> </fo:block-container> </fo:block-container> </xsl:template><xsl:template name="setColumnWidth_dl"> <xsl:param name="colwidths"/> <xsl:param name="maxlength_dt"/> + <xsl:param name="isContainsKeepTogetherTag"/> <xsl:choose> <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table --> <fo:table-column column-width="50%"/> <fo:table-column column-width="50%"/> </xsl:when> <xsl:otherwise> <xsl:choose> + <xsl:when test="$isContainsKeepTogetherTag"> + <xsl:call-template name="insertTableColumnWidth"> + <xsl:with-param name="colwidths" select="$colwidths"/> + </xsl:call-template> + </xsl:when> <!-- to set width check most wide chars like `W` --> <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc --> <fo:table-column column-width="7%"/> <fo:table-column column-width="93%"/> </xsl:when> @@ -3176,24 +3197,29 @@ <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 0.5"> <fo:table-column column-width="40%"/> <fo:table-column column-width="60%"/> </xsl:when> <xsl:otherwise> - <xsl:for-each select="xalan:nodeset($colwidths)//column"> - <xsl:choose> - <xsl:when test=". = 1 or . = 0"> - <fo:table-column column-width="proportional-column-width(2)"/> - </xsl:when> - <xsl:otherwise> - <fo:table-column column-width="proportional-column-width({.})"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> + <xsl:call-template name="insertTableColumnWidth"> + <xsl:with-param name="colwidths" select="$colwidths"/> + </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> + </xsl:template><xsl:template name="insertTableColumnWidth"> + <xsl:param name="colwidths"/> + <xsl:for-each select="xalan:nodeset($colwidths)//column"> + <xsl:choose> + <xsl:when test=". = 1 or . = 0"> + <fo:table-column column-width="proportional-column-width(2)"/> + </xsl:when> + <xsl:otherwise> + <fo:table-column column-width="proportional-column-width({.})"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> </xsl:template><xsl:template name="getMaxLength_dt"> <xsl:variable name="lengths"> <xsl:for-each select="*[local-name()='dt']"> <xsl:variable name="maintext_length" select="string-length(normalize-space(.))"/> <xsl:variable name="attributes"> @@ -3213,32 +3239,43 @@ </xsl:variable> <!-- <xsl:message>DEBUG:<xsl:value-of select="$maxLength"/></xsl:message> --> <xsl:value-of select="$maxLength"/> </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2"> <xsl:param name="key_iso"/> - <!-- <tr> <td>NOTE</td> <td> <xsl:apply-templates /> </td> </tr> --> - <fo:table-row> + <!-- OLD Variant --> + <!-- <fo:table-row> <fo:table-cell> <fo:block margin-top="6pt"> <xsl:if test="normalize-space($key_iso) = 'true'"> <xsl:attribute name="margin-top">0</xsl:attribute> </xsl:if> - <xsl:apply-templates select="*[local-name() = 'name']"/> + <xsl:apply-templates select="*[local-name() = 'name']" /> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block> - <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> + <xsl:apply-templates select="node()[not(local-name() = 'name')]" /> </fo:block> </fo:table-cell> + </fo:table-row> --> + <!-- <tr> + <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td> + </tr> + --> + <fo:table-row> + <fo:table-cell number-columns-spanned="2"> + <fo:block> + <xsl:call-template name="note"/> + </fo:block> + </fo:table-cell> </fo:table-row> </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl"> <tr> <td> <xsl:apply-templates/> @@ -3334,17 +3371,19 @@ <xsl:if test="$font-size != ''"> <xsl:attribute name="font-size"> <xsl:choose> <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when> <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when> - <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when> + <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when> <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:if> <xsl:apply-templates/> </fo:inline> + </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2"> + <xsl:call-template name="add_spaces_to_sourcecode"/> </xsl:template><xsl:template match="*[local-name()='underline']"> <fo:inline text-decoration="underline"> <xsl:apply-templates/> </fo:inline> </xsl:template><xsl:template match="*[local-name()='add']" name="tag_add"> @@ -3488,45 +3527,54 @@ </xsl:if> </xsl:template><xsl:template match="*[local-name() = 'pagebreak']"> <fo:block break-after="page"/> <fo:block> </fo:block> <fo:block break-after="page"/> + </xsl:template><xsl:template match="*[local-name() = 'span']"> + <xsl:apply-templates/> </xsl:template><xsl:template name="tokenize"> <xsl:param name="text"/> <xsl:param name="separator" select="' '"/> <xsl:choose> <xsl:when test="not(contains($text, $separator))"> <word> - <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/> - <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/> <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/> - <xsl:variable name="len_str"> - <xsl:choose> - <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters --> - <xsl:value-of select="$len_str_tmp * 1.5"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$len_str_tmp"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - - <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8"> - <xsl:message> - div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/> - len_str=<xsl:value-of select="$len_str"/> - len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/> - </xsl:message> - </xsl:if> --> - <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars> - <len_str><xsl:value-of select="$len_str"/></len_str> --> <xsl:choose> - <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string --> - <xsl:value-of select="$len_str - $len_str_no_en_chars"/> + <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line --> + <xsl:value-of select="$len_str_tmp"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$len_str"/> + <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/> + <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/> + <xsl:variable name="len_str"> + <xsl:choose> + <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters --> + <xsl:value-of select="$len_str_tmp * 1.5"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$len_str_tmp"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8"> + <xsl:message> + div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/> + len_str=<xsl:value-of select="$len_str"/> + len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/> + </xsl:message> + </xsl:if> --> + <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars> + <len_str><xsl:value-of select="$len_str"/></len_str> --> + <xsl:choose> + <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string --> + <xsl:value-of select="$len_str - $len_str_no_en_chars"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$len_str"/> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </word> </xsl:when> <xsl:otherwise> @@ -3797,59 +3845,94 @@ </xsl:template><xsl:template match="mathml:math"> <xsl:variable name="isAdded" select="@added"/> <xsl:variable name="isDeleted" select="@deleted"/> <fo:inline xsl:use-attribute-sets="mathml-style"> + + + <xsl:call-template name="setTrackChangesStyles"> <xsl:with-param name="isAdded" select="$isAdded"/> <xsl:with-param name="isDeleted" select="$isDeleted"/> </xsl:call-template> + <xsl:if test="$add_math_as_text = 'true'"> + <!-- insert helper tag --> + <!-- set unique font-size (fiction) --> + <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable> + <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space --> + </xsl:if> - - <xsl:variable name="mathml"> - <xsl:apply-templates select="." mode="mathml"/> + <xsl:variable name="mathml_content"> + <xsl:apply-templates select="." mode="mathml_actual_text"/> </xsl:variable> - <fo:instream-foreign-object fox:alt-text="Math"> + + <xsl:call-template name="mathml_instream_object"> + <xsl:with-param name="mathml_content" select="$mathml_content"/> + </xsl:call-template> - - <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/> - <xsl:variable name="comment_text_"> - <xsl:choose> - <xsl:when test="normalize-space($comment_text_following) != ''"> - <xsl:value-of select="$comment_text_following"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/> - - <xsl:if test="normalize-space($comment_text) != ''"> - <!-- put Mathin Alternate Text --> - <xsl:attribute name="fox:alt-text"> - <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/> - </xsl:attribute> - </xsl:if> - - <xsl:variable name="mathml_content"> - <xsl:apply-templates select="." mode="mathml_actual_text"/> - </xsl:variable> - <!-- put MathML in Actual Text --> - <xsl:attribute name="fox:actual-text"> - <xsl:value-of select="$mathml_content"/> - </xsl:attribute> - - - - <xsl:copy-of select="xalan:nodeset($mathml)"/> - </fo:instream-foreign-object> + </fo:inline> + </xsl:template><xsl:template name="getMathml_comment_text"> + <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/> + <xsl:variable name="comment_text_"> + <xsl:choose> + <xsl:when test="normalize-space($comment_text_following) != ''"> + <xsl:value-of select="$comment_text_following"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/> + <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/> + <xsl:value-of select="$comment_text"/> + </xsl:template><xsl:template name="mathml_instream_object"> + <xsl:param name="comment_text"/> + <xsl:param name="mathml_content"/> + + <xsl:variable name="comment_text_"> + <xsl:choose> + <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when> + <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="mathml"> + <xsl:apply-templates select="." mode="mathml"/> + </xsl:variable> + + <fo:instream-foreign-object fox:alt-text="Math"> + + + + + + + + <!-- put MathML in Actual Text --> + <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> --> + <xsl:attribute name="fox:actual-text"> + <xsl:value-of select="$mathml_content"/> + </xsl:attribute> + + <!-- <xsl:if test="$add_math_as_text = 'true'"> --> + <xsl:if test="normalize-space($comment_text_) != ''"> + <!-- put Mathin Alternate Text --> + <xsl:attribute name="fox:alt-text"> + <xsl:value-of select="$comment_text_"/> + </xsl:attribute> + </xsl:if> + <!-- </xsl:if> --> + + <xsl:copy-of select="xalan:nodeset($mathml)"/> + + </fo:instream-foreign-object> </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text"> <!-- <xsl:text>a+b</xsl:text> --> <xsl:text>&lt;</xsl:text> <xsl:value-of select="local-name()"/> <xsl:if test="local-name() = 'math'"> @@ -3876,11 +3959,13 @@ </xsl:template><xsl:template match="mathml:mtext" mode="mathml"> <xsl:copy> <!-- replace start and end spaces to non-break space --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/> </xsl:copy> - </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link"> + </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="mathml:mtd/mathml:mo/text()[. = '/']" mode="mathml"> + <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/> + </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link"> <xsl:variable name="target"> <xsl:choose> <xsl:when test="@updatetype = 'true'"> <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/> </xsl:when> @@ -4467,22 +4552,37 @@ <xsl:value-of select="."/> </xsl:attribute> </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update"> <xsl:copy> <xsl:apply-templates select="@*" mode="svg_update"/> - <xsl:variable name="viewbox"> + <xsl:variable name="viewbox_"> <xsl:call-template name="split"> <xsl:with-param name="pText" select="@viewBox"/> <xsl:with-param name="sep" select="' '"/> </xsl:call-template> </xsl:variable> + <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/> + <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/> + <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/> + <xsl:attribute name="width"> - <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/> + <xsl:choose> + <xsl:when test="$width != ''"> + <xsl:value-of select="round($width)"/> + </xsl:when> + <xsl:otherwise>400</xsl:otherwise> <!-- default width --> + </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> - <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/> + <xsl:choose> + <xsl:when test="$height != ''"> + <xsl:value-of select="round($height)"/> + </xsl:when> + <xsl:otherwise>400</xsl:otherwise> <!-- default height --> + </xsl:choose> </xsl:attribute> + <xsl:apply-templates mode="svg_update"/> </xsl:copy> </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3"> <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/> <xsl:for-each select="*[local-name() = 'svg']"> @@ -4673,12 +4773,16 @@ </xsl:if> </xsl:template><xsl:template match="node()" mode="bookmarks"> <xsl:apply-templates mode="bookmarks"/> </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents"> <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: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() = 'span']" mode="contents"> + <xsl:apply-templates mode="contents"/> + </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks"> <xsl:apply-templates mode="bookmarks"/> + </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks"> + <xsl:apply-templates mode="bookmarks"/> </xsl:template><xsl:template name="addBookmarks"> <xsl:param name="contents"/> <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/> <xsl:if test="$contents_nodes//item"> <fo:bookmark-tree> @@ -4955,11 +5059,13 @@ </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> - </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item"> + </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'xref']" mode="contents"> + <xsl:value-of select="."/> + </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item"> <xsl:text> </xsl:text> </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item"> <xsl:copy> <xsl:apply-templates mode="contents_item"/> </xsl:copy> @@ -4986,13 +5092,26 @@ </xsl:copy> </xsl:if> </xsl:when> <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise> </xsl:choose> + </xsl:template><xsl:template match="text()" mode="contents_item"> + <xsl:call-template name="keep_together_standard_number"/> + </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item"> + <xsl:apply-templates mode="contents_item"/> </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode"> <fo:block-container xsl:use-attribute-sets="sourcecode-container-style"> + + <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']"> + <xsl:attribute name="margin-left">0mm</xsl:attribute> + </xsl:if> + + <xsl:if test="ancestor::*[local-name() = 'example']"> + <xsl:attribute name="margin-right">0mm</xsl:attribute> + </xsl:if> + <xsl:copy-of select="@id"/> <xsl:if test="parent::*[local-name() = 'note']"> <xsl:attribute name="margin-left"> <xsl:choose> @@ -5466,43 +5585,71 @@ <xsl:otherwise> <fo:inline><xsl:apply-templates/></fo:inline> </xsl:otherwise> </xsl:choose> </xsl:template><xsl:template match="*[local-name() = 'example']"> - <fo:block id="{@id}" xsl:use-attribute-sets="example-style"> + + <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style"> + - + <xsl:variable name="fo_element"> - <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if> + <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if> block </xsl:variable> - <!-- display 'EXAMPLE' --> - <xsl:apply-templates select="*[local-name()='name']"> - <xsl:with-param name="fo_element" select="$fo_element"/> - </xsl:apply-templates> + <fo:block-container margin-left="0mm"> - <xsl:choose> - <xsl:when test="contains(normalize-space($fo_element), 'block')"> - <fo:block-container xsl:use-attribute-sets="example-body-style"> - <fo:block-container margin-left="0mm" margin-right="0mm"> - <xsl:apply-templates select="node()[not(local-name() = 'name')]"> + <xsl:choose> + + <xsl:when test="contains(normalize-space($fo_element), 'block')"> + + <!-- display name 'EXAMPLE' in a separate block --> + <fo:block> + <xsl:apply-templates select="*[local-name()='name']"> <xsl:with-param name="fo_element" select="$fo_element"/> </xsl:apply-templates> + </fo:block> + + <fo:block-container xsl:use-attribute-sets="example-body-style"> + <fo:block-container margin-left="0mm" margin-right="0mm"> + <xsl:apply-templates select="node()[not(local-name() = 'name')]"> + <xsl:with-param name="fo_element" select="$fo_element"/> + </xsl:apply-templates> + </fo:block-container> </fo:block-container> - </fo:block-container> - </xsl:when> - <xsl:otherwise> - <fo:inline> - <xsl:apply-templates select="node()[not(local-name() = 'name')]"> - <xsl:with-param name="fo_element" select="$fo_element"/> - </xsl:apply-templates> - </fo:inline> - </xsl:otherwise> - </xsl:choose> - - </fo:block> + </xsl:when> <!-- end block --> + + <xsl:otherwise> <!-- inline --> + + <!-- display 'EXAMPLE' and first element in the same line --> + <fo:block> + <xsl:apply-templates select="*[local-name()='name']"> + <xsl:with-param name="fo_element" select="$fo_element"/> + </xsl:apply-templates> + <fo:inline> + <xsl:apply-templates select="*[not(local-name() = 'name')][1]"> + <xsl:with-param name="fo_element" select="$fo_element"/> + </xsl:apply-templates> + </fo:inline> + </fo:block> + + <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]"> + <!-- display further elements in blocks --> + <fo:block-container xsl:use-attribute-sets="example-body-style"> + <fo:block-container margin-left="0mm" margin-right="0mm"> + <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]"> + <xsl:with-param name="fo_element" select="'block'"/> + </xsl:apply-templates> + </fo:block-container> + </fo:block-container> + </xsl:if> + </xsl:otherwise> <!-- end inline --> + + </xsl:choose> + </fo:block-container> + </fo:block-container> </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']"> <xsl:param name="fo_element">block</xsl:param> <xsl:choose> <xsl:when test="ancestor::*[local-name() = 'appendix']"> @@ -5530,14 +5677,20 @@ <xsl:value-of select="$fo_element"/> </xsl:variable> <xsl:choose> <xsl:when test="starts-with(normalize-space($element), 'block')"> - <fo:block xsl:use-attribute-sets="example-p-style"> - - <xsl:apply-templates/> - </fo:block> + <fo:block-container> + <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')"> + <xsl:attribute name="margin-left">0mm</xsl:attribute> + <xsl:attribute name="margin-right">0mm</xsl:attribute> + </xsl:if> + <fo:block xsl:use-attribute-sets="example-p-style"> + + <xsl:apply-templates/> + </fo:block> + </fo:block-container> </xsl:when> <xsl:otherwise> <fo:inline xsl:use-attribute-sets="example-p-style"> <xsl:apply-templates/> </fo:inline> @@ -5715,11 +5868,20 @@ </fo:basic-link> </fo:inline> </xsl:when> <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) --> - <fo:inline><xsl:apply-templates/></fo:inline> + + <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink --> + <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/> + <xsl:choose> + <xsl:when test="$uri_src != ''"> + <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link> + </xsl:when> + <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise> + </xsl:choose> + </xsl:otherwise> </xsl:choose> </xsl:template><xsl:template match="*[local-name() = 'tab']"> <!-- zero-space char --> <xsl:variable name="depth"> @@ -5897,14 +6059,28 @@ <fo:block break-after="page"/> <fo:block id="{@id}"> </fo:block> <xsl:apply-templates/> - </xsl:template><xsl:template match="*[local-name() = 'review']"> + </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl --> <!-- comment 2019-11-29 --> <!-- <fo:block font-weight="bold">Review:</fo:block> <xsl:apply-templates /> --> + + <xsl:variable name="id_from" select="normalize-space(current()/@from)"/> + + <xsl:choose> + <!-- if there isn't the attribute '@from', then --> + <xsl:when test="$id_from = ''"> + <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block> + </xsl:when> + <!-- if there isn't element with id 'from', then create 'bookmark' here --> + <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])"> + <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block> + </xsl:when> + </xsl:choose> + </xsl:template><xsl:template match="*[local-name() = 'name']/text()"> <!-- 0xA0 to space replacement --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/> </xsl:template><xsl:variable name="ul_labels_"> @@ -6261,11 +6437,14 @@ </fo:block> </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']/text()"> <!-- to split by '_' and other chars --> <xsl:call-template name="add-zero-spaces-java"/> </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark"> - <fo:inline id="{@id}" font-size="1pt"/> + <!-- <fo:inline id="{@id}" font-size="1pt"/> --> + <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline> + <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml --> + <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if> </xsl:template><xsl:template match="*[local-name() = 'errata']"> <!-- <row> <date>05-07-2013</date> <type>Editorial</type> <change>Changed CA-9 Priority Code from P1 to P2 in <xref target="tabled2"/>.</change> @@ -6807,9 +6986,123 @@ <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 match="*[local-name() = 'span']" mode="update_xml_step1"> + <xsl:apply-templates mode="update_xml_step1"/> + </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line"> + <xsl:copy> + <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/> + </xsl:copy> + </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable><xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line"> + + <!-- enclose standard's number into tag 'keep-together_within-line' --> + <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable> + <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> + <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> + <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_"/> + </xsl:call-template></text></xsl:variable> + + <xsl:variable name="parent" select="local-name(..)"/> + + <xsl:variable name="text2"> + <text><xsl:for-each select="xalan:nodeset($text)/text/node()"> + <xsl:copy-of select="."/> + </xsl:for-each></text> + </xsl:variable> + + <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b --> + <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\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()"> + <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_units_"/> + </xsl:call-template></text></xsl:variable> + <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/> + </xsl:when> + <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> + </xsl:choose> + </xsl:for-each></text> + </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: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"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_dots_"/> + </xsl:call-template></text></xsl:variable> + <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/> + </xsl:when> + <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> + </xsl:choose> + </xsl:for-each> + </xsl:when> + <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise> + </xsl:choose> + + </xsl:template><xsl:template name="replace_text_tags"> + <xsl:param name="tag_open"/> + <xsl:param name="tag_close"/> + <xsl:param name="text"/> + <xsl:choose> + <xsl:when test="contains($text, $tag_open)"> + <xsl:value-of select="substring-before($text, $tag_open)"/> + <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/> + + <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}"> + <xsl:value-of select="substring-before($text_after, $tag_close)"/> + </xsl:element> + + <xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_open"/> + <xsl:with-param name="tag_close" select="$tag_close"/> + <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:template name="printEdition"> + <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/> + <xsl:text> </xsl:text> + <xsl:choose> + <xsl:when test="$edition_i18n != ''"> + <!-- Example: <edition language="fr">deuxième édition</edition> --> + <xsl:call-template name="capitalize"> + <xsl:with-param name="str" select="$edition_i18n"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/> + <xsl:if test="$edition != ''"> <!-- Example: 1.3 --> + <xsl:call-template name="capitalize"> + <xsl:with-param name="str"> + <xsl:call-template name="getLocalizedString"> + <xsl:with-param name="key">edition</xsl:with-param> + </xsl:call-template> + </xsl:with-param> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:value-of select="$edition"/> + </xsl:if> + </xsl:otherwise> + </xsl:choose> </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