metanorma-bipm 2.1.10 → 2.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1058,7 +1058,7 @@
1058
1058
  <!-- <xsl:copy-of select="$contents"/> -->
1059
1059
 
1060
1060
  <xsl:if test="$contents/doc[@id = $docid]//item[@display='true']">
1061
- <fo:table table-layout="fixed" width="100%">
1061
+ <fo:table table-layout="fixed" width="100%" id="__internal_layout__toc_{generate-id()}">
1062
1062
  <fo:table-column column-width="127mm"/>
1063
1063
  <fo:table-column column-width="12mm"/>
1064
1064
  <fo:table-body>
@@ -2242,8 +2242,13 @@
2242
2242
  <!-- ====== -->
2243
2243
 
2244
2244
  <xsl:template match="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]" priority="3">
2245
- <fo:table table-layout="fixed" width="173.5mm">
2245
+ <fo:block keep-with-next="always">
2246
2246
  <xsl:call-template name="setId"/>
2247
+ </fo:block>
2248
+ <fo:table table-layout="fixed" width="173.5mm">
2249
+ <xsl:call-template name="setId">
2250
+ <xsl:with-param name="prefix">__internal_layout__</xsl:with-param>
2251
+ </xsl:call-template>
2247
2252
  <fo:table-column column-width="137mm"/>
2248
2253
  <fo:table-column column-width="2.5mm"/>
2249
2254
  <fo:table-column column-width="34mm"/>
@@ -2386,11 +2391,16 @@
2386
2391
  </xsl:variable>
2387
2392
  <xsl:variable name="space-before-value" select="normalize-space($space-before)"/>
2388
2393
 
2394
+ <fo:block keep-with-next="always">
2395
+ <xsl:call-template name="setId"/>
2396
+ </fo:block>
2389
2397
  <fo:table table-layout="fixed" width="174mm" line-height="135%">
2390
2398
  <xsl:if test="@orientation = 'landscape'">
2391
2399
  <xsl:attribute name="width">261mm</xsl:attribute> <!-- 87 = (297 - 210) -->
2392
2400
  </xsl:if>
2393
- <xsl:call-template name="setId"/>
2401
+ <xsl:call-template name="setId">
2402
+ <xsl:with-param name="prefix">__internal_layout__</xsl:with-param>
2403
+ </xsl:call-template>
2394
2404
  <xsl:if test="$space-before-value != ''">
2395
2405
  <xsl:attribute name="space-before"><xsl:value-of select="$space-before-value"/></xsl:attribute>
2396
2406
  </xsl:if>
@@ -3743,7 +3753,7 @@
3743
3753
  </fo:block>
3744
3754
  </fo:block-container>
3745
3755
  <!-- grey opacity -->
3746
- <fo:block-container absolute-position="fixed" left="0" top="0">
3756
+ <fo:block-container absolute-position="fixed" left="0" top="0" id="{concat('__internal_layout__', 'Logo-BIPM-Metro_', generate-id())}">
3747
3757
  <fo:block>
3748
3758
  <fo:instream-foreign-object content-height="{$pageHeight}mm" fox:alt-text="Background color">
3749
3759
  <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="215.9mm" height="279.4mm">
@@ -4215,6 +4225,12 @@
4215
4225
 
4216
4226
  </xsl:attribute-set>
4217
4227
 
4228
+ <xsl:attribute-set name="pre-style">
4229
+ <xsl:attribute name="font-family">Courier New, <xsl:value-of select="$font_noto_sans_mono"/></xsl:attribute>
4230
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4231
+
4232
+ </xsl:attribute-set>
4233
+
4218
4234
  <xsl:attribute-set name="permission-style">
4219
4235
 
4220
4236
  </xsl:attribute-set>
@@ -4313,6 +4329,11 @@
4313
4329
  </xsl:variable>
4314
4330
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
4315
4331
 
4332
+ <xsl:variable name="table-cell-border_">
4333
+
4334
+ </xsl:variable>
4335
+ <xsl:variable name="table-cell-border" select="normalize-space($table-cell-border_)"/>
4336
+
4316
4337
  <xsl:attribute-set name="table-container-style">
4317
4338
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
4318
4339
  <xsl:attribute name="margin-right">0mm</xsl:attribute>
@@ -4325,8 +4346,6 @@
4325
4346
  <xsl:attribute-set name="table-style">
4326
4347
  <xsl:attribute name="table-omit-footer-at-break">true</xsl:attribute>
4327
4348
  <xsl:attribute name="table-layout">fixed</xsl:attribute>
4328
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
4329
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
4330
4349
 
4331
4350
  </xsl:attribute-set><!-- table-style -->
4332
4351
 
@@ -5459,6 +5478,12 @@
5459
5478
  <xsl:variable name="table_attributes">
5460
5479
 
5461
5480
  <xsl:element name="table_attributes" use-attribute-sets="table-style">
5481
+
5482
+ <xsl:if test="$margin-side != 0">
5483
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5484
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5485
+ </xsl:if>
5486
+
5462
5487
  <xsl:attribute name="width"><xsl:value-of select="normalize-space($table_width)"/></xsl:attribute>
5463
5488
 
5464
5489
  <xsl:if test="not(ancestor::*[local-name()='preface']) and not(ancestor::*[local-name()='note_side']) and not(ancestor::*[local-name() = 'annex'] and .//*[local-name() = 'xref'][@pagenumber]) and not(ancestor::*[local-name() = 'doccontrol'])">
@@ -6247,6 +6272,10 @@
6247
6272
  <xsl:template match="*[local-name()='tr']">
6248
6273
  <fo:table-row xsl:use-attribute-sets="table-body-row-style">
6249
6274
 
6275
+ <xsl:if test="*[local-name() = 'th']">
6276
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
6277
+ </xsl:if>
6278
+
6250
6279
  <xsl:call-template name="setTableRowAttributes"/>
6251
6280
  <xsl:apply-templates/>
6252
6281
  </fo:table-row>
@@ -7342,8 +7371,17 @@
7342
7371
  </fo:inline>
7343
7372
  </xsl:template> <!-- tt -->
7344
7373
 
7374
+ <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
7345
7375
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
7346
- <xsl:call-template name="add_spaces_to_sourcecode"/>
7376
+ <xsl:choose>
7377
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
7378
+ <!-- url -->
7379
+ <xsl:call-template name="add-zero-spaces-link-java"/>
7380
+ </xsl:when>
7381
+ <xsl:otherwise>
7382
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
7383
+ </xsl:otherwise>
7384
+ </xsl:choose>
7347
7385
  </xsl:template>
7348
7386
 
7349
7387
  <xsl:template match="*[local-name()='underline']">
@@ -7699,8 +7737,11 @@
7699
7737
 
7700
7738
  <xsl:template name="add-zero-spaces-link-java">
7701
7739
  <xsl:param name="text" select="."/>
7740
+
7741
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
7742
+ <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
7702
7743
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
7703
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/>
7744
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
7704
7745
  </xsl:template>
7705
7746
 
7706
7747
  <!-- add zero space after dash character (for table's entries) -->
@@ -8257,6 +8298,9 @@
8257
8298
  <xsl:value-of select="substring($str, 2)"/>
8258
8299
  </xsl:template>
8259
8300
 
8301
+ <!-- ======================================= -->
8302
+ <!-- math -->
8303
+ <!-- ======================================= -->
8260
8304
  <xsl:template match="mathml:math">
8261
8305
  <xsl:variable name="isAdded" select="@added"/>
8262
8306
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -8292,17 +8336,18 @@
8292
8336
  <xsl:when test="$add_math_as_attachment = 'true' and normalize-space($filename) != ''">
8293
8337
  <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
8294
8338
  <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
8295
- <xsl:variable name="comment_text">
8296
- <xsl:call-template name="getMathml_comment_text"/>
8339
+ <xsl:variable name="asciimath_text">
8340
+ <!-- <xsl:call-template name="getMathml_comment_text"/> -->
8341
+ <xsl:call-template name="getMathml_asciimath_text"/>
8297
8342
  </xsl:variable>
8298
- <xsl:if test="normalize-space($comment_text) != ''">
8343
+ <xsl:if test="normalize-space($asciimath_text) != ''">
8299
8344
  <!-- put Mathin Alternate Text -->
8300
8345
  <xsl:attribute name="fox:alt-text">
8301
- <xsl:value-of select="$comment_text"/>
8346
+ <xsl:value-of select="$asciimath_text"/>
8302
8347
  </xsl:attribute>
8303
8348
  </xsl:if>
8304
8349
  <xsl:call-template name="mathml_instream_object">
8305
- <xsl:with-param name="comment_text" select="$comment_text"/>
8350
+ <xsl:with-param name="asciimath_text" select="$asciimath_text"/>
8306
8351
  <xsl:with-param name="mathml_content" select="$mathml_content"/>
8307
8352
  </xsl:call-template>
8308
8353
  </fo:basic-link>
@@ -8313,7 +8358,7 @@
8313
8358
  </xsl:call-template>
8314
8359
  </xsl:otherwise>
8315
8360
  </xsl:choose>
8316
- <!-- end BSI -->
8361
+ <!-- end BIPM -->
8317
8362
 
8318
8363
  </fo:inline>
8319
8364
  </xsl:template>
@@ -8335,14 +8380,57 @@
8335
8380
  <xsl:value-of select="$comment_text"/>
8336
8381
  </xsl:template>
8337
8382
 
8383
+ <xsl:template match="*[local-name() = 'asciimath']">
8384
+ <xsl:param name="process" select="'false'"/>
8385
+ <xsl:if test="$process = 'true'">
8386
+ <xsl:apply-templates/>
8387
+ </xsl:if>
8388
+ </xsl:template>
8389
+
8390
+ <xsl:template match="*[local-name() = 'latexmath']"/>
8391
+
8392
+ <xsl:template name="getMathml_asciimath_text">
8393
+ <xsl:variable name="asciimath" select="../*[local-name() = 'asciimath']"/>
8394
+ <xsl:variable name="latexmath">
8395
+
8396
+ </xsl:variable>
8397
+ <xsl:variable name="asciimath_text_following">
8398
+ <xsl:choose>
8399
+ <xsl:when test="normalize-space($latexmath) != ''">
8400
+ <xsl:value-of select="$latexmath"/>
8401
+ </xsl:when>
8402
+ <xsl:when test="normalize-space($asciimath) != ''">
8403
+ <xsl:value-of select="$asciimath"/>
8404
+ </xsl:when>
8405
+ <xsl:otherwise>
8406
+ <xsl:value-of select="following-sibling::node()[1][self::comment()]"/>
8407
+ </xsl:otherwise>
8408
+ </xsl:choose>
8409
+ </xsl:variable>
8410
+ <xsl:variable name="asciimath_text_">
8411
+ <xsl:choose>
8412
+ <xsl:when test="normalize-space($asciimath_text_following) != ''">
8413
+ <xsl:value-of select="$asciimath_text_following"/>
8414
+ </xsl:when>
8415
+ <xsl:otherwise>
8416
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
8417
+ </xsl:otherwise>
8418
+ </xsl:choose>
8419
+ </xsl:variable>
8420
+ <xsl:variable name="asciimath_text_2" select="java:org.metanorma.fop.Util.unescape($asciimath_text_)"/>
8421
+ <xsl:variable name="asciimath_text" select="java:trim(java:java.lang.String.new($asciimath_text_2))"/>
8422
+ <xsl:value-of select="$asciimath_text"/>
8423
+ </xsl:template>
8424
+
8338
8425
  <xsl:template name="mathml_instream_object">
8339
- <xsl:param name="comment_text"/>
8426
+ <xsl:param name="asciimath_text"/>
8340
8427
  <xsl:param name="mathml_content"/>
8341
8428
 
8342
- <xsl:variable name="comment_text_">
8429
+ <xsl:variable name="asciimath_text_">
8343
8430
  <xsl:choose>
8344
- <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
8345
- <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
8431
+ <xsl:when test="normalize-space($asciimath_text) != ''"><xsl:value-of select="$asciimath_text"/></xsl:when>
8432
+ <!-- <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise> -->
8433
+ <xsl:otherwise><xsl:call-template name="getMathml_asciimath_text"/></xsl:otherwise>
8346
8434
  </xsl:choose>
8347
8435
  </xsl:variable>
8348
8436
 
@@ -8366,10 +8454,10 @@
8366
8454
  </xsl:attribute>
8367
8455
 
8368
8456
  <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
8369
- <xsl:if test="normalize-space($comment_text_) != ''">
8457
+ <xsl:if test="normalize-space($asciimath_text_) != ''">
8370
8458
  <!-- put Mathin Alternate Text -->
8371
8459
  <xsl:attribute name="fox:alt-text">
8372
- <xsl:value-of select="$comment_text_"/>
8460
+ <xsl:value-of select="$asciimath_text_"/>
8373
8461
  </xsl:attribute>
8374
8462
  </xsl:if>
8375
8463
  <!-- </xsl:if> -->
@@ -8442,6 +8530,33 @@
8442
8530
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
8443
8531
  </xsl:template>
8444
8532
 
8533
+ <!-- Examples:
8534
+ <stem type="AsciiMath">x = 1</stem>
8535
+ <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
8536
+ <stem type="AsciiMath"><asciimath>x = 1</asciimath><latexmath>x = 1</latexmath></stem>
8537
+ -->
8538
+ <xsl:template match="*[local-name() = 'stem'][@type = 'AsciiMath'][count(*) = 0]/text() | *[local-name() = 'stem'][@type = 'AsciiMath'][*[local-name() = 'asciimath']]" priority="3">
8539
+ <fo:inline xsl:use-attribute-sets="mathml-style">
8540
+
8541
+ <xsl:if test="ancestor::*[local-name()='table']">
8542
+ <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
8543
+ </xsl:if>
8544
+
8545
+ <xsl:choose>
8546
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
8547
+ <xsl:otherwise>
8548
+ <xsl:apply-templates>
8549
+ <xsl:with-param name="process">true</xsl:with-param>
8550
+ </xsl:apply-templates>
8551
+ </xsl:otherwise>
8552
+ </xsl:choose>
8553
+
8554
+ </fo:inline>
8555
+ </xsl:template>
8556
+ <!-- ======================================= -->
8557
+ <!-- END: math -->
8558
+ <!-- ======================================= -->
8559
+
8445
8560
  <xsl:template match="*[local-name()='localityStack']"/>
8446
8561
 
8447
8562
  <xsl:template match="*[local-name()='link']" name="link">
@@ -9822,9 +9937,9 @@
9822
9937
  <xsl:apply-templates mode="contents_item"/>
9823
9938
  </xsl:template>
9824
9939
 
9825
- <!-- ====== -->
9826
- <!-- sourcecode -->
9827
- <!-- ====== -->
9940
+ <!-- =============== -->
9941
+ <!-- sourcecode -->
9942
+ <!-- =============== -->
9828
9943
  <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
9829
9944
 
9830
9945
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
@@ -10121,8 +10236,22 @@
10121
10236
  </fo:block>
10122
10237
  </xsl:if>
10123
10238
  </xsl:template>
10124
- <!-- ====== -->
10125
- <!-- ====== -->
10239
+ <!-- =============== -->
10240
+ <!-- END sourcecode -->
10241
+ <!-- =============== -->
10242
+
10243
+ <!-- =============== -->
10244
+ <!-- pre -->
10245
+ <!-- =============== -->
10246
+ <xsl:template match="*[local-name()='pre']" name="pre">
10247
+ <fo:block xsl:use-attribute-sets="pre-style">
10248
+ <xsl:copy-of select="@id"/>
10249
+ <xsl:apply-templates/>
10250
+ </fo:block>
10251
+ </xsl:template>
10252
+ <!-- =============== -->
10253
+ <!-- pre -->
10254
+ <!-- =============== -->
10126
10255
 
10127
10256
  <!-- ========== -->
10128
10257
  <!-- permission -->
@@ -12202,7 +12331,7 @@
12202
12331
 
12203
12332
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
12204
12333
 
12205
- <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">
12334
+ <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">
12206
12335
 
12207
12336
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
12208
12337
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
@@ -12678,13 +12807,14 @@
12678
12807
  </xsl:template>
12679
12808
 
12680
12809
  <xsl:template name="setId">
12810
+ <xsl:param name="prefix"/>
12681
12811
  <xsl:attribute name="id">
12682
12812
  <xsl:choose>
12683
12813
  <xsl:when test="@id">
12684
- <xsl:value-of select="@id"/>
12814
+ <xsl:value-of select="concat($prefix, @id)"/>
12685
12815
  </xsl:when>
12686
12816
  <xsl:otherwise>
12687
- <xsl:value-of select="generate-id()"/>
12817
+ <xsl:value-of select="concat($prefix, generate-id())"/>
12688
12818
  </xsl:otherwise>
12689
12819
  </xsl:choose>
12690
12820
  </xsl:attribute>
@@ -372,7 +372,7 @@ div.figure {
372
372
  font-weight: 700;
373
373
  font-size: 1em;
374
374
  text-align: center; }
375
- div.figure > img {
375
+ div.figure > img, div.figure > svg {
376
376
  margin-left: auto;
377
377
  margin-right: auto;
378
378
  display: block;
@@ -3,7 +3,7 @@ appendix: Appendice
3
3
  iso_annex: Annexe
4
4
  see: voir
5
5
  see_also: voir aussi
6
- clause: chapître
6
+ clause: chapitre
7
7
  subclause: section
8
8
  clause_jcgm: Article
9
9
  subclause_jcgm: Article
@@ -2100,6 +2100,14 @@
2100
2100
 
2101
2101
  </xsl:attribute-set>
2102
2102
 
2103
+ <xsl:attribute-set name="pre-style">
2104
+ <xsl:attribute name="font-family">Courier New, <xsl:value-of select="$font_noto_sans_mono"/></xsl:attribute>
2105
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2106
+
2107
+ <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
2108
+
2109
+ </xsl:attribute-set>
2110
+
2103
2111
  <xsl:attribute-set name="permission-style">
2104
2112
 
2105
2113
  </xsl:attribute-set>
@@ -2210,6 +2218,11 @@
2210
2218
  </xsl:variable>
2211
2219
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
2212
2220
 
2221
+ <xsl:variable name="table-cell-border_">
2222
+
2223
+ </xsl:variable>
2224
+ <xsl:variable name="table-cell-border" select="normalize-space($table-cell-border_)"/>
2225
+
2213
2226
  <xsl:attribute-set name="table-container-style">
2214
2227
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
2215
2228
  <xsl:attribute name="margin-right">0mm</xsl:attribute>
@@ -2223,8 +2236,6 @@
2223
2236
  <xsl:attribute-set name="table-style">
2224
2237
  <xsl:attribute name="table-omit-footer-at-break">true</xsl:attribute>
2225
2238
  <xsl:attribute name="table-layout">fixed</xsl:attribute>
2226
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2227
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
2228
2239
 
2229
2240
  <xsl:attribute name="border">1.5pt solid black</xsl:attribute>
2230
2241
 
@@ -3351,6 +3362,12 @@
3351
3362
  <xsl:variable name="table_attributes">
3352
3363
 
3353
3364
  <xsl:element name="table_attributes" use-attribute-sets="table-style">
3365
+
3366
+ <xsl:if test="$margin-side != 0">
3367
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
3368
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
3369
+ </xsl:if>
3370
+
3354
3371
  <xsl:attribute name="width"><xsl:value-of select="normalize-space($table_width)"/></xsl:attribute>
3355
3372
 
3356
3373
  <xsl:if test="*[local-name()='thead']">
@@ -4178,6 +4195,10 @@
4178
4195
  <xsl:template match="*[local-name()='tr']">
4179
4196
  <fo:table-row xsl:use-attribute-sets="table-body-row-style">
4180
4197
 
4198
+ <xsl:if test="*[local-name() = 'th']">
4199
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
4200
+ </xsl:if>
4201
+
4181
4202
  <xsl:call-template name="setTableRowAttributes"/>
4182
4203
  <xsl:apply-templates/>
4183
4204
  </fo:table-row>
@@ -5242,8 +5263,17 @@
5242
5263
  </fo:inline>
5243
5264
  </xsl:template> <!-- tt -->
5244
5265
 
5266
+ <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
5245
5267
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
5246
- <xsl:call-template name="add_spaces_to_sourcecode"/>
5268
+ <xsl:choose>
5269
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
5270
+ <!-- url -->
5271
+ <xsl:call-template name="add-zero-spaces-link-java"/>
5272
+ </xsl:when>
5273
+ <xsl:otherwise>
5274
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
5275
+ </xsl:otherwise>
5276
+ </xsl:choose>
5247
5277
  </xsl:template>
5248
5278
 
5249
5279
  <xsl:template match="*[local-name()='underline']">
@@ -5599,8 +5629,11 @@
5599
5629
 
5600
5630
  <xsl:template name="add-zero-spaces-link-java">
5601
5631
  <xsl:param name="text" select="."/>
5632
+
5633
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
5634
+ <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
5602
5635
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
5603
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/>
5636
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
5604
5637
  </xsl:template>
5605
5638
 
5606
5639
  <!-- add zero space after dash character (for table's entries) -->
@@ -6157,6 +6190,9 @@
6157
6190
  <xsl:value-of select="substring($str, 2)"/>
6158
6191
  </xsl:template>
6159
6192
 
6193
+ <!-- ======================================= -->
6194
+ <!-- math -->
6195
+ <!-- ======================================= -->
6160
6196
  <xsl:template match="mathml:math">
6161
6197
  <xsl:variable name="isAdded" select="@added"/>
6162
6198
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -6207,14 +6243,57 @@
6207
6243
  <xsl:value-of select="$comment_text"/>
6208
6244
  </xsl:template>
6209
6245
 
6246
+ <xsl:template match="*[local-name() = 'asciimath']">
6247
+ <xsl:param name="process" select="'false'"/>
6248
+ <xsl:if test="$process = 'true'">
6249
+ <xsl:apply-templates/>
6250
+ </xsl:if>
6251
+ </xsl:template>
6252
+
6253
+ <xsl:template match="*[local-name() = 'latexmath']"/>
6254
+
6255
+ <xsl:template name="getMathml_asciimath_text">
6256
+ <xsl:variable name="asciimath" select="../*[local-name() = 'asciimath']"/>
6257
+ <xsl:variable name="latexmath">
6258
+
6259
+ </xsl:variable>
6260
+ <xsl:variable name="asciimath_text_following">
6261
+ <xsl:choose>
6262
+ <xsl:when test="normalize-space($latexmath) != ''">
6263
+ <xsl:value-of select="$latexmath"/>
6264
+ </xsl:when>
6265
+ <xsl:when test="normalize-space($asciimath) != ''">
6266
+ <xsl:value-of select="$asciimath"/>
6267
+ </xsl:when>
6268
+ <xsl:otherwise>
6269
+ <xsl:value-of select="following-sibling::node()[1][self::comment()]"/>
6270
+ </xsl:otherwise>
6271
+ </xsl:choose>
6272
+ </xsl:variable>
6273
+ <xsl:variable name="asciimath_text_">
6274
+ <xsl:choose>
6275
+ <xsl:when test="normalize-space($asciimath_text_following) != ''">
6276
+ <xsl:value-of select="$asciimath_text_following"/>
6277
+ </xsl:when>
6278
+ <xsl:otherwise>
6279
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
6280
+ </xsl:otherwise>
6281
+ </xsl:choose>
6282
+ </xsl:variable>
6283
+ <xsl:variable name="asciimath_text_2" select="java:org.metanorma.fop.Util.unescape($asciimath_text_)"/>
6284
+ <xsl:variable name="asciimath_text" select="java:trim(java:java.lang.String.new($asciimath_text_2))"/>
6285
+ <xsl:value-of select="$asciimath_text"/>
6286
+ </xsl:template>
6287
+
6210
6288
  <xsl:template name="mathml_instream_object">
6211
- <xsl:param name="comment_text"/>
6289
+ <xsl:param name="asciimath_text"/>
6212
6290
  <xsl:param name="mathml_content"/>
6213
6291
 
6214
- <xsl:variable name="comment_text_">
6292
+ <xsl:variable name="asciimath_text_">
6215
6293
  <xsl:choose>
6216
- <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
6217
- <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
6294
+ <xsl:when test="normalize-space($asciimath_text) != ''"><xsl:value-of select="$asciimath_text"/></xsl:when>
6295
+ <!-- <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise> -->
6296
+ <xsl:otherwise><xsl:call-template name="getMathml_asciimath_text"/></xsl:otherwise>
6218
6297
  </xsl:choose>
6219
6298
  </xsl:variable>
6220
6299
 
@@ -6238,10 +6317,10 @@
6238
6317
  </xsl:attribute>
6239
6318
 
6240
6319
  <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
6241
- <xsl:if test="normalize-space($comment_text_) != ''">
6320
+ <xsl:if test="normalize-space($asciimath_text_) != ''">
6242
6321
  <!-- put Mathin Alternate Text -->
6243
6322
  <xsl:attribute name="fox:alt-text">
6244
- <xsl:value-of select="$comment_text_"/>
6323
+ <xsl:value-of select="$asciimath_text_"/>
6245
6324
  </xsl:attribute>
6246
6325
  </xsl:if>
6247
6326
  <!-- </xsl:if> -->
@@ -6314,6 +6393,29 @@
6314
6393
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6315
6394
  </xsl:template>
6316
6395
 
6396
+ <!-- Examples:
6397
+ <stem type="AsciiMath">x = 1</stem>
6398
+ <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
6399
+ <stem type="AsciiMath"><asciimath>x = 1</asciimath><latexmath>x = 1</latexmath></stem>
6400
+ -->
6401
+ <xsl:template match="*[local-name() = 'stem'][@type = 'AsciiMath'][count(*) = 0]/text() | *[local-name() = 'stem'][@type = 'AsciiMath'][*[local-name() = 'asciimath']]" priority="3">
6402
+ <fo:inline xsl:use-attribute-sets="mathml-style">
6403
+
6404
+ <xsl:choose>
6405
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
6406
+ <xsl:otherwise>
6407
+ <xsl:apply-templates>
6408
+ <xsl:with-param name="process">true</xsl:with-param>
6409
+ </xsl:apply-templates>
6410
+ </xsl:otherwise>
6411
+ </xsl:choose>
6412
+
6413
+ </fo:inline>
6414
+ </xsl:template>
6415
+ <!-- ======================================= -->
6416
+ <!-- END: math -->
6417
+ <!-- ======================================= -->
6418
+
6317
6419
  <xsl:template match="*[local-name()='localityStack']"/>
6318
6420
 
6319
6421
  <xsl:template match="*[local-name()='link']" name="link">
@@ -7652,9 +7754,9 @@
7652
7754
  <xsl:apply-templates mode="contents_item"/>
7653
7755
  </xsl:template>
7654
7756
 
7655
- <!-- ====== -->
7656
- <!-- sourcecode -->
7657
- <!-- ====== -->
7757
+ <!-- =============== -->
7758
+ <!-- sourcecode -->
7759
+ <!-- =============== -->
7658
7760
  <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
7659
7761
 
7660
7762
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
@@ -7952,8 +8054,22 @@
7952
8054
  </fo:block>
7953
8055
  </xsl:if>
7954
8056
  </xsl:template>
7955
- <!-- ====== -->
7956
- <!-- ====== -->
8057
+ <!-- =============== -->
8058
+ <!-- END sourcecode -->
8059
+ <!-- =============== -->
8060
+
8061
+ <!-- =============== -->
8062
+ <!-- pre -->
8063
+ <!-- =============== -->
8064
+ <xsl:template match="*[local-name()='pre']" name="pre">
8065
+ <fo:block xsl:use-attribute-sets="pre-style">
8066
+ <xsl:copy-of select="@id"/>
8067
+ <xsl:apply-templates/>
8068
+ </fo:block>
8069
+ </xsl:template>
8070
+ <!-- =============== -->
8071
+ <!-- pre -->
8072
+ <!-- =============== -->
7957
8073
 
7958
8074
  <!-- ========== -->
7959
8075
  <!-- permission -->
@@ -10035,7 +10151,7 @@
10035
10151
 
10036
10152
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
10037
10153
 
10038
- <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">
10154
+ <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">
10039
10155
 
10040
10156
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10041
10157
  <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
@@ -10508,13 +10624,14 @@
10508
10624
  </xsl:template>
10509
10625
 
10510
10626
  <xsl:template name="setId">
10627
+ <xsl:param name="prefix"/>
10511
10628
  <xsl:attribute name="id">
10512
10629
  <xsl:choose>
10513
10630
  <xsl:when test="@id">
10514
- <xsl:value-of select="@id"/>
10631
+ <xsl:value-of select="concat($prefix, @id)"/>
10515
10632
  </xsl:when>
10516
10633
  <xsl:otherwise>
10517
- <xsl:value-of select="generate-id()"/>
10634
+ <xsl:value-of select="concat($prefix, generate-id())"/>
10518
10635
  </xsl:otherwise>
10519
10636
  </xsl:choose>
10520
10637
  </xsl:attribute>