metanorma-bipm 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2855,11 +2855,11 @@
2855
2855
 
2856
2856
  </xsl:template>
2857
2857
 
2858
- <xsl:template match="bipm:example" priority="2">
2859
- <fo:block margin-top="6pt" margin-bottom="6pt" keep-together.within-column="1">
2858
+ <xsl:template match="bipm:example | bipm:termexample" priority="2">
2859
+ <fo:block keep-together.within-column="1" xsl:use-attribute-sets="example-style">
2860
2860
  <fo:table table-layout="fixed" width="100%">
2861
- <fo:table-column column-width="27.5mm"/>
2862
- <fo:table-column column-width="108mm"/>
2861
+ <fo:table-column column-width="proportional-column-width(27)"/>
2862
+ <fo:table-column column-width="proportional-column-width(108)"/>
2863
2863
  <fo:table-body>
2864
2864
  <fo:table-row>
2865
2865
  <fo:table-cell>
@@ -4356,6 +4356,8 @@
4356
4356
 
4357
4357
  <xsl:attribute-set name="termexample-name-style">
4358
4358
 
4359
+ <xsl:attribute name="font-style">italic</xsl:attribute>
4360
+
4359
4361
  </xsl:attribute-set> <!-- termexample-name-style -->
4360
4362
 
4361
4363
  <!-- ========================== -->
@@ -4583,6 +4585,9 @@
4583
4585
 
4584
4586
  <xsl:attribute-set name="termnote-style">
4585
4587
 
4588
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4589
+ <xsl:attribute name="text-align">justify</xsl:attribute>
4590
+
4586
4591
  </xsl:attribute-set>
4587
4592
 
4588
4593
  <xsl:attribute-set name="termnote-name-style">
@@ -4593,6 +4598,8 @@
4593
4598
 
4594
4599
  <xsl:attribute-set name="termnote-p-style">
4595
4600
 
4601
+ <xsl:attribute name="text-align">justify</xsl:attribute>
4602
+
4596
4603
  </xsl:attribute-set>
4597
4604
 
4598
4605
  <xsl:attribute-set name="quote-style">
@@ -5515,6 +5522,7 @@
5515
5522
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
5516
5523
 
5517
5524
  <xsl:choose>
5525
+ <xsl:when test="@width = 'full-page-width' or @width = 'text-width'">100%</xsl:when>
5518
5526
  <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
5519
5527
  <xsl:otherwise><xsl:value-of select="$table_width_default"/></xsl:otherwise>
5520
5528
  </xsl:choose>
@@ -5636,7 +5644,7 @@
5636
5644
  <xsl:variable name="isDeleted" select="@deleted"/>
5637
5645
 
5638
5646
  <xsl:choose>
5639
- <xsl:when test="@width">
5647
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
5640
5648
 
5641
5649
  <!-- centered table when table name is centered (see table-name-style) -->
5642
5650
 
@@ -5978,6 +5986,7 @@
5978
5986
  This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
5979
5987
  <xsl:when test="(@width_max &gt; $page_width and @width_min &lt; $page_width) or (@width_min &gt;= $page_width)">
5980
5988
  <!-- difference between the available space and the minimum table width -->
5989
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
5981
5990
  <xsl:variable name="W" select="$page_width - @width_min"/>
5982
5991
  <W><xsl:value-of select="$W"/></W>
5983
5992
  <!-- difference between maximum and minimum width of the table -->
@@ -6656,21 +6665,24 @@
6656
6665
  <xsl:for-each select="xalan:nodeset($references)//fn">
6657
6666
  <xsl:variable name="reference" select="@reference"/>
6658
6667
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
6659
- <fo:block xsl:use-attribute-sets="table-fn-style">
6660
6668
 
6661
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
6669
+ <fo:block xsl:use-attribute-sets="table-fn-style">
6662
6670
 
6663
- <fo:inline font-style="normal">(</fo:inline>
6671
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
6664
6672
 
6665
- <xsl:value-of select="@reference"/>
6673
+ <fo:inline font-style="normal">(</fo:inline>
6666
6674
 
6667
- <fo:inline font-style="normal">)</fo:inline>
6675
+ <xsl:value-of select="@reference"/>
6676
+
6677
+ <fo:inline font-style="normal">)</fo:inline>
6678
+
6679
+ </fo:inline>
6680
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
6681
+ <xsl:copy-of select="./node()"/>
6682
+ </fo:inline>
6683
+
6684
+ </fo:block>
6668
6685
 
6669
- </fo:inline>
6670
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
6671
- <xsl:copy-of select="./node()"/>
6672
- </fo:inline>
6673
- </fo:block>
6674
6686
  </xsl:if>
6675
6687
  </xsl:for-each>
6676
6688
  </xsl:template>
@@ -7611,12 +7623,12 @@
7611
7623
  <xsl:param name="value"/>
7612
7624
  <xsl:variable name="add_width" select="string-length($value) * 20"/>
7613
7625
  <xsl:variable name="maxwidth" select="60 + $add_width"/>
7614
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
7615
- <xsl:attribute name="height">5mm</xsl:attribute>
7626
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
7627
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
7616
7628
  <xsl:attribute name="content-width">100%</xsl:attribute>
7617
7629
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7618
7630
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7619
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
7631
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
7620
7632
  <g>
7621
7633
  <xsl:if test="$type = 'closing' or $type = 'end'">
7622
7634
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
@@ -7630,6 +7642,27 @@
7630
7642
  </xsl:if>
7631
7643
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
7632
7644
  </text>
7645
+ </svg> -->
7646
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
7647
+ <g>
7648
+ <xsl:if test="$type = 'closing' or $type = 'end'">
7649
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
7650
+ </xsl:if>
7651
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
7652
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
7653
+ </g>
7654
+ <xsl:variable name="text_x">
7655
+ <xsl:choose>
7656
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
7657
+ <xsl:otherwise>22</xsl:otherwise>
7658
+ </xsl:choose>
7659
+ </xsl:variable>
7660
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
7661
+ <xsl:value-of select="$kind"/>
7662
+ </text>
7663
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
7664
+ <xsl:value-of select="$value"/>
7665
+ </text>
7633
7666
  </svg>
7634
7667
  </fo:instream-foreign-object>
7635
7668
  </xsl:template>
@@ -7884,18 +7917,20 @@
7884
7917
 
7885
7918
  <xsl:template name="add-zero-spaces-java">
7886
7919
  <xsl:param name="text" select="."/>
7887
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
7888
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
7920
+ <!-- add zero-width space (#x200B) after characters: dash, dot, equal, underscore, em dash, thin space, arrow right -->
7921
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|=|_|—| |→)','$1​')"/>
7922
+ <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
7923
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1​$2')"/>
7889
7924
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
7890
- <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' -->
7925
+ <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' -->
7891
7926
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
7892
- <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
7927
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
7893
7928
  <!-- add zero-width space (#x200B) before character: { -->
7894
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
7929
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
7895
7930
  <!-- add zero-width space (#x200B) after character: , -->
7896
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
7931
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
7897
7932
 
7898
- <xsl:value-of select="$text5"/>
7933
+ <xsl:value-of select="$text6"/>
7899
7934
  </xsl:template>
7900
7935
 
7901
7936
  <xsl:template name="add-zero-spaces-link-java">
@@ -7904,7 +7939,9 @@
7904
7939
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
7905
7940
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
7906
7941
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
7907
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
7942
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
7943
+ <!-- remove zero-width space at the end -->
7944
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
7908
7945
  </xsl:template>
7909
7946
 
7910
7947
  <!-- add zero space after dash character (for table's entries) -->
@@ -8041,7 +8078,7 @@
8041
8078
  </xsl:copy>
8042
8079
  </xsl:template>
8043
8080
 
8044
- <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">
8081
+ <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">
8045
8082
  <xsl:copy>
8046
8083
  <xsl:copy-of select="@*"/>
8047
8084
  <p>
@@ -8117,6 +8154,14 @@
8117
8154
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
8118
8155
  </xsl:template>
8119
8156
 
8157
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" mode="table-without-br">
8158
+ <xsl:apply-templates mode="table-without-br"/>
8159
+ </xsl:template>
8160
+
8161
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'li']" mode="table-without-br">
8162
+ <xsl:apply-templates mode="table-without-br"/>
8163
+ </xsl:template>
8164
+
8120
8165
  <!-- mode="table-without-br" -->
8121
8166
  <!-- ================================== -->
8122
8167
  <!-- END: Step 0. replace <br/> to <p>...</p> -->
@@ -8975,7 +9020,7 @@
8975
9020
  <xsl:attribute name="margin-bottom">4pt</xsl:attribute>
8976
9021
  </xsl:if>
8977
9022
 
8978
- <fo:block-container margin-left="0mm">
9023
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8979
9024
 
8980
9025
  <fo:block>
8981
9026
 
@@ -9174,11 +9219,14 @@
9174
9219
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
9175
9220
  </xsl:call-template>
9176
9221
 
9222
+ <!-- Example: Dimensions in millimeters -->
9223
+ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/>
9224
+
9177
9225
  <fo:block xsl:use-attribute-sets="figure-style">
9178
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9226
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
9179
9227
  </fo:block>
9180
9228
  <xsl:call-template name="fn_display_figure"/>
9181
- <xsl:for-each select="*[local-name() = 'note']">
9229
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
9182
9230
  <xsl:call-template name="note"/>
9183
9231
  </xsl:for-each>
9184
9232
 
@@ -9435,24 +9483,47 @@
9435
9483
 
9436
9484
  </xsl:when>
9437
9485
  <xsl:otherwise>
9438
- <fo:block xsl:use-attribute-sets="image-style">
9439
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
9440
- <xsl:attribute name="width">100%</xsl:attribute>
9441
- <xsl:attribute name="content-height">100%</xsl:attribute>
9442
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
9443
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
9444
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
9445
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
9446
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
9447
- <!-- effective height / width = 1.48, 1.4 - with title -->
9448
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
9449
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
9450
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
9451
- </xsl:if>
9452
- <xsl:attribute name="scaling">uniform</xsl:attribute>
9453
- <xsl:copy-of select="$svg_content"/>
9454
- </fo:instream-foreign-object>
9455
- </fo:block>
9486
+
9487
+ <xsl:variable name="element">
9488
+ <xsl:choose>
9489
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
9490
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
9491
+ </xsl:when>
9492
+ <xsl:otherwise>
9493
+ <fo:block xsl:use-attribute-sets="image-style">
9494
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
9495
+ <xsl:attribute name="text-align">left</xsl:attribute>
9496
+ </xsl:if>
9497
+ </fo:block>
9498
+ </xsl:otherwise>
9499
+ </xsl:choose>
9500
+ </xsl:variable>
9501
+
9502
+ <xsl:for-each select="xalan:nodeset($element)/*">
9503
+ <xsl:copy>
9504
+ <xsl:copy-of select="@*"/>
9505
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
9506
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
9507
+ <xsl:if test="$isGenerateTableIF = 'false'">
9508
+ <xsl:attribute name="width">100%</xsl:attribute>
9509
+ </xsl:if>
9510
+ <xsl:attribute name="content-height">100%</xsl:attribute>
9511
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
9512
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
9513
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
9514
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
9515
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
9516
+ <!-- effective height / width = 1.48, 1.4 - with title -->
9517
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
9518
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
9519
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
9520
+ </xsl:if>
9521
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
9522
+ <xsl:copy-of select="$svg_content"/>
9523
+ </fo:instream-foreign-object>
9524
+ <!-- </fo:block> -->
9525
+ </xsl:copy>
9526
+ </xsl:for-each>
9456
9527
  </xsl:otherwise>
9457
9528
  </xsl:choose>
9458
9529
  </xsl:template>
@@ -9544,6 +9615,13 @@
9544
9615
  </xsl:for-each>
9545
9616
  </xsl:template>
9546
9617
 
9618
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
9619
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
9620
+ <xsl:for-each select="*[local-name() = 'svg']">
9621
+ <xsl:call-template name="image_svg"/>
9622
+ </xsl:for-each>
9623
+ </xsl:template>
9624
+
9547
9625
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
9548
9626
  <xsl:variable name="svg_content" select="document(@src)"/>
9549
9627
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -9682,6 +9760,8 @@
9682
9760
  <xsl:value-of select="."/>
9683
9761
  </xsl:template>
9684
9762
 
9763
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
9764
+
9685
9765
  <xsl:template match="node()" mode="contents">
9686
9766
  <xsl:apply-templates mode="contents"/>
9687
9767
  </xsl:template>
@@ -10003,7 +10083,15 @@
10003
10083
  <xsl:value-of select="@section"/>
10004
10084
  <xsl:text> </xsl:text>
10005
10085
  </xsl:if>
10006
- <xsl:value-of select="normalize-space(title)"/>
10086
+ <xsl:variable name="title">
10087
+ <xsl:for-each select="title/node()">
10088
+ <xsl:choose>
10089
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
10090
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10091
+ </xsl:choose>
10092
+ </xsl:for-each>
10093
+ </xsl:variable>
10094
+ <xsl:value-of select="normalize-space($title)"/>
10007
10095
  </fo:bookmark-title>
10008
10096
  <xsl:apply-templates mode="bookmark"/>
10009
10097
  </fo:bookmark>
@@ -10029,6 +10117,12 @@
10029
10117
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
10030
10118
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
10031
10119
 
10120
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
10121
+ <fo:block text-align="right" keep-with-next="always">
10122
+ <xsl:apply-templates/>
10123
+ </fo:block>
10124
+ </xsl:template>
10125
+
10032
10126
  <!-- ====== -->
10033
10127
  <!-- ====== -->
10034
10128
  <xsl:template match="*[local-name() = 'title']" mode="contents_item">
@@ -10178,6 +10272,10 @@
10178
10272
  </xsl:for-each>
10179
10273
  </xsl:template>
10180
10274
 
10275
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
10276
+ <xsl:value-of select="."/>
10277
+ </xsl:template>
10278
+
10181
10279
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
10182
10280
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
10183
10281
  <xsl:apply-templates mode="contents_item"/>