metanorma-jis 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -459,7 +459,7 @@
459
459
 
460
460
  <fo:flow flow-name="xsl-region-body">
461
461
 
462
- <xsl:if test="position() = 1">
462
+ <!-- <xsl:if test="position() = 1">
463
463
  <fo:table table-layout="fixed" width="100%">
464
464
  <fo:table-column column-width="proportional-column-width(35)"/>
465
465
  <fo:table-column column-width="proportional-column-width(97)"/>
@@ -467,14 +467,14 @@
467
467
  <fo:table-column column-width="proportional-column-width(12)"/>
468
468
  <fo:table-body>
469
469
  <fo:table-row>
470
- <fo:table-cell><fo:block/></fo:table-cell>
470
+ <fo:table-cell><fo:block></fo:block></fo:table-cell>
471
471
  <fo:table-cell font-family="IPAexGothic" font-size="14pt" text-align="center">
472
472
  <fo:block>
473
473
  <xsl:call-template name="getLocalizedString">
474
474
  <xsl:with-param name="key">doctype_dict.<xsl:value-of select="$doctype"/></xsl:with-param>
475
475
  </xsl:call-template>
476
476
  </fo:block>
477
- </fo:table-cell>
477
+ </fo:table-cell>
478
478
  <fo:table-cell text-align="right">
479
479
  <fo:block font-family="Arial" font-size="16pt">
480
480
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($docnumber), '^(JIS)(.*)', '$1')"/>
@@ -489,29 +489,29 @@
489
489
  </fo:inline>
490
490
  </fo:block>
491
491
  </fo:table-cell>
492
-
492
+
493
493
  </fo:table-row>
494
494
  </fo:table-body>
495
495
  </fo:table>
496
-
496
+
497
497
  <fo:block font-family="IPAexGothic" font-size="19pt" text-align="center" margin-top="12mm" margin-bottom="4mm"><xsl:value-of select="$title_ja"/></fo:block>
498
498
  <fo:block font-family="Arial" font-size="13pt" text-align="center" margin-bottom="10mm"><xsl:value-of select="$title_en"/></fo:block>
499
-
500
- </xsl:if>
499
+
500
+ </xsl:if> -->
501
501
 
502
502
  <!-- Annex Commentary first page -->
503
- <xsl:if test="$isCommentary = 'true'">
503
+ <!-- <xsl:if test="$isCommentary = 'true'"> -->
504
504
 
505
505
  <!-- Example: JIS Z 8301:2019 -->
506
- <fo:block font-family="IPAexGothic" font-size="15pt" text-align="center">
506
+ <!-- <fo:block font-family="IPAexGothic" font-size="15pt" text-align="center">
507
507
  <fo:inline font-family="Arial">JIS <xsl:value-of select="$docidentifier_number"/></fo:inline>
508
508
  <fo:inline baseline-shift="10%"><fo:inline font-size="10pt">:</fo:inline>
509
509
  <fo:inline font-family="Times New Roman" font-size="10pt"><xsl:value-of select="$docidentifier_year"/></fo:inline></fo:inline>
510
- </fo:block>
510
+ </fo:block> -->
511
511
 
512
512
  <!-- title -->
513
- <fo:block role="H1" font-family="IPAexGothic" font-size="16pt" text-align="center" margin-top="6mm"><xsl:value-of select="$title_ja"/></fo:block>
514
- </xsl:if>
513
+ <!-- <fo:block role="H1" font-family="IPAexGothic" font-size="16pt" text-align="center" margin-top="6mm"><xsl:value-of select="$title_ja"/></fo:block> -->
514
+ <!-- </xsl:if> -->
515
515
 
516
516
  <xsl:apply-templates select="*" mode="page"/>
517
517
 
@@ -704,6 +704,129 @@
704
704
  </fo:page-sequence>
705
705
  </xsl:template> <!-- insertInnerCoverPage -->
706
706
 
707
+ <xsl:template match="jis:p[@class = 'JapaneseIndustrialStandard']" priority="4">
708
+ <fo:table table-layout="fixed" width="100%">
709
+ <fo:table-column column-width="proportional-column-width(36)"/>
710
+ <fo:table-column column-width="proportional-column-width(92)"/>
711
+ <fo:table-column column-width="proportional-column-width(36)"/>
712
+ <fo:table-body>
713
+ <fo:table-row>
714
+ <fo:table-cell>
715
+ <fo:block> </fo:block>
716
+ </fo:table-cell>
717
+ <fo:table-cell font-family="IPAexGothic" font-size="14pt" text-align="center">
718
+ <fo:block><xsl:apply-templates/></fo:block>
719
+ </fo:table-cell>
720
+ <fo:table-cell padding-left="5mm">
721
+ <fo:block font-family="Arial" font-size="16pt">
722
+ <xsl:apply-templates select="jis:span[@class = 'JIS']">
723
+ <xsl:with-param name="process">true</xsl:with-param>
724
+ </xsl:apply-templates>
725
+ </fo:block>
726
+ </fo:table-cell>
727
+ </fo:table-row>
728
+ </fo:table-body>
729
+ </fo:table>
730
+ </xsl:template>
731
+
732
+ <xsl:template match="jis:p[@class = 'StandardNumber']" priority="4">
733
+ <fo:table table-layout="fixed" width="100%">
734
+ <fo:table-column column-width="proportional-column-width(36)"/>
735
+ <fo:table-column column-width="proportional-column-width(92)"/>
736
+ <fo:table-column column-width="proportional-column-width(36)"/>
737
+ <fo:table-body>
738
+ <fo:table-row>
739
+ <fo:table-cell>
740
+ <fo:block> </fo:block>
741
+ </fo:table-cell>
742
+ <fo:table-cell>
743
+ <fo:block> </fo:block>
744
+ </fo:table-cell>
745
+ <fo:table-cell>
746
+ <fo:block>
747
+ <xsl:apply-templates/>
748
+ </fo:block>
749
+ </fo:table-cell>
750
+ </fo:table-row>
751
+ </fo:table-body>
752
+ </fo:table>
753
+ </xsl:template>
754
+
755
+ <xsl:template match="jis:p[@class = 'StandardNumber']//text()[not(ancestor::jis:span)]" priority="4">
756
+ <fo:inline font-family="Arial" font-size="16pt">
757
+ <xsl:choose>
758
+ <xsl:when test="contains(., ':')">
759
+ <xsl:value-of select="substring-before(., ':')"/>
760
+ <fo:inline baseline-shift="10%" font-size="10pt" font-family="IPAexMincho">:</fo:inline>
761
+ <xsl:value-of select="substring-after(., ':')"/>
762
+ </xsl:when>
763
+ <xsl:otherwise>
764
+ <xsl:value-of select="."/>
765
+ </xsl:otherwise>
766
+ </xsl:choose>
767
+ </fo:inline>
768
+ </xsl:template>
769
+
770
+ <xsl:template match="jis:p[@class = 'StandardNumber']/jis:span[@class = 'EffectiveYear']" priority="4">
771
+ <fo:inline font-size="10pt" baseline-shift="10%">
772
+ <fo:inline font-family="Times New Roman"><xsl:apply-templates/></fo:inline>
773
+ </fo:inline>
774
+ </xsl:template>
775
+
776
+ <xsl:template match="jis:p[@class = 'JapaneseIndustrialStandard']/jis:tab" priority="4"/>
777
+ <!-- <fo:inline role="SKIP" padding-right="0mm">&#x200B;</fo:inline>
778
+ </xsl:template> -->
779
+ <xsl:template match="jis:p[@class = 'JapaneseIndustrialStandard']/jis:span[@class = 'JIS']" priority="4">
780
+ <xsl:param name="process">false</xsl:param>
781
+ <xsl:if test="$process = 'true'">
782
+ <fo:inline font-size="16pt" font-family="Arial"><xsl:apply-templates/></fo:inline>
783
+ </xsl:if>
784
+ </xsl:template>
785
+
786
+ <xsl:template match="jis:p[@class = 'zzSTDTitle1']" priority="4">
787
+ <fo:block font-family="IPAexGothic" font-size="19pt" text-align="center" margin-top="12mm" margin-bottom="4mm">
788
+ <xsl:apply-templates/>
789
+ </fo:block>
790
+ </xsl:template>
791
+
792
+ <xsl:template match="jis:p[@class = 'zzSTDTitle2']" priority="4">
793
+ <fo:block font-family="Arial" font-size="13pt" text-align="center" margin-bottom="10mm">
794
+ <xsl:apply-templates/>
795
+ </fo:block>
796
+ </xsl:template>
797
+
798
+ <!-- for commentary annex -->
799
+ <xsl:template match="jis:p[@class = 'CommentaryStandardNumber']" priority="4">
800
+ <fo:block font-family="IPAexGothic" font-size="15pt" text-align="center">
801
+ <xsl:apply-templates/>
802
+ </fo:block>
803
+ </xsl:template>
804
+
805
+ <xsl:template match="jis:p[@class = 'CommentaryStandardNumber']//text()[not(ancestor::jis:span)]" priority="4">
806
+ <fo:inline font-family="Arial">
807
+ <xsl:choose>
808
+ <xsl:when test="contains(., ':')">
809
+ <xsl:value-of select="substring-before(., ':')"/>
810
+ <fo:inline baseline-shift="10%" font-size="10pt" font-family="IPAexMincho">:</fo:inline>
811
+ <xsl:value-of select="substring-after(., ':')"/>
812
+ </xsl:when>
813
+ <xsl:otherwise>
814
+ <xsl:value-of select="."/>
815
+ </xsl:otherwise>
816
+ </xsl:choose>
817
+ </fo:inline>
818
+ </xsl:template>
819
+
820
+ <xsl:template match="jis:p[@class = 'CommentaryStandardNumber']/jis:span[@class = 'CommentaryEffectiveYear']" priority="4">
821
+ <fo:inline baseline-shift="10%" font-family="Times New Roman" font-size="10pt"><xsl:apply-templates/></fo:inline>
822
+ </xsl:template>
823
+
824
+ <xsl:template match="jis:p[@class = 'CommentaryStandardName']" priority="4">
825
+ <fo:block role="H1" font-family="IPAexGothic" font-size="16pt" text-align="center" margin-top="6mm">
826
+ <xsl:apply-templates/>
827
+ </fo:block>
828
+ </xsl:template>
829
+
707
830
  <!-- ============================= -->
708
831
  <!-- CONTENTS -->
709
832
  <!-- ============================= -->
@@ -842,7 +965,7 @@
842
965
  <xsl:choose>
843
966
  <xsl:when test="@type = 'section-title'">18pt</xsl:when>
844
967
  <xsl:when test="@ancestor = 'foreword' and $level = '1'">14pt</xsl:when>
845
- <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[1][local-name() = 'annex' and @commentary = 'true']">16pt</xsl:when>
968
+ <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[local-name() = 'annex'][1][@commentary = 'true']">16pt</xsl:when>
846
969
  <xsl:when test="@ancestor = 'annex' and $level = '1'">14pt</xsl:when>
847
970
  <!-- <xsl:when test="@ancestor = 'foreword' and $level &gt;= '2'">12pt</xsl:when>
848
971
  <xsl:when test=". = 'Executive summary'">18pt</xsl:when>
@@ -879,7 +1002,7 @@
879
1002
  <xsl:variable name="margin-top">
880
1003
  <xsl:choose>
881
1004
  <xsl:when test="@ancestor = 'foreword' and $level = 1">9mm</xsl:when>
882
- <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[1][local-name() = 'annex' and @commentary = 'true']">1mm</xsl:when>
1005
+ <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[local-name() = 'annex'][1][@commentary = 'true']">1mm</xsl:when>
883
1006
  <xsl:when test="$level = 1">6.5mm</xsl:when>
884
1007
  <xsl:when test="@ancestor = 'foreword' and $level = 2">0mm</xsl:when>
885
1008
  <xsl:when test="@ancestor = 'annex' and $level = 2">4.5mm</xsl:when>
@@ -900,7 +1023,7 @@
900
1023
  <xsl:variable name="margin-bottom">
901
1024
  <xsl:choose>
902
1025
  <xsl:when test="@ancestor = 'foreword' and $level = 1">9mm</xsl:when>
903
- <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[1][local-name() = 'annex' and @commentary = 'true']">7mm</xsl:when>
1026
+ <xsl:when test="@ancestor = 'annex' and $level = '1' and preceding-sibling::*[local-name() = 'annex'][1][@commentary = 'true']">7mm</xsl:when>
904
1027
  <xsl:when test="$level = 1 and following-sibling::jis:clause">8pt</xsl:when>
905
1028
  <xsl:when test="$level = 1">12pt</xsl:when>
906
1029
  <xsl:when test="$level = 2 and following-sibling::jis:clause">8pt</xsl:when>
@@ -1167,6 +1290,46 @@
1167
1290
  </xsl:if>
1168
1291
  </xsl:template>
1169
1292
 
1293
+ <xsl:template match="*[local-name() = 'span'][@class = 'surname' or @class = 'givenname' or @class = 'JIS' or @class = 'EffectiveYear' or @class = 'CommentaryEffectiveYear']" mode="update_xml_step1" priority="2">
1294
+ <xsl:copy>
1295
+ <xsl:apply-templates select="@* | node()" mode="update_xml_step1"/>
1296
+ </xsl:copy>
1297
+ </xsl:template>
1298
+
1299
+ <xsl:template match="jis:clause[@type = 'contributors']//jis:table//jis:span[@class = 'surname']/text()[string-length() &lt; 3]" priority="2">
1300
+ <xsl:choose>
1301
+ <xsl:when test="string-length() = 1">
1302
+ <xsl:value-of select="concat(.,'  ')"/>
1303
+ </xsl:when>
1304
+ <xsl:when test="string-length() = 2">
1305
+ <xsl:value-of select="concat(substring(.,1,1), ' ', substring(., 2))"/>
1306
+ </xsl:when>
1307
+ </xsl:choose>
1308
+ <xsl:if test="../following-sibling::node()[1][self::jis:span and @class = 'surname']"> <!-- if no space between surname and given name -->
1309
+ <xsl:text> </xsl:text>
1310
+ </xsl:if>
1311
+ </xsl:template>
1312
+
1313
+ <xsl:template match="jis:clause[@type = 'contributors']//jis:table//jis:span[@class = 'givenname']/text()[string-length() &lt; 3]" priority="2">
1314
+ <xsl:choose>
1315
+ <xsl:when test="string-length() = 1">
1316
+ <xsl:value-of select="concat('  ', .)"/>
1317
+ </xsl:when>
1318
+ <xsl:when test="string-length() = 2">
1319
+ <xsl:value-of select="concat(substring(.,1,1), ' ', substring(., 2))"/>
1320
+ </xsl:when>
1321
+ <xsl:otherwise>
1322
+ <xsl:value-of select="."/>
1323
+ </xsl:otherwise>
1324
+ </xsl:choose>
1325
+ </xsl:template>
1326
+
1327
+ <!-- space between surname and givenname replace by 'ideographic space' -->
1328
+ <!-- and following-sibling::node()[1][self::jis:span and @class = 'givenname'] -->
1329
+ <xsl:template match="jis:clause[@type = 'contributors']//jis:table//node()[preceding-sibling::node()[1][self::jis:span and @class = 'surname']][. = ' ']" priority="2">
1330
+ <xsl:text> </xsl:text>
1331
+ </xsl:template>
1332
+
1170
1333
  <xsl:template name="makePagedXML">
1171
1334
  <xsl:param name="structured_xml"/>
1172
1335
  <xsl:choose>
@@ -1330,7 +1493,10 @@
1330
1493
 
1331
1494
  <xsl:template match="*[local-name() = 'font_en'][normalize-space() != '']">
1332
1495
  <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']"><xsl:value-of select="$zero_width_space"/></xsl:if>
1333
- <fo:inline font-family="Times New Roman">
1496
+ <fo:inline>
1497
+ <xsl:if test="not(ancestor::jis:p[@class = 'zzSTDTitle2']) and not(ancestor::jis:span[@class = 'JIS'])">
1498
+ <xsl:attribute name="font-family">Times New Roman</xsl:attribute>
1499
+ </xsl:if>
1334
1500
  <xsl:if test="ancestor::*[local-name() = 'preferred']">
1335
1501
  <xsl:attribute name="font-weight">normal</xsl:attribute>
1336
1502
  </xsl:if>
@@ -1571,19 +1737,32 @@
1571
1737
  <xsl:variable name="titles_">
1572
1738
 
1573
1739
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1574
- <title-toc lang="en">
1575
-
1576
- </title-toc>
1577
- <title-toc lang="fr">
1740
+ <!-- <title-toc lang="en">
1741
+ <xsl:if test="$namespace = 'csd' or $namespace = 'ieee' or $namespace = 'iho' or $namespace = 'mpfd' or $namespace = 'ogc' or $namespace = 'unece-rec'">
1742
+ <xsl:text>Contents</xsl:text>
1743
+ </xsl:if>
1744
+ <xsl:if test="$namespace = 'csa' or $namespace = 'm3d' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper'">
1745
+ <xsl:text>Table of Contents</xsl:text>
1746
+ </xsl:if>
1747
+ <xsl:if test="$namespace = 'gb'">
1748
+ <xsl:text>Table of contents</xsl:text>
1749
+ </xsl:if>
1750
+ </title-toc> -->
1751
+ <title-toc lang="en">Table of contents</title-toc>
1752
+ <!-- <title-toc lang="fr">
1578
1753
  <xsl:text>Sommaire</xsl:text>
1579
- </title-toc>
1580
- <title-toc lang="zh">
1581
-
1754
+ </title-toc> -->
1755
+ <!-- <title-toc lang="zh">
1756
+ <xsl:choose>
1757
+ <xsl:when test="$namespace = 'gb'">
1758
+ <xsl:text>目次</xsl:text>
1759
+ </xsl:when>
1760
+ <xsl:otherwise>
1582
1761
  <xsl:text>Contents</xsl:text>
1583
-
1584
- </title-toc>
1585
-
1586
- <title-descriptors lang="en">Descriptors</title-descriptors>
1762
+ </xsl:otherwise>
1763
+ </xsl:choose>
1764
+ </title-toc> -->
1765
+ <title-toc lang="zh">目次</title-toc>
1587
1766
 
1588
1767
  <title-part lang="en">
1589
1768
 
@@ -1599,20 +1778,6 @@
1599
1778
  <title-subpart lang="en">Sub-part #</title-subpart>
1600
1779
  <title-subpart lang="fr">Partie de sub #</title-subpart>
1601
1780
 
1602
- <title-list-tables lang="en">List of Tables</title-list-tables>
1603
-
1604
- <title-list-figures lang="en">List of Figures</title-list-figures>
1605
-
1606
- <title-table-figures lang="en">Table of Figures</title-table-figures>
1607
-
1608
- <title-list-recommendations lang="en">List of Recommendations</title-list-recommendations>
1609
-
1610
- <title-summary lang="en">Summary</title-summary>
1611
-
1612
- <title-continued lang="ru">(продолжение)</title-continued>
1613
- <title-continued lang="en">(continued)</title-continued>
1614
- <title-continued lang="fr">(continué)</title-continued>
1615
-
1616
1781
  </xsl:variable>
1617
1782
  <xsl:variable name="titles" select="xalan:nodeset($titles_)"/>
1618
1783
 
@@ -1620,8 +1785,8 @@
1620
1785
  <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
1621
1786
  <xsl:value-of select="$toc_table_title"/>
1622
1787
  <xsl:if test="normalize-space($toc_table_title) = ''">
1623
- <xsl:call-template name="getTitle">
1624
- <xsl:with-param name="name" select="'title-list-tables'"/>
1788
+ <xsl:call-template name="getLocalizedString">
1789
+ <xsl:with-param name="key">toc_tables</xsl:with-param>
1625
1790
  </xsl:call-template>
1626
1791
  </xsl:if>
1627
1792
  </xsl:variable>
@@ -1630,8 +1795,8 @@
1630
1795
  <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
1631
1796
  <xsl:value-of select="$toc_figure_title"/>
1632
1797
  <xsl:if test="normalize-space($toc_figure_title) = ''">
1633
- <xsl:call-template name="getTitle">
1634
- <xsl:with-param name="name" select="'title-list-figures'"/>
1798
+ <xsl:call-template name="getLocalizedString">
1799
+ <xsl:with-param name="key">toc_figures</xsl:with-param>
1635
1800
  </xsl:call-template>
1636
1801
  </xsl:if>
1637
1802
  </xsl:variable>
@@ -1640,8 +1805,8 @@
1640
1805
  <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
1641
1806
  <xsl:value-of select="$toc_requirement_title"/>
1642
1807
  <xsl:if test="normalize-space($toc_requirement_title) = ''">
1643
- <xsl:call-template name="getTitle">
1644
- <xsl:with-param name="name" select="'title-list-recommendations'"/>
1808
+ <xsl:call-template name="getLocalizedString">
1809
+ <xsl:with-param name="key">toc_recommendations</xsl:with-param>
1645
1810
  </xsl:call-template>
1646
1811
  </xsl:if>
1647
1812
  </xsl:variable>
@@ -5324,6 +5489,9 @@
5324
5489
  <!-- END Definition List -->
5325
5490
  <!-- ===================== -->
5326
5491
 
5492
+ <!-- default: ignore title in sections/p -->
5493
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]" priority="3"/>
5494
+
5327
5495
  <!-- ========================= -->
5328
5496
  <!-- Rich text formatting -->
5329
5497
  <!-- ========================= -->
@@ -5401,7 +5569,7 @@
5401
5569
  <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
5402
5570
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
5403
5571
  <xsl:choose>
5404
- <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
5572
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), $regex_url_start, '$2') != ''">
5405
5573
  <!-- url -->
5406
5574
  <xsl:call-template name="add-zero-spaces-link-java"/>
5407
5575
  </xsl:when>
@@ -5867,10 +6035,13 @@
5867
6035
  </xsl:choose>
5868
6036
  </xsl:variable>
5869
6037
 
6038
+ <!-- replace sequence #x200B to one &#x200B -->
6039
+ <xsl:variable name="text10" select="java:replaceAll(java:java.lang.String.new($text9), '\u200b{2,}', '​')"/>
6040
+
5870
6041
  <!-- replace sequence #x200B and space TO space -->
5871
- <xsl:variable name="text10" select="java:replaceAll(java:java.lang.String.new($text9), '\u200b ', ' ')"/>
6042
+ <xsl:variable name="text11" select="java:replaceAll(java:java.lang.String.new($text10), '\u200b ', ' ')"/>
5872
6043
 
5873
- <xsl:value-of select="$text10"/>
6044
+ <xsl:value-of select="$text11"/>
5874
6045
  </xsl:template>
5875
6046
 
5876
6047
  <xsl:template name="add-zero-spaces-link-java">
@@ -5880,8 +6051,12 @@
5880
6051
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
5881
6052
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
5882
6053
  <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
6054
+
6055
+ <!-- replace sequence #x200B to one &#x200B -->
6056
+ <xsl:variable name="url2" select="java:replaceAll(java:java.lang.String.new($url), '\u200b{2,}', '​')"/>
6057
+
5883
6058
  <!-- remove zero-width space at the end -->
5884
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
6059
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url2), '​$', '')"/>
5885
6060
  </xsl:template>
5886
6061
 
5887
6062
  <!-- add zero space after dash character (for table's entries) -->
@@ -7176,12 +7351,12 @@
7176
7351
  <xsl:variable name="num"><xsl:number/></xsl:variable>
7177
7352
  <xsl:choose>
7178
7353
  <xsl:when test="$num = 1"> <!-- display first NOTE's paragraph in the same line with label NOTE -->
7179
- <fo:inline xsl:use-attribute-sets="note-p-style">
7354
+ <fo:inline xsl:use-attribute-sets="note-p-style" role="SKIP">
7180
7355
  <xsl:apply-templates/>
7181
7356
  </fo:inline>
7182
7357
  </xsl:when>
7183
7358
  <xsl:otherwise>
7184
- <fo:block xsl:use-attribute-sets="note-p-style">
7359
+ <fo:block xsl:use-attribute-sets="note-p-style" role="SKIP">
7185
7360
  <xsl:apply-templates/>
7186
7361
  </fo:block>
7187
7362
  </xsl:otherwise>
@@ -7396,25 +7571,45 @@
7396
7571
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7397
7572
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
7398
7573
 
7399
- <xsl:variable name="img_src">
7400
- <xsl:choose>
7401
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
7402
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
7403
- </xsl:choose>
7404
- </xsl:variable>
7574
+ <xsl:if test="@width != '' and @width != 'auto'">
7575
+ <xsl:attribute name="width">
7576
+ <xsl:value-of select="@width"/>
7577
+ </xsl:attribute>
7578
+ </xsl:if>
7405
7579
 
7406
- <xsl:variable name="image_width_effective">
7580
+ <xsl:if test="@height != '' and @height != 'auto'">
7581
+ <xsl:attribute name="height">
7582
+ <xsl:value-of select="@height"/>
7583
+ </xsl:attribute>
7584
+ </xsl:if>
7407
7585
 
7408
- <xsl:value-of select="$width_effective"/>
7586
+ <xsl:choose>
7587
+ <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
7588
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
7589
+ </xsl:when>
7590
+ <xsl:otherwise>
7409
7591
 
7410
- </xsl:variable>
7592
+ <xsl:variable name="img_src">
7593
+ <xsl:choose>
7594
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
7595
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
7596
+ </xsl:choose>
7597
+ </xsl:variable>
7411
7598
 
7412
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7413
- <xsl:if test="number($scale) &lt; 100">
7599
+ <xsl:variable name="image_width_effective">
7414
7600
 
7415
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7601
+ <xsl:value-of select="$width_effective"/>
7416
7602
 
7417
- </xsl:if>
7603
+ </xsl:variable>
7604
+
7605
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7606
+ <xsl:if test="number($scale) &lt; 100">
7607
+
7608
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7609
+
7610
+ </xsl:if>
7611
+ </xsl:otherwise>
7612
+ </xsl:choose>
7418
7613
 
7419
7614
  </xsl:if>
7420
7615
 
@@ -11076,7 +11271,7 @@
11076
11271
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
11077
11272
  <xsl:apply-templates mode="update_xml_step1"/>
11078
11273
  </xsl:template>
11079
- <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
11274
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]/*[local-name() = 'span'][@class] | *[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
11080
11275
  <xsl:copy>
11081
11276
  <xsl:copy-of select="@*"/>
11082
11277
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -135,7 +135,7 @@ module IsoDoc
135
135
  end
136
136
 
137
137
  def annex1(elem)
138
- elem["commentary"] == "true" and return
138
+ elem["commentary"] == "true" and return commentary(elem)
139
139
  lbl = @xrefs.anchor(elem["id"], :label)
140
140
  if t = elem.at(ns("./title"))
141
141
  t.children = "<strong>#{to_xml(t.children)}</strong>"
@@ -157,6 +157,21 @@ module IsoDoc
157
157
  end
158
158
  end
159
159
 
160
+ def commentary(elem)
161
+ t = elem.elements.first
162
+ commentary_title_hdr(t)
163
+ middle_title_main(t, "CommentaryStandardName")
164
+ end
165
+
166
+ def commentary_title_hdr(elem)
167
+ ret = <<~COMMENTARY
168
+ <p class="CommentaryStandardNumber">JIS #{@meta.get[:docnumber_undated]}
169
+ COMMENTARY
170
+ yr = @meta.get[:docyear] and
171
+ ret += ": <span class='CommentaryEffectiveYear'>#{yr}</span>"
172
+ elem.previous = ret
173
+ end
174
+
160
175
  def display_order(docxml)
161
176
  i = 0
162
177
  i = display_order_xpath(docxml, "//preface/*", i)
@@ -202,6 +217,60 @@ module IsoDoc
202
217
  dest.children.first.next = source
203
218
  end
204
219
 
220
+ def middle_title(docxml)
221
+ s = docxml.at(ns("//sections")) or return
222
+ elem = s.children.first
223
+ middle_title_hdr(elem)
224
+ middle_title_main(elem, "zzSTDTitle1")
225
+ middle_subtitle_main(elem)
226
+ # middle_title_amd(s.children.first)
227
+ end
228
+
229
+ def middle_title_hdr(out)
230
+ ret = "<p class='JapaneseIndustrialStandard'>#{@i18n.jis}"
231
+ @meta.get[:unpublished] and ret += @i18n.l10n("(#{@i18n.draft_label})")
232
+ ret += ("<tab/>" * 7)
233
+ ret += "<span class='JIS'>JIS</span></p>"
234
+ ret += "<p class='StandardNumber'><tab/>#{@meta.get[:docnumber_undated]}"
235
+ if yr = @meta.get[:docyear]
236
+ ret += ": <span class='EffectiveYear'>#{yr}</span>"
237
+ end
238
+ ret += "</p><p class='IDT'/>"
239
+ out.previous = ret
240
+ end
241
+
242
+ def middle_title_main(out, style)
243
+ t = @meta.get[:doctitlemain]
244
+ (t && !t.empty?) or return
245
+ ret = "<p class='#{style}'>#{@meta.get[:doctitleintro]}"
246
+ ret += " &#x2014; " if @meta.get[:doctitleintro] && t
247
+ ret += t
248
+ ret += " &#x2014; " if t && @meta.get[:doctitlepart]
249
+ ret += "</p>"
250
+ if a = @meta.get[:doctitlepart]
251
+ ret += "<p class='zzSTDTitle1'>"
252
+ b = @meta.get[:doctitlepartlabel] and ret += "#{b}: "
253
+ ret += "<br/><strong>#{a}</strong></p>"
254
+ end
255
+ out.previous = ret
256
+ end
257
+
258
+ def middle_subtitle_main(out)
259
+ t = @meta.get[:docsubtitlemain]
260
+ (t && !t.empty?) or return
261
+ ret = "<p class='zzSTDTitle2'>#{@meta.get[:docsubtitleintro]}"
262
+ ret += " &#x2014; " if @meta.get[:docsubtitleintro] && t
263
+ ret += @meta.get[:docsubtitlemain]
264
+ ret += " &#x2014; " if t && @meta.get[:docsubtitlepart]
265
+ ret += "</p>"
266
+ if a = @meta.get[:docsubtitlepart]
267
+ ret += "<p class='zzSTDTitle2'>"
268
+ b = @meta.get[:docsubtitlepartlabel] and ret += "#{b}: "
269
+ ret += "<br/><strong>#{a}</strong></p>"
270
+ end
271
+ out.previous = ret
272
+ end
273
+
205
274
  include Init
206
275
  end
207
276
  end