metanorma-jis 0.2.9 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5802f552014937f59b4ac8509da44c12a6d1daba68d6c68ec4580701ef9629b9
4
- data.tar.gz: 56027208cc4e320b533bb43e391ffb48104c81d9dc322e1279cf8a956d4a5a3e
3
+ metadata.gz: 1fd45b34656e8ad9ca11060ef7bd5de64e5d8140f56122d65a9b1a2c211d9f2f
4
+ data.tar.gz: f98c49a2d90f36fb4f9b408e2ce48f9d34c83c28ddc8e265746458bfa54b1ae2
5
5
  SHA512:
6
- metadata.gz: 9a922521b2270dcef779ad8fe7901e29bfed9e6d30e7b0035fd05023a8f0540f840ce5dcb23df380376e74c3cbbf571ab934788f53ad038a6d561359ba77f2c9
7
- data.tar.gz: f013e980b0548dc9a2959b2857109f0d1a28742b3778d39982d5650478c088405a6c7813c6e07fe31691acd23679b8d4f9fb80aa740b1d3fa384d0322a7051b0
6
+ metadata.gz: 338dac9a6839cf63f0b97c1d5d3d571ef230a73da1622f0fd2fb5cc54d7d799de9566dc31d9b3786a584499f55e58ddd40f2ee2344cfea89fe1772054b388a3e
7
+ data.tar.gz: 4cc95fc4ffc266b99695f45ae325645fdf176a0aab739dc2f60db983d4d1a02659f36f2e4f8c08f3fefde9beac8fa9a553f7e5934a6fbe89a42c52473eb3ae1e
@@ -4,8 +4,6 @@
4
4
 
5
5
  <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
- <xsl:variable name="namespace_full">https://www.metanorma.org/ns/jis</xsl:variable>
8
-
9
7
  <xsl:variable name="debug">false</xsl:variable>
10
8
 
11
9
  <xsl:variable name="contents_">
@@ -1619,7 +1617,9 @@
1619
1617
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="jis:xref"/>
1620
1618
 
1621
1619
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
1622
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
1620
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
1621
+
1622
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="document_scheme" select="normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'document-scheme']/*[local-name() = 'value'])"/>
1623
1623
 
1624
1624
  <!-- external parameters -->
1625
1625
 
@@ -3298,41 +3298,9 @@
3298
3298
  </xsl:for-each>
3299
3299
  </xsl:template>
3300
3300
 
3301
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
3302
-
3303
- <xsl:variable name="updated_xml_step_move_pagebreak_">
3304
-
3305
- <xsl:element name="{$root_element}" namespace="{$namespace_full}">
3306
-
3307
- <xsl:call-template name="copyCommonElements"/>
3308
-
3309
- <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
3310
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
3311
- <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3312
- <xsl:sort select="@displayorder" data-type="number"/>
3313
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3314
- </xsl:for-each>
3315
- </xsl:element>
3316
- </xsl:element>
3317
- </xsl:element>
3318
- </xsl:variable>
3319
-
3320
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3321
-
3322
- <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
3323
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
3324
- </redirect:write>
3325
-
3326
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3327
-
3328
- <xsl:call-template name="deleteFile">
3329
- <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
3330
- </xsl:call-template>
3331
- </xsl:template>
3332
-
3333
3301
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
3334
3302
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
3335
- <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography']"/>
3303
+ <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography' and local-name() != 'indexsect']"/>
3336
3304
  </xsl:template>
3337
3305
 
3338
3306
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault">
@@ -3353,38 +3321,16 @@
3353
3321
  </xsl:for-each>
3354
3322
  </xsl:template><!-- END: processMainSectionsDefault -->
3355
3323
 
3356
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
3357
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3358
- <xsl:sort select="@displayorder" data-type="number"/>
3359
- <xsl:variable name="flatxml">
3360
- <xsl:apply-templates select="." mode="flatxml"/>
3361
- </xsl:variable>
3362
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3363
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3364
-
3365
- </xsl:for-each>
3366
-
3367
- <xsl:for-each select="/*/*[local-name()='annex']">
3368
- <xsl:sort select="@displayorder" data-type="number"/>
3369
- <xsl:variable name="flatxml">
3370
- <xsl:apply-templates select="." mode="flatxml"/>
3371
- </xsl:variable>
3372
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3373
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3374
- </xsl:for-each>
3375
-
3376
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3377
- <xsl:sort select="@displayorder" data-type="number"/>
3378
- <xsl:variable name="flatxml">
3379
- <xsl:apply-templates select="." mode="flatxml"/>
3380
- </xsl:variable>
3381
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3382
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3383
- </xsl:for-each>
3384
- </xsl:template>
3385
-
3386
3324
  <!-- Example:
3387
3325
  <iso-standard>
3326
+ <preface>
3327
+ <page_sequence>
3328
+ <clause...
3329
+ </page_sequence>
3330
+ <page_sequence>
3331
+ <clause...
3332
+ </page_sequence>
3333
+ </preface>
3388
3334
  <sections>
3389
3335
  <page_sequence>
3390
3336
  <clause...
@@ -3401,54 +3347,200 @@
3401
3347
  </page_sequence>
3402
3348
  </iso-standard>
3403
3349
  -->
3404
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
3405
-
3406
- <xsl:variable name="updated_xml_step_move_pagebreak_">
3350
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceAndMainSectionsDefault_items">
3407
3351
 
3352
+ <xsl:variable name="updated_xml_step_move_pagebreak">
3408
3353
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
3409
-
3410
3354
  <xsl:call-template name="copyCommonElements"/>
3355
+ <xsl:call-template name="insertPrefaceSectionsPageSequences"/>
3356
+ <xsl:call-template name="insertMainSectionsPageSequences"/>
3357
+ </xsl:element>
3358
+ </xsl:variable>
3411
3359
 
3412
- <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
3413
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
3414
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3415
- <xsl:sort select="@displayorder" data-type="number"/>
3416
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3360
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3417
3361
 
3418
- </xsl:for-each>
3419
- </xsl:element>
3362
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
3363
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3364
+ </redirect:write>
3365
+
3366
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3367
+
3368
+ <xsl:if test="$debug = 'true'">
3369
+ <redirect:write file="page_sequence_preface_and_main.xml">
3370
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3371
+ </redirect:write>
3372
+ </xsl:if>
3373
+
3374
+ <xsl:call-template name="deleteFile">
3375
+ <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
3376
+ </xsl:call-template>
3377
+ </xsl:template> <!-- END: processPrefaceAndMainSectionsDefault_items -->
3378
+
3379
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSectionsPageSequences">
3380
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
3381
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3382
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3383
+ <xsl:sort select="@displayorder" data-type="number"/>
3384
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3385
+ </xsl:for-each>
3386
+ </xsl:element>
3387
+ </xsl:element>
3388
+ </xsl:template> <!-- END: insertPrefaceSectionsPageSequences -->
3389
+
3390
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsPageSequences">
3391
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
3392
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3393
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3394
+ <xsl:sort select="@displayorder" data-type="number"/>
3395
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3396
+
3397
+ </xsl:for-each>
3398
+ </xsl:element>
3399
+ </xsl:element>
3400
+
3401
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3402
+ <xsl:for-each select="/*/*[local-name()='annex']">
3403
+ <xsl:sort select="@displayorder" data-type="number"/>
3404
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3405
+ </xsl:for-each>
3406
+ </xsl:element>
3407
+
3408
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3409
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
3410
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3411
+ <xsl:sort select="@displayorder" data-type="number"/>
3412
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3413
+ </xsl:for-each>
3414
+ </xsl:element>
3415
+ </xsl:element>
3416
+ </xsl:template> <!-- END: insertMainSectionsPageSequences -->
3417
+
3418
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsInSeparatePageSequences">
3419
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
3420
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3421
+ <xsl:sort select="@displayorder" data-type="number"/>
3422
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3423
+ <xsl:attribute name="main_page_sequence"/>
3424
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3420
3425
  </xsl:element>
3426
+ </xsl:for-each>
3427
+ </xsl:element>
3421
3428
 
3429
+ <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
3430
+
3431
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
3432
+
3433
+ <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
3434
+ </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
3435
+
3436
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
3437
+ <xsl:for-each select="/*/*[local-name()='annex']">
3438
+ <xsl:sort select="@displayorder" data-type="number"/>
3439
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3440
+ <xsl:attribute name="main_page_sequence"/>
3441
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3442
+ </xsl:element>
3443
+ </xsl:for-each>
3444
+ </xsl:template>
3445
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBibliographyInSeparatePageSequences">
3446
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
3447
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3448
+ <xsl:sort select="@displayorder" data-type="number"/>
3422
3449
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
3423
- <xsl:for-each select="/*/*[local-name()='annex']">
3424
- <xsl:sort select="@displayorder" data-type="number"/>
3425
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3426
- </xsl:for-each>
3450
+ <xsl:attribute name="main_page_sequence"/>
3451
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3427
3452
  </xsl:element>
3453
+ </xsl:for-each>
3454
+ </xsl:element>
3455
+ </xsl:template>
3456
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertIndexInSeparatePageSequences">
3457
+ <xsl:for-each select="/*/*[local-name()='indexsect']">
3458
+ <xsl:sort select="@displayorder" data-type="number"/>
3459
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3460
+ <xsl:attribute name="main_page_sequence"/>
3461
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3462
+ </xsl:element>
3463
+ </xsl:for-each>
3464
+ </xsl:template>
3428
3465
 
3466
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processAllSectionsDefault_items">
3467
+ <xsl:variable name="updated_xml_step_move_pagebreak">
3468
+ <xsl:element name="{$root_element}" namespace="{$namespace_full}">
3469
+ <xsl:call-template name="copyCommonElements"/>
3429
3470
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
3430
- <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
3431
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3432
- <xsl:sort select="@displayorder" data-type="number"/>
3433
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3434
- </xsl:for-each>
3435
- </xsl:element>
3471
+ <xsl:call-template name="insertPrefaceSections"/>
3472
+ <xsl:call-template name="insertMainSections"/>
3436
3473
  </xsl:element>
3437
3474
  </xsl:element>
3438
3475
  </xsl:variable>
3439
3476
 
3440
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3441
-
3477
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_and_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3478
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
3479
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
3442
3480
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
3443
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
3481
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3444
3482
  </redirect:write>
3483
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
3445
3484
 
3446
3485
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3447
3486
 
3487
+ <!-- TODO: instead of
3488
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
3489
+ in each template, add removing empty page_sequence here
3490
+ -->
3491
+
3492
+ <xsl:if test="$debug = 'true'">
3493
+ <redirect:write file="page_sequence_preface_and_main.xml">
3494
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3495
+ </redirect:write>
3496
+ </xsl:if>
3497
+
3498
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
3448
3499
  <xsl:call-template name="deleteFile">
3449
3500
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
3450
3501
  </xsl:call-template>
3451
- </xsl:template> <!-- END: processMainSectionsDefault_items -->
3502
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
3503
+ </xsl:template> <!-- END: processAllSectionsDefault_items -->
3504
+
3505
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSections">
3506
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
3507
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3508
+ <xsl:sort select="@displayorder" data-type="number"/>
3509
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
3510
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
3511
+ </xsl:apply-templates>
3512
+ </xsl:for-each>
3513
+ </xsl:element>
3514
+ </xsl:template>
3515
+
3516
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSections">
3517
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
3518
+
3519
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3520
+ <xsl:sort select="@displayorder" data-type="number"/>
3521
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
3522
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
3523
+ </xsl:apply-templates>
3524
+
3525
+ </xsl:for-each>
3526
+ </xsl:element>
3527
+
3528
+ <xsl:for-each select="/*/*[local-name()='annex']">
3529
+ <xsl:sort select="@displayorder" data-type="number"/>
3530
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
3531
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
3532
+ </xsl:apply-templates>
3533
+ </xsl:for-each>
3534
+
3535
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
3536
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3537
+ <xsl:sort select="@displayorder" data-type="number"/>
3538
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
3539
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
3540
+ </xsl:apply-templates>
3541
+ </xsl:for-each>
3542
+ </xsl:element>
3543
+ </xsl:template>
3452
3544
 
3453
3545
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="deleteFile">
3454
3546
  <xsl:param name="filepath"/>
@@ -3457,6 +3549,14 @@
3457
3549
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
3458
3550
  </xsl:template>
3459
3551
 
3552
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
3553
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
3554
+ <xsl:choose>
3555
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
3556
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
3557
+ </xsl:choose>
3558
+ </xsl:template>
3559
+
3460
3560
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3461
3561
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
3462
3562
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
@@ -3485,9 +3585,16 @@
3485
3585
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3486
3586
  <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3487
3587
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3488
- <fo:inline keep-together.within-line="always">
3489
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3490
- </fo:inline>
3588
+ <xsl:choose>
3589
+ <xsl:when test="local-name(..) = 'keep-together_within-line'"> <!-- prevent two nested <fo:inline keep-together.within-line="always"><fo:inline keep-together.within-line="always" -->
3590
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3591
+ </xsl:when>
3592
+ <xsl:otherwise>
3593
+ <fo:inline keep-together.within-line="always" role="SKIP">
3594
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3595
+ </fo:inline>
3596
+ </xsl:otherwise>
3597
+ </xsl:choose>
3491
3598
  <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3492
3599
  <xsl:call-template name="replace_fo_inline_tags">
3493
3600
  <xsl:with-param name="tag_open" select="$tag_open"/>
@@ -3789,7 +3896,9 @@
3789
3896
 
3790
3897
  <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
3791
3898
  <xsl:if test="$isNoteOrFnExist = 'true'">
3792
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3899
+
3900
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3901
+
3793
3902
  </xsl:if>
3794
3903
 
3795
3904
  <xsl:choose>
@@ -3846,13 +3955,14 @@
3846
3955
  </fo:table>
3847
3956
 
3848
3957
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
3849
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3850
- <xsl:call-template name="insertTableFooterInSeparateTable">
3851
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
3852
- <xsl:with-param name="colwidths" select="$colwidths"/>
3853
- <xsl:with-param name="colgroup" select="$colgroup"/>
3854
- </xsl:call-template>
3855
- </xsl:for-each>
3958
+
3959
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3960
+ <xsl:call-template name="insertTableFooterInSeparateTable">
3961
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
3962
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3963
+ <xsl:with-param name="colgroup" select="$colgroup"/>
3964
+ </xsl:call-template>
3965
+ </xsl:for-each>
3856
3966
 
3857
3967
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
3858
3968
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -3873,6 +3983,27 @@
3873
3983
 
3874
3984
  <!-- centered table when table name is centered (see table-name-style) -->
3875
3985
 
3986
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
3987
+
3988
+ <fo:table-column column-width="proportional-column-width(1)"/>
3989
+ <fo:table-column column-width="{@width}"/>
3990
+ <fo:table-column column-width="proportional-column-width(1)"/>
3991
+ <fo:table-body>
3992
+ <fo:table-row>
3993
+ <fo:table-cell column-number="2">
3994
+ <xsl:copy-of select="$table-preamble"/>
3995
+ <fo:block role="SKIP">
3996
+ <xsl:call-template name="setTrackChangesStyles">
3997
+ <xsl:with-param name="isAdded" select="$isAdded"/>
3998
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
3999
+ </xsl:call-template>
4000
+ <xsl:copy-of select="$table"/>
4001
+ </fo:block>
4002
+ </fo:table-cell>
4003
+ </fo:table-row>
4004
+ </fo:table-body>
4005
+ </fo:table>
4006
+
3876
4007
  </xsl:when>
3877
4008
  <xsl:otherwise>
3878
4009
  <xsl:choose>
@@ -4221,8 +4352,10 @@
4221
4352
  <width_min><xsl:value-of select="@width_min"/></width_min>
4222
4353
  <e><xsl:value-of select="$d * $W div $D"/></e>
4223
4354
  <!-- set the column's width to the minimum width plus d times W over D. -->
4355
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4356
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
4224
4357
  <column divider="100">
4225
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4358
+ <xsl:value-of select="$column_width"/>
4226
4359
  </column>
4227
4360
  </xsl:for-each>
4228
4361
 
@@ -4624,8 +4757,26 @@
4624
4757
  <xsl:with-param name="default">center</xsl:with-param>
4625
4758
  </xsl:call-template>
4626
4759
 
4760
+ <xsl:copy-of select="@keep-together.within-line"/>
4761
+
4627
4762
  <xsl:call-template name="refine_table-header-cell-style"/>
4628
4763
 
4764
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
4765
+ <!-- <xsl:choose>
4766
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
4767
+ <fo:block-container reference-orientation="270">
4768
+ <fo:block role="SKIP" text-align="start">
4769
+ <xsl:apply-templates />
4770
+ </fo:block>
4771
+ </fo:block-container>
4772
+ </xsl:when>
4773
+ <xsl:otherwise>
4774
+ <fo:block role="SKIP">
4775
+ <xsl:apply-templates />
4776
+ </fo:block>
4777
+ </xsl:otherwise>
4778
+ </xsl:choose> -->
4779
+
4629
4780
  <fo:block role="SKIP">
4630
4781
  <xsl:apply-templates/>
4631
4782
  </fo:block>
@@ -4666,6 +4817,8 @@
4666
4817
  <xsl:with-param name="default">left</xsl:with-param>
4667
4818
  </xsl:call-template>
4668
4819
 
4820
+ <xsl:copy-of select="@keep-together.within-line"/>
4821
+
4669
4822
  <xsl:call-template name="refine_table-cell-style"/>
4670
4823
 
4671
4824
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
@@ -4791,7 +4944,7 @@
4791
4944
  <xsl:copy-of select="."/>
4792
4945
  </xsl:for-each>
4793
4946
 
4794
- <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
4947
+ <xsl:if test="following-sibling::node()[normalize-space() != ''][1][local-name() = 'fn']">
4795
4948
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
4796
4949
  </xsl:if>
4797
4950
 
@@ -4858,7 +5011,7 @@
4858
5011
  <xsl:copy-of select="node()"/>
4859
5012
  </fn>
4860
5013
  </xsl:for-each>
4861
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*">
5014
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*">
4862
5015
  <xsl:sort select="@displayorder" data-type="number"/>
4863
5016
  <!-- commented:
4864
5017
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
@@ -4943,6 +5096,11 @@
4943
5096
 
4944
5097
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="create_fn">
4945
5098
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
5099
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
5100
+ <xsl:attribute name="id">
5101
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
5102
+ </xsl:attribute>
5103
+ </xsl:if>
4946
5104
 
4947
5105
  <xsl:apply-templates/>
4948
5106
  </fn>
@@ -5086,6 +5244,11 @@
5086
5244
  <xsl:call-template name="refine_fn-reference-style"/>
5087
5245
 
5088
5246
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
5247
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
5248
+ <xsl:attribute name="internal-destination">
5249
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
5250
+ </xsl:attribute>
5251
+ </xsl:if>
5089
5252
 
5090
5253
  <xsl:value-of select="@reference"/>
5091
5254
 
@@ -6131,7 +6294,7 @@
6131
6294
 
6132
6295
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="recursiveSmallCaps">
6133
6296
  <xsl:param name="text"/>
6134
- <xsl:param name="ratio"/>
6297
+ <xsl:param name="ratio">0.75</xsl:param>
6135
6298
  <xsl:variable name="char" select="substring($text,1,1)"/>
6136
6299
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
6137
6300
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
@@ -8131,6 +8294,15 @@
8131
8294
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
8132
8295
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
8133
8296
  </xsl:when>
8297
+ <!-- in WebP format, then convert image into PNG -->
8298
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
8299
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
8300
+ <xsl:value-of select="$src_png"/>
8301
+ </xsl:when>
8302
+ <xsl:when test="not(starts-with(@src, 'data:')) and (java:endsWith(java:java.lang.String.new(@src), '.webp') or java:endsWith(java:java.lang.String.new(@src), '.WEBP'))">
8303
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
8304
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8305
+ </xsl:when>
8134
8306
  <xsl:when test="not(starts-with(@src, 'data:'))">
8135
8307
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8136
8308
  </xsl:when>
@@ -8221,6 +8393,8 @@
8221
8393
  </xsl:choose>
8222
8394
  </xsl:variable>
8223
8395
 
8396
+ <xsl:variable name="isPrecedingTitle" select="normalize-space(ancestor::*[local-name() = 'figure']/preceding-sibling::*[1][local-name() = 'title'] and 1 = 1)"/>
8397
+
8224
8398
  <xsl:choose>
8225
8399
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
8226
8400
  <fo:block>
@@ -8367,7 +8541,14 @@
8367
8541
  <xsl:variable name="scale_y">
8368
8542
  <xsl:choose>
8369
8543
  <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
8370
- <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
8544
+ <xsl:variable name="height_effective_px_">
8545
+ <xsl:choose>
8546
+ <!-- title is 'keep-with-next' with following figure -->
8547
+ <xsl:when test="$isPrecedingTitle = 'true'"><xsl:value-of select="$height_effective_px - 80"/></xsl:when>
8548
+ <xsl:otherwise><xsl:value-of select="$height_effective_px"/></xsl:otherwise>
8549
+ </xsl:choose>
8550
+ </xsl:variable>
8551
+ <xsl:value-of select="$height_effective_px_ div ($svg_height * $scale_x)"/>
8371
8552
  </xsl:when>
8372
8553
  <xsl:otherwise>1</xsl:otherwise>
8373
8554
  </xsl:choose>
@@ -8786,7 +8967,7 @@
8786
8967
  </xsl:if>
8787
8968
 
8788
8969
  <xsl:for-each select="$contents_nodes/doc">
8789
- <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
8970
+ <fo:bookmark internal-destination="{contents/item[@display = 'true'][1]/@id}" starting-state="hide">
8790
8971
  <xsl:if test="@bundle = 'true'">
8791
8972
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
8792
8973
  </xsl:if>
@@ -9996,9 +10177,17 @@
9996
10177
 
9997
10178
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
9998
10179
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
9999
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
10000
- <xsl:with-param name="fo_element" select="$fo_element"/>
10001
- </xsl:apply-templates>
10180
+ <xsl:variable name="example_body">
10181
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
10182
+ <xsl:with-param name="fo_element" select="$fo_element"/>
10183
+ </xsl:apply-templates>
10184
+ </xsl:variable>
10185
+ <xsl:choose>
10186
+ <xsl:when test="xalan:nodeset($example_body)/*">
10187
+ <xsl:copy-of select="$example_body"/>
10188
+ </xsl:when>
10189
+ <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise>
10190
+ </xsl:choose>
10002
10191
  </fo:block-container>
10003
10192
  </fo:block-container>
10004
10193
  </xsl:when> <!-- end block -->
@@ -10533,7 +10722,22 @@
10533
10722
 
10534
10723
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
10535
10724
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2">
10536
- <xsl:call-template name="sections_node"/>
10725
+ <xsl:choose>
10726
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
10727
+ <xsl:otherwise>
10728
+ <xsl:call-template name="sections_node"/>
10729
+ </xsl:otherwise>
10730
+ </xsl:choose>
10731
+ </xsl:template>
10732
+
10733
+ <!-- page_sequence/sections/clause -->
10734
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2">
10735
+ <xsl:choose>
10736
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
10737
+ <xsl:otherwise>
10738
+ <xsl:call-template name="sections_node"/>
10739
+ </xsl:otherwise>
10740
+ </xsl:choose>
10537
10741
  </xsl:template>
10538
10742
 
10539
10743
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -10550,8 +10754,24 @@
10550
10754
  </fo:block>
10551
10755
  </xsl:template>
10552
10756
 
10553
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
10554
- <xsl:call-template name="preface_node"/>
10757
+ <!-- preface/ page_sequence/clause -->
10758
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
10759
+ <xsl:choose>
10760
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
10761
+ <xsl:otherwise>
10762
+ <xsl:call-template name="preface_node"/>
10763
+ </xsl:otherwise>
10764
+ </xsl:choose>
10765
+ </xsl:template>
10766
+
10767
+ <!-- page_sequence/preface/clause -->
10768
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'preface']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
10769
+ <xsl:choose>
10770
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
10771
+ <xsl:otherwise>
10772
+ <xsl:call-template name="preface_node"/>
10773
+ </xsl:otherwise>
10774
+ </xsl:choose>
10555
10775
  </xsl:template>
10556
10776
 
10557
10777
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
@@ -11811,6 +12031,82 @@
11811
12031
  <!-- ===================================== -->
11812
12032
  <!-- Update xml -->
11813
12033
  <!-- ===================================== -->
12034
+
12035
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
12036
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
12037
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
12038
+
12039
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12040
+ <xsl:variable name="updated_xml_step1">
12041
+ <xsl:if test="$table_if = 'false'">
12042
+ <xsl:apply-templates mode="update_xml_step1"/>
12043
+ </xsl:if>
12044
+ </xsl:variable>
12045
+
12046
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
12047
+ <xsl:if test="$debug = 'true'">
12048
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
12049
+ <xsl:message>END updated_xml_step1</xsl:message>
12050
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
12051
+ <xsl:copy-of select="$updated_xml_step1"/>
12052
+ </redirect:write> -->
12053
+ </xsl:if>
12054
+
12055
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
12056
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
12057
+
12058
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12059
+ <xsl:variable name="updated_xml_step2">
12060
+
12061
+ <xsl:if test="$table_if = 'false'">
12062
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step1)" mode="update_xml_step2"/>
12063
+ </xsl:if>
12064
+
12065
+ </xsl:variable>
12066
+
12067
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
12068
+ <xsl:if test="$debug = 'true'">
12069
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
12070
+ <xsl:message>END updated_xml_step2</xsl:message>
12071
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
12072
+ <xsl:copy-of select="$updated_xml_step2"/>
12073
+ </redirect:write> -->
12074
+ </xsl:if>
12075
+
12076
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
12077
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
12078
+
12079
+ <xsl:variable name="updated_xml_step3">
12080
+ <xsl:choose>
12081
+ <xsl:when test="$table_if = 'false'">
12082
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
12083
+ </xsl:when>
12084
+ <xsl:otherwise>
12085
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
12086
+ </xsl:otherwise>
12087
+ </xsl:choose>
12088
+ </xsl:variable>
12089
+
12090
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
12091
+ <xsl:if test="$debug = 'true'">
12092
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
12093
+ <xsl:message>END updated_xml_step3</xsl:message>
12094
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
12095
+ <xsl:copy-of select="$updated_xml_step3"/>
12096
+ </redirect:write> -->
12097
+ </xsl:if>
12098
+
12099
+ <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if>
12100
+ <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> -->
12101
+ <xsl:copy-of select="$updated_xml_step3"/>
12102
+ <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/>
12103
+ <xsl:if test="$debug = 'true'">
12104
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message>
12105
+ <xsl:message>END copying updated_xml_step3</xsl:message>
12106
+ </xsl:if> -->
12107
+
12108
+ </xsl:template>
12109
+
11814
12110
  <!-- =========================================================================== -->
11815
12111
  <!-- STEP1: -->
11816
12112
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -11989,14 +12285,17 @@
11989
12285
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
11990
12286
  <!-- =========================================================================== -->
11991
12287
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="update_xml_step_move_pagebreak">
12288
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
11992
12289
  <xsl:copy>
11993
- <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
12290
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak">
12291
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
12292
+ </xsl:apply-templates>
11994
12293
  </xsl:copy>
11995
12294
  </xsl:template>
11996
12295
 
11997
12296
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
11998
12297
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="update_xml_step_move_pagebreak">
11999
-
12298
+ <xsl:param name="page_sequence_at_top"/>
12000
12299
  <!-- <xsl:choose>
12001
12300
  <xsl:when test="ancestor::*[local-name() = 'sections']">
12002
12301
 
@@ -12010,7 +12309,7 @@
12010
12309
 
12011
12310
  <!-- determine pagebreak is last element before </fo:flow> or not -->
12012
12311
  <xsl:variable name="isLast">
12013
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12312
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12014
12313
  <xsl:if test="following-sibling::*">false</xsl:if>
12015
12314
  </xsl:for-each>
12016
12315
  </xsl:variable>
@@ -12020,7 +12319,9 @@
12020
12319
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
12021
12320
 
12022
12321
  <xsl:variable name="tree_">
12023
- <xsl:call-template name="makeAncestorsElementsTree"/>
12322
+ <xsl:call-template name="makeAncestorsElementsTree">
12323
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
12324
+ </xsl:call-template>
12024
12325
  </xsl:variable>
12025
12326
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
12026
12327
 
@@ -12032,7 +12333,7 @@
12032
12333
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
12033
12334
 
12034
12335
  <!-- create a new page_sequence (opening elements) -->
12035
- <xsl:text disable-output-escaping="yes">&lt;page_sequence namespace="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
12336
+ <xsl:text disable-output-escaping="yes">&lt;page_sequence xmlns="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
12036
12337
 
12037
12338
  <xsl:call-template name="insertOpeningElements">
12038
12339
  <xsl:with-param name="tree" select="$tree"/>
@@ -12042,12 +12343,26 @@
12042
12343
  </xsl:template>
12043
12344
 
12044
12345
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
12045
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12046
- <element pos="{position()}">
12047
- <xsl:copy-of select="@*[local-name() != 'id']"/>
12048
- <xsl:value-of select="name()"/>
12049
- </element>
12050
- </xsl:for-each>
12346
+ <xsl:param name="page_sequence_at_top"/>
12347
+
12348
+ <xsl:choose>
12349
+ <xsl:when test="$page_sequence_at_top = 'true'">
12350
+ <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]">
12351
+ <element pos="{position()}">
12352
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
12353
+ <xsl:value-of select="name()"/>
12354
+ </element>
12355
+ </xsl:for-each>
12356
+ </xsl:when>
12357
+ <xsl:otherwise>
12358
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12359
+ <element pos="{position()}">
12360
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
12361
+ <xsl:value-of select="name()"/>
12362
+ </element>
12363
+ </xsl:for-each>
12364
+ </xsl:otherwise>
12365
+ </xsl:choose>
12051
12366
  </xsl:template>
12052
12367
 
12053
12368
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -12085,11 +12400,14 @@
12085
12400
 
12086
12401
  <!-- move full page width figures, tables at top level -->
12087
12402
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'figure' or local-name() = 'table'][normalize-space(@width) != 'text-width']" mode="update_xml_step_move_pagebreak">
12403
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
12088
12404
  <xsl:choose>
12089
12405
  <xsl:when test="$layout_columns != 1">
12090
12406
 
12091
12407
  <xsl:variable name="tree_">
12092
- <xsl:call-template name="makeAncestorsElementsTree"/>
12408
+ <xsl:call-template name="makeAncestorsElementsTree">
12409
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
12410
+ </xsl:call-template>
12093
12411
  </xsl:variable>
12094
12412
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
12095
12413
 
@@ -12237,81 +12555,140 @@
12237
12555
 
12238
12556
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
12239
12557
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/>
12558
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable>
12240
12559
 
12241
12560
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
12561
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12562
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12242
12563
 
12243
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" 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 ancestor::*[local-name() = 'svg'] 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">
12564
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
12565
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
12566
+ <!-- add &lt; and &gt; to \S -->
12567
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
12568
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" 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>
12244
12569
 
12245
- <!-- enclose standard's number into tag 'keep-together_within-line' -->
12246
- <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12247
- <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12248
- <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))"/>
12249
- <xsl:variable name="text_">
12250
- <xsl:choose>
12251
- <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 -->
12252
- <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
12253
- </xsl:choose>
12254
- </xsl:variable>
12255
- <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
12570
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
12571
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
12572
+
12573
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" 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 ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') or normalize-space() = '' )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
12574
+
12575
+ <xsl:variable name="parent" select="local-name(..)"/>
12576
+
12577
+ <xsl:if test="1 = 2"> <!-- alternative variant -->
12578
+
12579
+ <xsl:variable name="regexs">
12580
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
12581
+ <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if>
12582
+ <!-- if EXPRESS reference -->
12583
+
12584
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
12585
+ <regex><xsl:value-of select="$regex_solidus_units"/></regex>
12586
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
12587
+ <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
12588
+ <regex><xsl:value-of select="$regex_dots_units"/></regex>
12589
+ </xsl:if>
12590
+ </xsl:variable>
12591
+
12592
+ <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text>
12593
+ <xsl:for-each select="xalan:nodeset($regexs)/regex">
12594
+ <xsl:value-of select="."/>
12595
+ <xsl:if test="position() != last()">|</xsl:if>
12596
+ </xsl:for-each>
12597
+ <xsl:text>)</xsl:text>
12598
+ </xsl:variable>
12599
+
12600
+ <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' -->
12601
+
12602
+ <xsl:variable name="text_replaced" select="java:replaceAll(java:java.lang.String.new(.), $regex_replacement, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
12603
+
12604
+ <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' -->
12605
+
12606
+ <xsl:call-template name="replace_text_tags">
12256
12607
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12257
12608
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12258
- <xsl:with-param name="text" select="$text_"/>
12259
- </xsl:call-template></text></xsl:variable>
12609
+ <xsl:with-param name="text" select="$text_replaced"/>
12610
+ </xsl:call-template>
12611
+ </xsl:if>
12260
12612
 
12261
- <xsl:variable name="parent" select="local-name(..)"/>
12613
+ <xsl:if test="1 = 1">
12614
+
12615
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
12616
+ <xsl:variable name="text">
12617
+ <xsl:element name="text" namespace="{$namespace_full}">
12618
+ <xsl:choose>
12619
+ <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 -->
12620
+ <xsl:otherwise>
12621
+ <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))"/>
12622
+ <!-- <xsl:value-of select="$text__"/> -->
12623
+
12624
+ <xsl:call-template name="replace_text_tags">
12625
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12626
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12627
+ <xsl:with-param name="text" select="$text_"/>
12628
+ </xsl:call-template>
12629
+
12630
+ </xsl:otherwise>
12631
+ </xsl:choose>
12632
+ </xsl:element>
12633
+ </xsl:variable>
12262
12634
 
12263
12635
  <xsl:variable name="text2">
12264
- <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
12636
+ <xsl:element name="text" namespace="{$namespace_full}">
12637
+ <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()">
12265
12638
  <xsl:copy-of select="."/>
12266
- </xsl:for-each></text>
12639
+ </xsl:for-each>
12640
+ </xsl:element>
12267
12641
  </xsl:variable>
12268
12642
 
12269
12643
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
12270
- <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
12271
- <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
12272
- <!-- add &lt; and &gt; to \S -->
12273
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
12274
- <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>
12275
12644
  <xsl:variable name="text3">
12276
- <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
12277
- <xsl:choose>
12278
- <xsl:when test="self::text()">
12279
- <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))"/>
12280
- <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
12281
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12282
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12283
- <xsl:with-param name="text" select="$text_units_"/>
12284
- </xsl:call-template></text></xsl:variable>
12285
- <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
12286
- </xsl:when>
12287
- <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
12288
- </xsl:choose>
12289
- </xsl:for-each></text>
12645
+ <xsl:element name="text" namespace="{$namespace_full}">
12646
+ <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()">
12647
+ <xsl:choose>
12648
+ <xsl:when test="self::text()">
12649
+ <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))"/>
12650
+ <!-- <xsl:variable name="text_units">
12651
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
12652
+ <xsl:call-template name="replace_text_tags">
12653
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12654
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12655
+ <xsl:with-param name="text" select="$text_units"/>
12656
+ </xsl:call-template>
12657
+ <!-- </xsl:element>
12658
+ </xsl:variable>
12659
+ <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> -->
12660
+ </xsl:when>
12661
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
12662
+ </xsl:choose>
12663
+ </xsl:for-each>
12664
+ </xsl:element>
12290
12665
  </xsl:variable>
12291
12666
 
12292
12667
  <xsl:choose>
12293
12668
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
12294
12669
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
12295
- <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
12296
- <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
12297
- <xsl:for-each select="xalan:nodeset($text3)/text/node()">
12670
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
12298
12671
  <xsl:choose>
12299
12672
  <xsl:when test="self::text()">
12300
- <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))"/>
12301
- <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
12302
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12303
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12304
- <xsl:with-param name="text" select="$text_dots_"/>
12305
- </xsl:call-template></text></xsl:variable>
12306
- <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
12673
+ <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))"/>
12674
+ <!-- <xsl:variable name="text_dots">
12675
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
12676
+ <xsl:call-template name="replace_text_tags">
12677
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12678
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
12679
+ <xsl:with-param name="text" select="$text_dots"/>
12680
+ </xsl:call-template>
12681
+ <!-- </xsl:element>
12682
+ </xsl:variable>
12683
+ <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> -->
12307
12684
  </xsl:when>
12308
12685
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
12309
12686
  </xsl:choose>
12310
12687
  </xsl:for-each>
12311
12688
  </xsl:when>
12312
- <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
12689
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise>
12313
12690
  </xsl:choose>
12314
-
12691
+ </xsl:if>
12315
12692
  </xsl:template>
12316
12693
 
12317
12694
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
@@ -12327,7 +12704,7 @@
12327
12704
  <xsl:value-of select="substring-before($text, $tag_open)"/>
12328
12705
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
12329
12706
 
12330
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
12707
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
12331
12708
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
12332
12709
  </xsl:element>
12333
12710
 
@@ -12837,6 +13214,15 @@
12837
13214
  </xsl:otherwise>
12838
13215
  </xsl:choose>
12839
13216
  </xsl:for-each>
13217
+ <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13218
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13219
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13220
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13221
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13222
+ <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13223
+ <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
13224
+ </xsl:for-each>
13225
+ </xsl:if>
12840
13226
  </xsl:template> <!-- addPDFUAmeta -->
12841
13227
 
12842
13228
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">
@@ -13150,7 +13536,10 @@
13150
13536
  <xsl:call-template name="setTextAlignment">
13151
13537
  <xsl:with-param name="default" select="$text_align_default"/>
13152
13538
  </xsl:call-template>
13539
+ <xsl:call-template name="setKeepAttributes"/>
13540
+ </xsl:template>
13153
13541
 
13542
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
13154
13543
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
13155
13544
  <!-- Example: keep-lines-together="true" -->
13156
13545
  <xsl:if test="@keep-lines-together = 'true'">
@@ -13162,6 +13551,72 @@
13162
13551
  </xsl:if>
13163
13552
  </xsl:template>
13164
13553
 
13554
+ <!-- insert cover page image -->
13555
+ <!-- background cover image -->
13556
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
13557
+ <xsl:param name="number">1</xsl:param>
13558
+ <xsl:param name="name">coverpage-image</xsl:param>
13559
+ <xsl:variable name="num" select="number($number)"/>
13560
+ <!-- background image -->
13561
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
13562
+ <fo:block>
13563
+ <xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
13564
+ <xsl:choose>
13565
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
13566
+ <fo:instream-foreign-object fox:alt-text="Image Front">
13567
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
13568
+ <xsl:call-template name="getSVG"/>
13569
+ </fo:instream-foreign-object>
13570
+ </xsl:when>
13571
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
13572
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
13573
+ </xsl:when>
13574
+ <xsl:otherwise> <!-- bitmap image -->
13575
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
13576
+ <xsl:if test="$coverimage_src != ''">
13577
+ <xsl:variable name="coverpage">
13578
+ <xsl:call-template name="getImageURL">
13579
+ <xsl:with-param name="src" select="$coverimage_src"/>
13580
+ </xsl:call-template>
13581
+ </xsl:variable>
13582
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
13583
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
13584
+ </xsl:if>
13585
+ </xsl:otherwise>
13586
+ </xsl:choose>
13587
+ </xsl:for-each>
13588
+ </fo:block>
13589
+ </fo:block-container>
13590
+ </xsl:template>
13591
+
13592
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
13593
+ <xsl:param name="src"/>
13594
+ <xsl:choose>
13595
+ <xsl:when test="starts-with($src, 'data:image')">
13596
+ <xsl:value-of select="$src"/>
13597
+ </xsl:when>
13598
+ <xsl:otherwise>
13599
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13600
+ </xsl:otherwise>
13601
+ </xsl:choose>
13602
+ </xsl:template>
13603
+
13604
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
13605
+ <xsl:choose>
13606
+ <xsl:when test="*[local-name() = 'svg']">
13607
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
13608
+ </xsl:when>
13609
+ <xsl:otherwise>
13610
+ <xsl:variable name="svg_content" select="document(@src)"/>
13611
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
13612
+ <xsl:apply-templates select="." mode="svg_update"/>
13613
+ </xsl:for-each>
13614
+ </xsl:otherwise>
13615
+ </xsl:choose>
13616
+ </xsl:template>
13617
+
13618
+ <!-- END: insert cover page image -->
13619
+
13165
13620
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
13166
13621
  <xsl:param name="number"/>
13167
13622
  <xsl:param name="first"/>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.2.9".freeze
3
+ VERSION = "0.2.12".freeze
4
4
  end
5
5
  end
6
6
 
@@ -28,10 +28,10 @@ Gem::Specification.new do |spec|
28
28
  || f.match(%r{Rakefile|bin/rspec})
29
29
  end
30
30
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
31
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
31
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
32
32
 
33
33
  spec.add_dependency "japanese_calendar", "~> 0"
34
- spec.add_dependency "metanorma-iso", "~> 2.7.3"
34
+ spec.add_dependency "metanorma-iso", "~> 2.8.0"
35
35
  spec.add_dependency "pubid"
36
36
 
37
37
  spec.add_development_dependency "debug"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: japanese_calendar
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.7.3
33
+ version: 2.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.7.3
40
+ version: 2.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pubid
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -313,7 +313,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
313
313
  requirements:
314
314
  - - ">="
315
315
  - !ruby/object:Gem::Version
316
- version: 2.7.0
316
+ version: 3.1.0
317
317
  required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  requirements:
319
319
  - - ">="