lib/isodoc/itu/itu.recommendation-supplement.xsl in metanorma-itu-2.1.12 vs lib/isodoc/itu/itu.recommendation-supplement.xsl in metanorma-itu-2.1.13
- old
+ new
@@ -2047,10 +2047,12 @@
<xsl:with-param name="text" select="substring($text, 2)"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
+ <xsl:strip-space elements="itu:xref"/>
+
<!-- external parameters -->
<xsl:param name="svg_images"/> <!-- svg images array -->
<xsl:variable name="images" select="document($svg_images)"/>
<xsl:param name="basepath"/> <!-- base path for images -->
@@ -3424,21 +3426,26 @@
<xsl:sort select="@displayorder" data-type="number"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:template>
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
<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:choose>
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when>
+ <xsl:otherwise>
+ <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:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template name="replace_fo_inline_tags">
<xsl:param name="tag_open"/>
@@ -3820,11 +3827,11 @@
<xsl:choose>
<xsl:when test="@width">
<!-- centered table when table name is centered (see table-name-style) -->
- <fo:table table-layout="fixed" width="100%">
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="{@width}"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
@@ -4496,11 +4503,11 @@
<!-- row in table's body (tbody) -->
<xsl:template match="*[local-name()='tr']">
<fo:table-row xsl:use-attribute-sets="table-body-row-style">
- <xsl:if test="*[local-name() = 'th']">
+ <xsl:if test="count(*) = count(*[local-name() = 'th'])"> <!-- row contains 'th' only -->
<xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:if>
<xsl:call-template name="setTableRowAttributes"/>
<xsl:apply-templates/>
@@ -5504,18 +5511,66 @@
<tr>
<td>
<xsl:copy-of select="node()"/>
</td>
<td>
- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
+ <!-- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/> -->
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]" mode="dl_if"/>
<!-- get paragraphs from nested 'dl' -->
<xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
</td>
</tr>
</xsl:template>
<xsl:template match="*[local-name()='dd']" mode="dl_if"/>
+ <xsl:template match="*" mode="dl_if">
+ <xsl:copy-of select="."/>
+ </xsl:template>
+
+ <xsl:template match="*[local-name() = 'p']" mode="dl_if">
+ <xsl:param name="indent"/>
+ <p>
+ <xsl:copy-of select="@*"/>
+ <xsl:value-of select="$indent"/>
+ <xsl:copy-of select="node()"/>
+ </p>
+
+ </xsl:template>
+
+ <xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']" mode="dl_if">
+ <xsl:variable name="list_rendered_">
+ <xsl:apply-templates select="."/>
+ </xsl:variable>
+ <xsl:variable name="list_rendered" select="xalan:nodeset($list_rendered_)"/>
+
+ <xsl:variable name="indent">
+ <xsl:for-each select="($list_rendered//fo:block[not(.//fo:block)])[1]">
+ <xsl:apply-templates select="ancestor::*[@provisional-distance-between-starts]/@provisional-distance-between-starts" mode="dl_if"/>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:apply-templates mode="dl_if">
+ <xsl:with-param name="indent" select="$indent"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="*[local-name() = 'li']" mode="dl_if">
+ <xsl:param name="indent"/>
+ <xsl:apply-templates mode="dl_if">
+ <xsl:with-param name="indent" select="$indent"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="@provisional-distance-between-starts" mode="dl_if">
+ <xsl:variable name="value" select="round(substring-before(.,'mm'))"/>
+ <!-- emulate left indent for list item -->
+ <xsl:call-template name="repeat">
+ <xsl:with-param name="char" select="'x'"/>
+ <xsl:with-param name="count" select="$value"/>
+ </xsl:call-template>
+ </xsl:template>
+
<xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
<xsl:for-each select="*[local-name() = 'dt']">
<p>
<xsl:copy-of select="node()"/>
<xsl:text> </xsl:text>
@@ -5905,10 +5960,11 @@
<xsl:with-param name="tags" select="$tags"/>
</xsl:call-template>
</word>
<xsl:call-template name="tokenize_with_tags">
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
+ <xsl:with-param name="tags" select="$tags"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -5944,12 +6000,22 @@
</xsl:for-each>
</xsl:template>
<xsl:template name="add-zero-spaces-java">
<xsl:param name="text" select="."/>
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1')"/>
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1')"/>
+ <!-- add zero-width space (#x200B) after characters: 'great than' -->
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1), '(\u003e)(?!\u003e)', '$1')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
+ <!-- add zero-width space (#x200B) before characters: 'less than' -->
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(?<!\u003c)(\u003c)', '$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
+ <!-- add zero-width space (#x200B) before character: { -->
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?<!\W)(\{)', '$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
+ <!-- add zero-width space (#x200B) after character: , -->
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1')"/> <!-- negative lookahead: ',' not followed by digit -->
+
+ <xsl:value-of select="$text5"/>
</xsl:template>
<xsl:template name="add-zero-spaces-link-java">
<xsl:param name="text" select="."/>
@@ -6091,11 +6157,11 @@
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="table-without-br"/>
</xsl:copy>
</xsl:template>
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
+ <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode'])]" mode="table-without-br">
<xsl:copy>
<xsl:copy-of select="@*"/>
<p>
<xsl:copy-of select="node()"/>
</p>
@@ -6139,10 +6205,32 @@
</p>
</xsl:if>
</xsl:for-each>
</xsl:template>
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']" mode="table-without-br">
+ <xsl:apply-templates mode="table-without-br"/>
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']/text()[contains(., ' ') or contains(., ' ')]" mode="table-without-br">
+
+ <xsl:variable name="sep">###SOURCECODE_NEWLINE###</xsl:variable>
+ <xsl:variable name="sourcecode_text" select="java:replaceAll(java:java.lang.String.new(.),'( | | )', $sep)"/>
+ <xsl:variable name="items">
+ <xsl:call-template name="split">
+ <xsl:with-param name="pText" select="$sourcecode_text"/>
+ <xsl:with-param name="sep" select="$sep"/>
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:for-each select="xalan:nodeset($items)/*">
+ <p>
+ <sourcecode><xsl:copy-of select="node()"/></sourcecode>
+ </p>
+ </xsl:for-each>
+ </xsl:template>
+
<!-- remove redundant white spaces -->
<xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
<xsl:variable name="text" select="translate(.,'	 ','')"/>
<xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
</xsl:template>
@@ -6449,10 +6537,11 @@
<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>
<xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
<xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']"><tag>sourcecode</tag></xsl:if>
<xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
</tags>
</xsl:template>
<!-- =============================== -->
<!-- END mode="td_text_with_formatting" -->
@@ -6932,10 +7021,16 @@
<fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
<fo:block-container margin-left="0mm">
+ <!-- <xsl:if test="$namespace = 'iho'">
+ <xsl:if test="ancestor::iho:td">
+ <xsl:attribute name="font-size">12pt</xsl:attribute>
+ </xsl:if>
+ </xsl:if> -->
+
<fo:block>
<xsl:if test="ancestor::itu:figure">
<xsl:attribute name="keep-with-previous">always</xsl:attribute>
</xsl:if>
@@ -8079,44 +8174,22 @@
<!-- =============== -->
<!-- sourcecode -->
<!-- =============== -->
<xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
- <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
+ <xsl:variable name="sourcecode_attributes">
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
+ <xsl:variable name="_font-size">
- <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
- </xsl:if>
+ <!-- 9 -->
- <xsl:if test="ancestor::*[local-name() = 'example']">
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
- </xsl:if>
+ <!-- <xsl:if test="$namespace = 'ieee'">
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
+ </xsl:if> -->
+ 10
- <xsl:copy-of select="@id"/>
- <xsl:if test="parent::*[local-name() = 'note']">
- <xsl:attribute name="margin-left">
- <xsl:choose>
- <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- </xsl:if>
- <fo:block-container margin-left="0mm">
-
- <fo:block xsl:use-attribute-sets="sourcecode-style">
- <xsl:variable name="_font-size">
-
- <!-- 9 -->
-
- <!-- <xsl:if test="$namespace = 'ieee'">
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
- </xsl:if> -->
- 10
-
-
</xsl:variable>
<xsl:variable name="font-size" select="normalize-space($_font-size)"/>
<xsl:if test="$font-size != ''">
<xsl:attribute name="font-size">
@@ -8126,18 +8199,64 @@
<xsl:when test="ancestor::*[local-name()='note']"><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:element>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
+ <xsl:attribute name="{local-name()}">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ </xsl:for-each>
<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
- </fo:block>
+ </xsl:when>
- <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
+ <xsl:otherwise>
+ <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
- </fo:block-container>
- </fo:block-container>
+ <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>
+ <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ </xsl:if>
+ <fo:block-container margin-left="0mm">
+
+ <fo:block xsl:use-attribute-sets="sourcecode-style">
+
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
+ <xsl:attribute name="{local-name()}">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ </xsl:for-each>
+
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
+ </fo:block>
+
+ <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
+
+ </fo:block-container>
+ </fo:block-container>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
<xsl:choose>
<xsl:when test="normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
@@ -10394,11 +10513,13 @@
<!-- ================ -->
<!-- ===================================== -->
<!-- Update xml -->
<!-- ===================================== -->
+ <!-- =========================================================================== -->
<!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
+ <!-- =========================================================================== -->
<xsl:template match="@*|node()" mode="update_xml_step1">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
</xsl:copy>
</xsl:template>
@@ -10486,14 +10607,19 @@
</xsl:template>
<!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
<xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
<xsl:apply-templates mode="update_xml_step1"/>
</xsl:template>
-
+ <!-- =========================================================================== -->
<!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
+ <!-- =========================================================================== -->
+ <!-- =========================================================================== -->
<!-- XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
+ <!-- =========================================================================== -->
<!-- Example: <keep-together_within-line>ISO 10303-51</keep-together_within-line> -->
<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>
@@ -10505,14 +10631,19 @@
<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() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" 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__" 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_">
+ <xsl:choose>
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when> <!-- no need enclose standard's number into tag 'keep-together_within-line' in table cells -->
+ <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<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>
@@ -10524,11 +10655,15 @@
<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>
+ <!-- \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 < and > to \S -->
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \<>]</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()">
<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))"/>
@@ -10588,12 +10723,11 @@
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<!-- ===================================== -->
- <!-- End Update xml -->
+ <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
<!-- ===================================== -->
<!-- for correct rendering combining chars -->
<xsl:template match="*[local-name() = 'lang_none']">
<fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
\ No newline at end of file