lib/isodoc/un/un.recommendation.xsl in metanorma-un-0.10.3 vs lib/isodoc/un/un.recommendation.xsl in metanorma-un-0.10.4
- old
+ new
@@ -2454,10 +2454,11 @@
<xsl:variable name="table_width_default">100%</xsl:variable>
<xsl:variable name="table_width">
<!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
<xsl:choose>
+ <xsl:when test="@width = 'full-page-width' or @width = 'text-width'">100%</xsl:when>
<xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$table_width_default"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -2580,11 +2581,11 @@
<xsl:variable name="isAdded" select="@added"/>
<xsl:variable name="isDeleted" select="@deleted"/>
<xsl:choose>
- <xsl:when test="@width">
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
<!-- centered table when table name is centered (see table-name-style) -->
<xsl:choose>
<xsl:when test="$isAdded = 'true' or $isDeleted = 'true'">
@@ -2902,10 +2903,11 @@
For each column, let d be the difference between maximum and minimum width of that column.
Now set the column's width to the minimum width plus d times W over D.
This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
<xsl:when test="(@width_max > $page_width and @width_min < $page_width) or (@width_min >= $page_width)">
<!-- difference between the available space and the minimum table width -->
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
<xsl:variable name="W" select="$page_width - @width_min"/>
<W><xsl:value-of select="$W"/></W>
<!-- difference between maximum and minimum width of the table -->
<xsl:variable name="D" select="@width_max - @width_min"/>
<D><xsl:value-of select="$D"/></D>
@@ -3543,21 +3545,24 @@
</xsl:variable>
<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:block xsl:use-attribute-sets="table-fn-style">
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
+ <fo:block xsl:use-attribute-sets="table-fn-style">
- <xsl:value-of select="@reference"/>
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
- </fo:inline>
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
- <xsl:copy-of select="./node()"/>
- </fo:inline>
- </fo:block>
+ <xsl:value-of select="@reference"/>
+
+ </fo:inline>
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
+ <xsl:copy-of select="./node()"/>
+ </fo:inline>
+
+ </fo:block>
+
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="create_fn">
@@ -4489,16 +4494,16 @@
<xsl:param name="type"/>
<xsl:param name="kind"/>
<xsl:param name="value"/>
<xsl:variable name="add_width" select="string-length($value) * 20"/>
<xsl:variable name="maxwidth" select="60 + $add_width"/>
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
- <xsl:attribute name="height">5mm</xsl:attribute>
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
<xsl:attribute name="content-width">100%</xsl:attribute>
<xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
<xsl:attribute name="scaling">uniform</xsl:attribute>
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
<g>
<xsl:if test="$type = 'closing' or $type = 'end'">
<xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
</xsl:if>
<polyline points="0,0 {$maxwidth},0 {$maxwidth + 30},40 {$maxwidth},80 0,80 " stroke="black" stroke-width="5" fill="white"/>
@@ -4508,10 +4513,31 @@
<xsl:if test="$type = 'closing' or $type = 'end'">
<xsl:attribute name="x">25</xsl:attribute>
</xsl:if>
<xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
</text>
+ </svg> -->
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
+ <g>
+ <xsl:if test="$type = 'closing' or $type = 'end'">
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
+ </xsl:if>
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
+ </g>
+ <xsl:variable name="text_x">
+ <xsl:choose>
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
+ <xsl:otherwise>22</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
+ <xsl:value-of select="$kind"/>
+ </text>
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
+ <xsl:value-of select="$value"/>
+ </text>
</svg>
</fo:instream-foreign-object>
</xsl:template>
<xsl:template match="*[local-name()='del']">
@@ -4762,31 +4788,35 @@
</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, arrow right -->
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1')"/>
+ <!-- add zero-width space (#x200B) after characters: dash, dot, 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: colon, if there aren't digits after -->
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1$2')"/>
<!-- 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' -->
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(\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' -->
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?<!\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' -->
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?<!\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:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\d)', '$1')"/> <!-- negative lookahead: ',' not followed by digit -->
- <xsl:value-of select="$text5"/>
+ <xsl:value-of select="$text6"/>
</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:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1')"/>
+ <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) -->
<xsl:template name="add-zero-spaces">
<xsl:param name="text" select="."/>
@@ -4919,11 +4949,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']) and not(*[local-name()='sourcecode'])]" 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']) and not(*[local-name()='ul']) and not(*[local-name()='ol'])]" mode="table-without-br">
<xsl:copy>
<xsl:copy-of select="@*"/>
<p>
<xsl:copy-of select="node()"/>
</p>
@@ -4995,10 +5025,18 @@
<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>
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" 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() = 'li']" mode="table-without-br">
+ <xsl:apply-templates mode="table-without-br"/>
+ </xsl:template>
+
<!-- mode="table-without-br" -->
<!-- ================================== -->
<!-- END: Step 0. replace <br/> to <p>...</p> -->
<!-- ================================== -->
@@ -5817,11 +5855,11 @@
<xsl:if test="../@type = 'source' or ../@type = 'abbreviation'">
<xsl:attribute name="border-top">0pt solid black</xsl:attribute>
</xsl:if>
- <fo:block-container margin-left="0mm">
+ <fo:block-container margin-left="0mm" margin-right="0mm">
<fo:block>
<xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="text-indent">0</xsl:attribute>
@@ -6004,15 +6042,18 @@
<xsl:call-template name="setTrackChangesStyles">
<xsl:with-param name="isAdded" select="$isAdded"/>
<xsl:with-param name="isDeleted" select="$isDeleted"/>
</xsl:call-template>
+ <!-- Example: Dimensions in millimeters -->
+ <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')]"/>
+ <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']">
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
<xsl:call-template name="note"/>
</xsl:for-each>
<xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
@@ -6270,28 +6311,51 @@
</fo:table>
</fo:block>
</xsl:when>
<xsl:otherwise>
- <fo:block xsl:use-attribute-sets="image-style">
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
- <xsl:attribute name="width">100%</xsl:attribute>
- <xsl:attribute name="content-height">100%</xsl:attribute>
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
- <!-- effective height / width = 1.48, 1.4 - with title -->
- <xsl:if test="$svg_height > ($svg_width * 1.4)"> <!-- for images with big height -->
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
- </xsl:if>
- <xsl:attribute name="scaling">uniform</xsl:attribute>
- <xsl:copy-of select="$svg_content"/>
- </fo:instream-foreign-object>
- </fo:block>
+
+ <xsl:variable name="element">
+ <xsl:choose>
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:block xsl:use-attribute-sets="image-style">
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
+ <xsl:attribute name="text-align">left</xsl:attribute>
+ </xsl:if>
+ </fo:block>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:for-each select="xalan:nodeset($element)/*">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
+ <xsl:if test="$isGenerateTableIF = 'false'">
+ <xsl:attribute name="width">100%</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute name="content-height">100%</xsl:attribute>
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
+ <!-- effective height / width = 1.48, 1.4 - with title -->
+ <xsl:if test="$svg_height > ($svg_width * 1.4)"> <!-- for images with big height -->
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
+ <xsl:copy-of select="$svg_content"/>
+ </fo:instream-foreign-object>
+ <!-- </fo:block> -->
+ </xsl:copy>
+ </xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ============== -->
@@ -6379,10 +6443,17 @@
<xsl:with-param name="name" select="$name"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
+ <xsl:for-each select="*[local-name() = 'svg']">
+ <xsl:call-template name="image_svg"/>
+ </xsl:for-each>
+ </xsl:template>
+
<xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
<xsl:variable name="svg_content" select="document(@src)"/>
<xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
<xsl:for-each select="xalan:nodeset($svg_content)/node()">
<xsl:call-template name="image_svg">
@@ -6517,10 +6588,12 @@
<xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement' or local-name() = 'sourcecode']/*[local-name() = 'name']//text()" mode="bookmarks" priority="2">
<xsl:value-of select="."/>
</xsl:template>
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
+
<xsl:template match="node()" mode="contents">
<xsl:apply-templates mode="contents"/>
</xsl:template>
<!-- special case: ignore preface/section-title and sections/section-title without @displayorder -->
@@ -6824,11 +6897,19 @@
<fo:bookmark-title>
<xsl:if test="@section != ''">
<xsl:value-of select="@section"/>
<xsl:text> </xsl:text>
</xsl:if>
- <xsl:value-of select="normalize-space(title)"/>
+ <xsl:variable name="title">
+ <xsl:for-each select="title/node()">
+ <xsl:choose>
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select="normalize-space($title)"/>
</fo:bookmark-title>
<xsl:apply-templates mode="bookmark"/>
</fo:bookmark>
</xsl:when>
<xsl:otherwise>
@@ -6850,10 +6931,16 @@
</xsl:template>
<xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
<xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
+ <fo:block text-align="right" keep-with-next="always">
+ <xsl:apply-templates/>
+ </fo:block>
+ </xsl:template>
+
<!-- ====== -->
<!-- ====== -->
<xsl:template match="*[local-name() = 'title']" mode="contents_item">
<xsl:param name="mode">bookmarks</xsl:param>
<xsl:apply-templates mode="contents_item">
@@ -6997,9 +7084,13 @@
<text><xsl:call-template name="add-zero-spaces-java"/></text>
</xsl:variable>
<xsl:for-each select="xalan:nodeset($text)/text/text()">
<xsl:call-template name="keep_together_standard_number"/>
</xsl:for-each>
+ </xsl:template>
+
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
+ <xsl:value-of select="."/>
</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="contents_item">
<xsl:apply-templates mode="contents_item"/>
\ No newline at end of file