metanorma-jis 0.3.0 → 0.3.2

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: 1aab80a7925f249d9da43542593dcb44fbf35c6e444e47b43c2d409f6b5e6337
4
- data.tar.gz: 0f25e20b71e7410dca4bdbc7f7484cea9926fd198d480a52a5213e19194af60b
3
+ metadata.gz: 1705b0a1189c3766e1a185447e7ca92fa6c55ceebcb394f12d51782dbbe98a6e
4
+ data.tar.gz: 9e549d8aaba6c21294d6314c980e79de90bd92f9172cf29f056199a5af1f135b
5
5
  SHA512:
6
- metadata.gz: a3e77efa2a97c6faf8f6419d9d73d77b99da0682f668df17113516c75d7b8d33625ec56274a5996d576d8dffdf6816df2699ab9c080fcce06ee9be30e89c5fcc
7
- data.tar.gz: cfc8462eb1314e15cd7c163d4f767c61a1b84631c1159851110398e559722e9dbadb743f3920c6255f868656c6573bab0748e0dcb9b2c9bd2cd479355c44ab93
6
+ metadata.gz: ef60ef6cce41c377a25975953d216a707b6621923b9d88a4202535b59a1bc7e9de8a6548be68718c51fb5df05c5e91a3f432b171f67f8e1112f3d42ddcd00cb3
7
+ data.tar.gz: 1adc24ff72b309f1ccea730e3a047fc89d9678e489ec8f3d62c1213a26513babe1890a67a571fa33b4c804426f91fffdee28661a89a40025434ed02b41ecab72
@@ -229,6 +229,46 @@ h6:hover > a.anchor,
229
229
  .inline-header:hover > a.anchor {
230
230
  visibility: visible; }
231
231
 
232
+ /* collapsible snippets: collapsible before hidable */
233
+ .hidable {
234
+ max-height: 0;
235
+ overflow: hidden;
236
+ transition: max-height 0.2s ease-out; }
237
+
238
+ .collapsible {
239
+ background-color: #777;
240
+ color: white;
241
+ cursor: pointer;
242
+ padding: 12px 0;
243
+ margin: 0;
244
+ width: 100%;
245
+ border: none;
246
+ text-align: left;
247
+ outline: none;
248
+ font-size: 15px; }
249
+
250
+ .active, .collapsible:hover {
251
+ background-color: #555; }
252
+
253
+ .collapsible:after {
254
+ content: '\25bc';
255
+ color: white;
256
+ font-weight: bold;
257
+ float: right;
258
+ margin-left: 12px;
259
+ margin-right: 12px; }
260
+
261
+ .active:after {
262
+ content: "\25b2"; }
263
+
264
+ /* collapsible: */
265
+ .collapsible + .hidable {
266
+ margin-top: 0; }
267
+
268
+ .collapsible:not(.active) + .hidable {
269
+ overflow: hidden;
270
+ padding: 0; }
271
+
232
272
  #standard-band {
233
273
  background-color: #0AC442; }
234
274
 
@@ -229,6 +229,46 @@ h6:hover > a.anchor,
229
229
  .inline-header:hover > a.anchor {
230
230
  visibility: visible; }
231
231
 
232
+ /* collapsible snippets: collapsible before hidable */
233
+ .hidable {
234
+ max-height: 0;
235
+ overflow: hidden;
236
+ transition: max-height 0.2s ease-out; }
237
+
238
+ .collapsible {
239
+ background-color: #777;
240
+ color: white;
241
+ cursor: pointer;
242
+ padding: 12px 0;
243
+ margin: 0;
244
+ width: 100%;
245
+ border: none;
246
+ text-align: left;
247
+ outline: none;
248
+ font-size: 15px; }
249
+
250
+ .active, .collapsible:hover {
251
+ background-color: #555; }
252
+
253
+ .collapsible:after {
254
+ content: '\25bc';
255
+ color: white;
256
+ font-weight: bold;
257
+ float: right;
258
+ margin-left: 12px;
259
+ margin-right: 12px; }
260
+
261
+ .active:after {
262
+ content: "\25b2"; }
263
+
264
+ /* collapsible: */
265
+ .collapsible + .hidable {
266
+ margin-top: 0; }
267
+
268
+ .collapsible:not(.active) + .hidable {
269
+ overflow: hidden;
270
+ padding: 0; }
271
+
232
272
  #standard-band {
233
273
  background-color: #0AC442; }
234
274
 
@@ -6,6 +6,9 @@ commentary_page: Comm.
6
6
  JIS: 日本工業規格
7
7
  permission_footer: Duplication, reprinting, etc. without permission is prohibited by copyright law.
8
8
  chairperson: chairperson
9
+ membership_table: Membership Table
10
+ full_name: Full Name
11
+ affiliation: Affiliation
9
12
  doctype_dict:
10
13
  international-standard: International standard
11
14
  japanese-industrial-standard: International standard
@@ -11,6 +11,9 @@ JIS: 日本工業規格
11
11
  draft_label: 案
12
12
  white-paper: 白紙
13
13
  chairperson: 委員会長
14
+ membership_table: 構成表
15
+ full_name: 氏名
16
+ affiliation: 所属
14
17
  doctype_dict:
15
18
  international-standard: 日本産業規格
16
19
  japanese-industrial-standard: 日本産業規格
@@ -185,6 +185,11 @@
185
185
  <xsl:apply-templates mode="update_xml_step1"/>
186
186
  </xsl:variable>
187
187
  <!-- DEBUG: updated_xml_step1=<xsl:copy-of select="$updated_xml_step1"/> -->
188
+ <!-- <xsl:message>start redirect</xsl:message>
189
+ <redirect:write file="update_xml_step1.xml">
190
+ <xsl:copy-of select="$updated_xml_step1"/>
191
+ </redirect:write>
192
+ <xsl:message>end redirect</xsl:message> -->
188
193
 
189
194
  <xsl:variable name="updated_xml_step2_">
190
195
  <xsl:apply-templates select="xalan:nodeset($updated_xml_step1)" mode="update_xml_step2"/>
@@ -246,87 +251,99 @@
246
251
  <!-- Contents and preface pages -->
247
252
  <!-- ========================== -->
248
253
 
249
- <fo:page-sequence master-reference="document_toc" initial-page-number="1" force-page-count="no-force">
254
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'clause' and @type = 'contributors')]">
255
+ <xsl:sort select="@displayorder" data-type="number"/>
250
256
 
251
- <xsl:call-template name="insertHeaderFooter">
252
- <xsl:with-param name="docidentifier" select="$docidentifier"/>
253
- <xsl:with-param name="copyrightText" select="$copyrightText"/>
254
- <xsl:with-param name="section">preface</xsl:with-param>
255
- <xsl:with-param name="section_title">
256
- <fo:inline font-family="IPAexGothic">
257
- <xsl:text> </xsl:text>
258
- <xsl:call-template name="getLocalizedString">
259
- <xsl:with-param name="key">table_of_contents</xsl:with-param>
260
- </xsl:call-template>
261
- </fo:inline>
262
- </xsl:with-param>
263
- </xsl:call-template>
264
-
265
- <fo:flow flow-name="xsl-region-body">
257
+ <xsl:choose>
258
+ <xsl:when test="local-name() = 'clause' and @type = 'toc'">
259
+ <fo:page-sequence master-reference="document_toc" force-page-count="no-force">
266
260
 
267
- <xsl:if test="$debug = 'true'">
268
- <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
269
- DEBUG
270
- contents=<xsl:copy-of select="$contents"/>
271
- <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
272
- </xsl:if>
261
+ <xsl:if test="position() = 1">
262
+ <xsl:attribute name="initial-page-number">1</xsl:attribute>
263
+ </xsl:if>
273
264
 
274
- <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() = 'clause'][@type = 'toc']">
275
- <xsl:with-param name="num" select="$num"/>
276
- </xsl:apply-templates>
265
+ <xsl:call-template name="insertHeaderFooter">
266
+ <xsl:with-param name="docidentifier" select="$docidentifier"/>
267
+ <xsl:with-param name="copyrightText" select="$copyrightText"/>
268
+ <xsl:with-param name="section">preface</xsl:with-param>
269
+ <xsl:with-param name="section_title">
270
+ <fo:inline font-family="IPAexGothic">
271
+ <xsl:text> </xsl:text>
272
+ <xsl:call-template name="getLocalizedString">
273
+ <xsl:with-param name="key">table_of_contents</xsl:with-param>
274
+ </xsl:call-template>
275
+ </fo:inline>
276
+ </xsl:with-param>
277
+ </xsl:call-template>
277
278
 
278
- <xsl:if test="not(/*/*[local-name()='preface']/*[local-name() = 'clause'][@type = 'toc'])">
279
- <fo:block><!-- prevent fop error for empty document --></fo:block>
280
- </xsl:if>
279
+ <fo:flow flow-name="xsl-region-body">
281
280
 
282
- </fo:flow>
281
+ <!-- <xsl:if test="$debug = 'true'">
282
+ <redirect:write file="contents_.xml">
283
+ <xsl:copy-of select="$contents"/>
284
+ </redirect:write>
285
+ </xsl:if> -->
283
286
 
284
- </fo:page-sequence>
287
+ <xsl:apply-templates select=".">
288
+ <xsl:with-param name="num" select="$num"/>
289
+ </xsl:apply-templates>
285
290
 
286
- <xsl:variable name="structured_xml_preface">
291
+ <!-- <xsl:if test="not(/*/*[local-name()='preface']/*[local-name() = 'clause'][@type = 'toc'])">
292
+ <fo:block> --><!-- prevent fop error for empty document --><!-- </fo:block>
293
+ </xsl:if> -->
287
294
 
288
- <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() = 'foreword']" mode="linear_xml"/>
295
+ </fo:flow>
289
296
 
290
- </xsl:variable>
297
+ </fo:page-sequence>
298
+ </xsl:when><!-- end ToC -->
299
+ <xsl:otherwise>
300
+ <xsl:variable name="structured_xml_preface">
301
+ <xsl:apply-templates select="." mode="linear_xml"/>
302
+ </xsl:variable>
291
303
 
292
- <!-- structured_xml_preface=<xsl:copy-of select="$structured_xml_preface"/> -->
304
+ <xsl:variable name="paged_xml_preface_">
305
+ <xsl:call-template name="makePagedXML">
306
+ <xsl:with-param name="structured_xml" select="$structured_xml_preface"/>
307
+ </xsl:call-template>
308
+ </xsl:variable>
309
+ <xsl:variable name="paged_xml_preface" select="xalan:nodeset($paged_xml_preface_)"/>
293
310
 
294
- <xsl:variable name="paged_xml_preface_">
295
- <xsl:call-template name="makePagedXML">
296
- <xsl:with-param name="structured_xml" select="$structured_xml_preface"/>
297
- </xsl:call-template>
298
- </xsl:variable>
299
- <xsl:variable name="paged_xml_preface" select="xalan:nodeset($paged_xml_preface_)"/>
311
+ <xsl:if test="$paged_xml_preface/*[local-name()='page'] and count($paged_xml_preface/*[local-name()='page']/*) != 0">
312
+ <!-- Preface pages -->
313
+ <fo:page-sequence master-reference="document_preface" force-page-count="no-force">
300
314
 
301
- <xsl:if test="$paged_xml_preface/*[local-name()='page'] and count($paged_xml_preface/*[local-name()='page']/*) != 0">
302
- <!-- Preface pages -->
303
- <fo:page-sequence master-reference="document_preface" force-page-count="no-force">
315
+ <xsl:if test="position() = 1">
316
+ <xsl:attribute name="initial-page-number">1</xsl:attribute>
317
+ </xsl:if>
304
318
 
305
- <fo:static-content flow-name="xsl-footnote-separator">
306
- <fo:block text-align="center" margin-bottom="6pt">
307
- <fo:leader leader-pattern="rule" leader-length="80mm"/>
308
- </fo:block>
309
- </fo:static-content>
319
+ <fo:static-content flow-name="xsl-footnote-separator">
320
+ <fo:block text-align="center" margin-bottom="6pt">
321
+ <fo:leader leader-pattern="rule" leader-length="80mm"/>
322
+ </fo:block>
323
+ </fo:static-content>
310
324
 
311
- <xsl:call-template name="insertHeaderFooter">
312
- <xsl:with-param name="docidentifier" select="$docidentifier"/>
313
- <xsl:with-param name="copyrightText" select="$copyrightText"/>
314
- <xsl:with-param name="section">preface</xsl:with-param>
315
- </xsl:call-template>
325
+ <xsl:call-template name="insertHeaderFooter">
326
+ <xsl:with-param name="docidentifier" select="$docidentifier"/>
327
+ <xsl:with-param name="copyrightText" select="$copyrightText"/>
328
+ <xsl:with-param name="section">preface</xsl:with-param>
329
+ </xsl:call-template>
316
330
 
317
- <fo:flow flow-name="xsl-region-body">
331
+ <fo:flow flow-name="xsl-region-body">
318
332
 
319
- <fo:block>
320
- <xsl:for-each select="$paged_xml_preface/*[local-name()='page']">
321
- <xsl:if test="position() != 1">
322
- <fo:block break-after="page"/>
323
- </xsl:if>
324
- <xsl:apply-templates select="*" mode="page"/>
325
- </xsl:for-each>
326
- </fo:block>
327
- </fo:flow>
328
- </fo:page-sequence> <!-- END Preface pages -->
329
- </xsl:if>
333
+ <fo:block>
334
+ <xsl:for-each select="$paged_xml_preface/*[local-name()='page']">
335
+ <xsl:if test="position() != 1">
336
+ <fo:block break-after="page"/>
337
+ </xsl:if>
338
+ <xsl:apply-templates select="*" mode="page"/>
339
+ </xsl:for-each>
340
+ </fo:block>
341
+ </fo:flow>
342
+ </fo:page-sequence> <!-- END Preface pages -->
343
+ </xsl:if>
344
+ </xsl:otherwise>
345
+ </xsl:choose>
346
+ </xsl:for-each>
330
347
 
331
348
  <!-- Document type rendering -->
332
349
  <fo:page-sequence master-reference="document_preface" force-page-count="no-force">
@@ -400,7 +417,12 @@
400
417
  <xsl:copy-of select="./*"/>
401
418
  </xsl:for-each>
402
419
  </xsl:variable>
403
- <!-- structured_xml=<xsl:copy-of select="$structured_xml" /> -->
420
+
421
+ <!-- <xsl:if test="$debug = 'true'">
422
+ <redirect:write file="structured_xml_.xml">
423
+ <xsl:copy-of select="$structured_xml"/>
424
+ </redirect:write>
425
+ </xsl:if> -->
404
426
 
405
427
  <xsl:variable name="paged_xml">
406
428
  <xsl:call-template name="makePagedXML">
@@ -1102,6 +1124,12 @@
1102
1124
  </xsl:choose>
1103
1125
  </xsl:template>
1104
1126
 
1127
+ <xsl:template match="*[local-name() = 'introduction']">
1128
+ <fo:block id="{@id}">
1129
+ <xsl:apply-templates/>
1130
+ </fo:block>
1131
+ </xsl:template>
1132
+
1105
1133
  <xsl:template match="*[local-name() = 'annex']" priority="2">
1106
1134
  <fo:block id="{@id}">
1107
1135
  </fo:block>
@@ -1399,12 +1427,16 @@
1399
1427
 
1400
1428
  <xsl:template match="jis:p//text()[not(ancestor::jis:strong)] | jis:dt/text()" mode="update_xml_step1">
1401
1429
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new(.), $regex_en, concat($tag_font_en_open,'$1',$tag_font_en_close))"/>
1402
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1403
- <xsl:with-param name="tag_open" select="$tag_font_en_open"/>
1404
- <xsl:with-param name="tag_close" select="$tag_font_en_close"/>
1405
- <xsl:with-param name="text" select="$text_en_"/>
1406
- </xsl:call-template></text></xsl:variable>
1407
- <xsl:copy-of select="xalan:nodeset($text_en)/text/node()"/>
1430
+ <xsl:variable name="text_en">
1431
+ <xsl:element name="text" namespace="{$namespace_full}">
1432
+ <xsl:call-template name="replace_text_tags">
1433
+ <xsl:with-param name="tag_open" select="$tag_font_en_open"/>
1434
+ <xsl:with-param name="tag_close" select="$tag_font_en_close"/>
1435
+ <xsl:with-param name="text" select="$text_en_"/>
1436
+ </xsl:call-template>
1437
+ </xsl:element>
1438
+ </xsl:variable>
1439
+ <xsl:copy-of select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1408
1440
  </xsl:template>
1409
1441
 
1410
1442
  <!-- jis:term/jis:preferred2//text() | -->
@@ -1412,24 +1444,32 @@
1412
1444
  <!-- <name>注記 1</name> to <name>注記<font_en> 1</font_en></name> -->
1413
1445
  <xsl:template match="jis:title/text() | jis:note/jis:name/text() | jis:termnote/jis:name/text() | jis:table/jis:name/text() | jis:figure/jis:name/text() | jis:termexample/jis:name/text() | jis:xref//text() | jis:origin/text()" mode="update_xml_step1">
1414
1446
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new(.), $regex_en, concat($tag_font_en_bold_open,'$1',$tag_font_en_bold_close))"/>
1415
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1416
- <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1417
- <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1418
- <xsl:with-param name="text" select="$text_en_"/>
1419
- </xsl:call-template></text></xsl:variable>
1420
- <xsl:copy-of select="xalan:nodeset($text_en)/text/node()"/>
1447
+ <xsl:variable name="text_en">
1448
+ <xsl:element name="text" namespace="{$namespace_full}">
1449
+ <xsl:call-template name="replace_text_tags">
1450
+ <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1451
+ <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1452
+ <xsl:with-param name="text" select="$text_en_"/>
1453
+ </xsl:call-template>
1454
+ </xsl:element>
1455
+ </xsl:variable>
1456
+ <xsl:copy-of select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1421
1457
  </xsl:template>
1422
1458
 
1423
1459
  <!-- for $contents -->
1424
1460
  <xsl:template match="title/text()">
1425
1461
  <xsl:variable name="regex_en_contents">([^\u00A0\u2002-\u200B\u3000-\u9FFF\uF900-\uFFFF\(\)]{1,})</xsl:variable>
1426
1462
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new(.), $regex_en_contents, concat($tag_font_en_bold_open,'$1',$tag_font_en_bold_close))"/>
1427
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1428
- <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1429
- <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1430
- <xsl:with-param name="text" select="$text_en_"/>
1431
- </xsl:call-template></text></xsl:variable>
1432
- <xsl:apply-templates select="xalan:nodeset($text_en)/text/node()"/>
1463
+ <xsl:variable name="text_en">
1464
+ <xsl:element name="text" namespace="{$namespace_full}">
1465
+ <xsl:call-template name="replace_text_tags">
1466
+ <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1467
+ <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1468
+ <xsl:with-param name="text" select="$text_en_"/>
1469
+ </xsl:call-template>
1470
+ </xsl:element>
1471
+ </xsl:variable>
1472
+ <xsl:apply-templates select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1433
1473
  </xsl:template>
1434
1474
 
1435
1475
  <!-- move example title to the first paragraph -->
@@ -1437,11 +1477,18 @@
1437
1477
  <xsl:copy>
1438
1478
  <xsl:copy-of select="@*"/>
1439
1479
  <xsl:element name="p" namespace="https://www.metanorma.org/ns/jis">
1440
- <xsl:value-of select="substring-after(jis:name/text(), ' — ')"/>
1480
+ <xsl:value-of select="substring-after(jis:name/text()[1], ' — ')"/>
1481
+ <xsl:apply-templates select="jis:name/text()[1]/following-sibling::node()" mode="update_xml_step1"/>
1441
1482
  </xsl:element>
1442
1483
  <xsl:apply-templates mode="update_xml_step1"/>
1443
1484
  </xsl:copy>
1444
1485
  </xsl:template>
1486
+ <xsl:template match="jis:example/jis:name[contains(text(), ' — ')]" mode="update_xml_step1">
1487
+ <xsl:copy>
1488
+ <xsl:copy-of select="@*"/>
1489
+ <xsl:apply-templates select="text()[1]" mode="update_xml_step1"/>
1490
+ </xsl:copy>
1491
+ </xsl:template>
1445
1492
  <xsl:template match="jis:example/jis:name/text()" mode="update_xml_step1">
1446
1493
  <xsl:variable name="example_name">
1447
1494
  <xsl:choose>
@@ -1450,12 +1497,16 @@
1450
1497
  </xsl:choose>
1451
1498
  </xsl:variable>
1452
1499
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new($example_name), $regex_en, concat($tag_font_en_bold_open,'$1',$tag_font_en_bold_close))"/>
1453
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1454
- <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1455
- <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1456
- <xsl:with-param name="text" select="$text_en_"/>
1457
- </xsl:call-template></text></xsl:variable>
1458
- <xsl:copy-of select="xalan:nodeset($text_en)/text/node()"/>
1500
+ <xsl:variable name="text_en">
1501
+ <xsl:element name="text" namespace="{$namespace_full}">
1502
+ <xsl:call-template name="replace_text_tags">
1503
+ <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1504
+ <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1505
+ <xsl:with-param name="text" select="$text_en_"/>
1506
+ </xsl:call-template>
1507
+ </xsl:element>
1508
+ </xsl:variable>
1509
+ <xsl:copy-of select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1459
1510
  </xsl:template>
1460
1511
 
1461
1512
  <xsl:template match="jis:eref//text()" mode="update_xml_step1">
@@ -1463,11 +1514,11 @@
1463
1514
  <xsl:variable name="parts">
1464
1515
  <xsl:choose>
1465
1516
  <xsl:when test="contains(., ':')">
1466
- <xsl:element name="{$element_name_font_en_bold}"><xsl:value-of select="substring-before(., ':')"/></xsl:element>
1467
- <xsl:element name="{$element_name_font_en}">:<xsl:value-of select="substring-after(., ':')"/></xsl:element>
1517
+ <xsl:element name="{$element_name_font_en_bold}" namespace="{$namespace_full}"><xsl:value-of select="substring-before(., ':')"/></xsl:element>
1518
+ <xsl:element name="{$element_name_font_en}" namespace="{$namespace_full}">:<xsl:value-of select="substring-after(., ':')"/></xsl:element>
1468
1519
  </xsl:when>
1469
1520
  <xsl:otherwise>
1470
- <xsl:element name="{$element_name_font_en_bold}"><xsl:value-of select="."/></xsl:element>
1521
+ <xsl:element name="{$element_name_font_en_bold}" namespace="{$namespace_full}"><xsl:value-of select="."/></xsl:element>
1471
1522
  </xsl:otherwise>
1472
1523
  </xsl:choose>
1473
1524
  </xsl:variable>
@@ -1475,12 +1526,16 @@
1475
1526
  <xsl:variable name="tag_open">###<xsl:value-of select="local-name()"/>###</xsl:variable>
1476
1527
  <xsl:variable name="tag_close">###/<xsl:value-of select="local-name()"/>###</xsl:variable>
1477
1528
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new(.), $regex_en, concat($tag_open,'$1',$tag_close))"/>
1478
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1479
- <xsl:with-param name="tag_open" select="$tag_open"/>
1480
- <xsl:with-param name="tag_close" select="$tag_close"/>
1481
- <xsl:with-param name="text" select="$text_en_"/>
1482
- </xsl:call-template></text></xsl:variable>
1483
- <xsl:copy-of select="xalan:nodeset($text_en)/text/node()"/>
1529
+ <xsl:variable name="text_en">
1530
+ <xsl:element name="text" namespace="{$namespace_full}">
1531
+ <xsl:call-template name="replace_text_tags">
1532
+ <xsl:with-param name="tag_open" select="$tag_open"/>
1533
+ <xsl:with-param name="tag_close" select="$tag_close"/>
1534
+ <xsl:with-param name="text" select="$text_en_"/>
1535
+ </xsl:call-template>
1536
+ </xsl:element>
1537
+ </xsl:variable>
1538
+ <xsl:copy-of select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1484
1539
  </xsl:for-each>
1485
1540
  </xsl:template>
1486
1541
 
@@ -1489,12 +1544,16 @@
1489
1544
  </xsl:template>
1490
1545
  <xsl:template match="jis:strong/text()" priority="2" mode="update_xml_step1">
1491
1546
  <xsl:variable name="text_en_" select="java:replaceAll(java:java.lang.String.new(.), $regex_en, concat($tag_font_en_bold_open,'$1',$tag_font_en_bold_close))"/>
1492
- <xsl:variable name="text_en"><text><xsl:call-template name="replace_text_tags">
1493
- <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1494
- <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1495
- <xsl:with-param name="text" select="$text_en_"/>
1496
- </xsl:call-template></text></xsl:variable>
1497
- <xsl:copy-of select="xalan:nodeset($text_en)/text/node()"/>
1547
+ <xsl:variable name="text_en">
1548
+ <xsl:element name="text" namespace="{$namespace_full}">
1549
+ <xsl:call-template name="replace_text_tags">
1550
+ <xsl:with-param name="tag_open" select="$tag_font_en_bold_open"/>
1551
+ <xsl:with-param name="tag_close" select="$tag_font_en_bold_close"/>
1552
+ <xsl:with-param name="text" select="$text_en_"/>
1553
+ </xsl:call-template>
1554
+ </xsl:element>
1555
+ </xsl:variable>
1556
+ <xsl:copy-of select="xalan:nodeset($text_en)/*[local-name() = 'text']/node()"/>
1498
1557
  </xsl:template>
1499
1558
 
1500
1559
  <xsl:template match="*[local-name() = 'font_en_bold'][normalize-space() != '']">
@@ -3429,13 +3488,35 @@
3429
3488
  </xsl:for-each>
3430
3489
  </xsl:element>
3431
3490
 
3432
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
3491
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
3433
3492
 
3434
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
3493
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
3435
3494
 
3436
3495
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
3437
3496
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
3438
3497
 
3498
+ <xsl:template name="insertAnnexAndBibliographyInSeparatePageSequences">
3499
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
3500
+ <xsl:sort select="@displayorder" data-type="number"/>
3501
+ <xsl:choose>
3502
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
3503
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3504
+ <xsl:attribute name="main_page_sequence"/>
3505
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3506
+ </xsl:element>
3507
+ </xsl:when>
3508
+ <xsl:otherwise> <!-- bibliography -->
3509
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
3510
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
3511
+ <xsl:attribute name="main_page_sequence"/>
3512
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
3513
+ </xsl:element>
3514
+ </xsl:element>
3515
+ </xsl:otherwise>
3516
+ </xsl:choose>
3517
+ </xsl:for-each>
3518
+ </xsl:template>
3519
+
3439
3520
  <xsl:template name="insertAnnexInSeparatePageSequences">
3440
3521
  <xsl:for-each select="/*/*[local-name()='annex']">
3441
3522
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -7639,18 +7720,33 @@
7639
7720
 
7640
7721
  <xsl:template match="*[local-name()='localityStack']"/>
7641
7722
 
7723
+ <xsl:variable name="pdfAttachmentsList_">
7724
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7725
+ <attachment filename="{@name}"/>
7726
+ </xsl:for-each>
7727
+ </xsl:variable>
7728
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7729
+
7642
7730
  <xsl:template match="*[local-name()='link']" name="link">
7731
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7732
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7643
7733
  <xsl:variable name="target">
7644
7734
  <xsl:choose>
7645
7735
  <xsl:when test="@updatetype = 'true'">
7646
7736
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7647
7737
  </xsl:when>
7738
+ <!-- link to the PDF attachment -->
7739
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7740
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7741
+ </xsl:when>
7742
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
7743
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
7744
+ </xsl:when>
7648
7745
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7649
- <!-- link to the PDF attachment -->
7650
7746
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7651
7747
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7652
7748
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7653
- </xsl:when>
7749
+ </xsl:when> -->
7654
7750
  <xsl:otherwise>
7655
7751
  <xsl:value-of select="normalize-space(@target)"/>
7656
7752
  </xsl:otherwise>
@@ -12244,6 +12340,19 @@
12244
12340
  <xsl:copy-of select="."/>
12245
12341
  </xsl:template>
12246
12342
 
12343
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12344
+ <xsl:copy>
12345
+ <xsl:copy-of select="@*"/>
12346
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
12347
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12348
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12349
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12350
+ <xsl:value-of select="normalize-space(.)"/>
12351
+ </xsl:if>
12352
+ </xsl:if>
12353
+ </xsl:copy>
12354
+ </xsl:template>
12355
+
12247
12356
  <!-- add @id, mandatory for table auto-layout algorithm -->
12248
12357
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12249
12358
  <xsl:copy>
@@ -13221,11 +13330,13 @@
13221
13330
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13222
13331
  <xsl:choose>
13223
13332
  <xsl:when test="normalize-space() != ''">
13224
- <pdf:embedded-file src="{.}" filename="{@name}"/>
13333
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13334
+ <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
13225
13335
  </xsl:when>
13226
13336
  <xsl:otherwise>
13227
13337
  <!-- _{filename}_attachments -->
13228
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13338
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13339
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13229
13340
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13230
13341
  </xsl:otherwise>
13231
13342
  </xsl:choose>
@@ -73,20 +73,23 @@ module IsoDoc
73
73
  investigative_committee(xml)
74
74
  end
75
75
 
76
+ def extract_role(role, desc)
77
+ <<~XPATH
78
+ //bibdata/contributor[xmlns:role/@type = '#{role}'][xmlns:role/description = '#{desc}' or xmlns:role/description = '#{desc.downcase}']
79
+ XPATH
80
+ end
81
+
76
82
  def investigative_organisation(xml)
77
- xpath = "//bibdata/contributor" \
78
- "[xmlns:role/@type = 'authorizer'][xmlns:role/description = " \
79
- "'investigative organization']/organization/name"
80
- org = xml.at(ns(xpath))
83
+ p = extract_role("authorizer", "Investigative organization")
84
+ org = xml.at(ns("#{p}/organization/name[@language = '#{@lang}']"))
85
+ org ||= xml.at(ns("#{p}/organization/name"))
81
86
  if org then set_encoded(:"investigative-organization", org)
82
87
  else set(:"investigative-organization", get[:publisher])
83
88
  end
84
89
  end
85
90
 
86
91
  def investigative_committee(xml)
87
- xpath = "//bibdata/contributor" \
88
- "[xmlns:role/@type = 'authorizer'][xmlns:role/description = " \
89
- "'investigative committee']"
92
+ xpath = extract_role("authorizer", "Investigative committee")
90
93
  if o = xml.at(ns("#{xpath}/organization/name"))
91
94
  set_encoded(:"investigative-committee", o)
92
95
  elsif p = xml.at(ns("#{xpath}/person"))
@@ -22,7 +22,7 @@ module IsoDoc
22
22
  docxml.at(ns("//annex[@commentary = 'true']")) or return
23
23
  b = docxml.at(ns("//bibliography")) ||
24
24
  docxml.at(ns("//annex[last()]")).after(" ").next
25
- docxml.xpath(ns("//annex[@commentary = 'true']")).reverse.each do |x|
25
+ docxml.xpath(ns("//annex[@commentary = 'true']")).reverse_each do |x|
26
26
  b.next = x.remove
27
27
  end
28
28
  end
@@ -42,17 +42,22 @@ module IsoDoc
42
42
  elem.previous = ret
43
43
  end
44
44
 
45
- def toc_title_insert_pt(docxml)
46
- ins = docxml.at(ns("//preface")) ||
45
+ def make_preface(docxml)
46
+ docxml.at(ns("//preface")) ||
47
47
  docxml.at(ns("//sections | //annex | //bibliography"))
48
48
  &.before("<preface> </preface>")
49
- &.previous_element or return nil
49
+ &.previous_element
50
+ end
51
+
52
+ def toc_title_insert_pt(docxml)
53
+ ins = make_preface(docxml) or return nil
50
54
  ins.children.last.after(" ").next
51
55
  end
52
56
 
53
57
  def preface_rearrange(doc)
54
58
  move_introduction(doc)
55
59
  super
60
+ move_participants(doc)
56
61
  end
57
62
 
58
63
  def move_introduction(doc)
@@ -63,6 +68,45 @@ module IsoDoc
63
68
  dest.children.first.next = source
64
69
  end
65
70
 
71
+ def move_participants(doc)
72
+ p = doc.at(ns("//clause[@type = 'participants']")) or return
73
+ t = participant_table(p) or return
74
+ p.remove
75
+ ins = make_preface(doc) or return nil
76
+ ins.children.first.previous = t
77
+ end
78
+
79
+ def participant_table(clause)
80
+ s = clause.at(ns("./sourcecode")) or return nil
81
+ y = YAML.safe_load(s.children.to_xml(encoding: "UTF-8")) or return nil
82
+ y.is_a?(Array) or return nil
83
+ out1 = <<~OUTPUT
84
+ <clause id='_#{UUIDTools::UUID.random_create}'><title>#{@meta.get[:"investigative-committee"]} #{@i18n.membership_table}</title>
85
+ <table unnumbered='true'>
86
+ <thead>
87
+ <tr><th/><th>#{@i18n.full_name}</th><th>#{@i18n.affiliation}</th></tr>
88
+ </thead>
89
+ <tbody>
90
+ OUTPUT
91
+ out2 = <<~OUTPUT
92
+ </tbody></table></clause>
93
+ OUTPUT
94
+ "#{out1}#{participant_rows(y)}#{out2}"
95
+ end
96
+
97
+ def participant_rows(yaml)
98
+ yaml.map do |y|
99
+ r = y["role"] ? @i18n.l10n("(#{y['role']})") : ""
100
+ n = y["name"]
101
+ if n.is_a?(Hash)
102
+ n =
103
+ if @lang == "ja" then "#{n['surname']} #{n['givenname']}"
104
+ else "#{n['givenname']} #{n['surname']}" end
105
+ end
106
+ "<tr><td>#{r}</rd><td>#{n}</td><td>#{y['affiliation']}</td></tr>"
107
+ end.join("\n")
108
+ end
109
+
66
110
  def middle_title(docxml)
67
111
  s = docxml.at(ns("//sections")) or return
68
112
  elem = s.children.first
@@ -37,7 +37,7 @@ module IsoDoc
37
37
 
38
38
  def ol_depth(node)
39
39
  depth = node.ancestors("ol").size + 1
40
- depth == 1 and return :alphabetic
40
+ depth == 1 and return :alphabet
41
41
  :arabic
42
42
  end
43
43
 
@@ -7,14 +7,18 @@ module IsoDoc
7
7
  word_note_cleanup(docxml)
8
8
  boldface(docxml)
9
9
  super
10
- move_to_inner_cover(docxml)
10
+ end
11
+
12
+ def word_remove_empty_sections(docxml)
13
+ move_to_inner_cover(docxml) # preempt by populating WordSection1
14
+ super
11
15
  end
12
16
 
13
17
  def move_to_inner_cover(docxml)
14
18
  source = docxml.at("//div[@type = 'inner-cover-note']")
15
19
  dest = docxml.at("//div[@id = 'boilerplate-inner-cover-note']")
16
20
  source && dest and dest.replace(source.remove)
17
- source = docxml.at("//div[@type = 'contributors']")
21
+ source = docxml.at("//div[@type = 'participants']")
18
22
  dest = docxml.at("//div[@id = 'boilerplate-contributors']")
19
23
  source && dest and dest.replace(source.remove)
20
24
  docxml
@@ -82,6 +82,37 @@ module Metanorma
82
82
  ::Metanorma::Standoc::Converter.instance_method(:ol_cleanup).bind(self)
83
83
  .call(doc)
84
84
  end
85
+
86
+ def biblio_reorder(xmldoc)
87
+ xmldoc.xpath("//references[@normative = 'true']").each do |r|
88
+ biblio_reorder1(r)
89
+ end
90
+ end
91
+
92
+ def pub_class_prep(bib)
93
+ iso = bib.at("#{PUBLISHER}[abbreviation = 'ISO']") ||
94
+ bib.at("#{PUBLISHER}[name = 'International Organization " \
95
+ "for Standardization']")
96
+ iec = bib.at("#{PUBLISHER}[abbreviation = 'IEC']") ||
97
+ bib.at("#{PUBLISHER}[name = 'International " \
98
+ "Electrotechnical Commission']")
99
+ jis = bib.at("#{PUBLISHER}[abbreviation = 'JIS']") ||
100
+ bib.at("#{PUBLISHER}[name = '#{pub_hash['ja']}']") ||
101
+ bib.at("#{PUBLISHER}[name = '#{pub_hash['en']}']")
102
+ [iso, iec, jis]
103
+ end
104
+
105
+ def pub_class(bib)
106
+ iso, iec, jis = pub_class_prep(bib)
107
+ jis && iec && iso and return 2
108
+ jis && iec and return 2
109
+ jis && iso and return 3
110
+ jis and return 1
111
+ iso && iec and return 4
112
+ iso and return 4
113
+ iec and return 5
114
+ 6
115
+ end
85
116
  end
86
117
  end
87
118
  end
@@ -14,12 +14,12 @@ module Metanorma
14
14
  def metadata_author(node, xml)
15
15
  org_contributor(node, xml,
16
16
  { source: ["publisher", "pub"], role: "author",
17
- default: JIS_HASH })
17
+ default: pub_hash })
18
18
  personal_author(node, xml)
19
19
  end
20
20
 
21
21
  def metadata_publisher(node, xml)
22
- [{ source: ["publisher", "pub"], role: "publisher", default: JIS_HASH },
22
+ [{ source: ["publisher", "pub"], role: "publisher", default: pub_hash },
23
23
  { role: "authorizer",
24
24
  source: ["investigative-organization"],
25
25
  desc: "Investigative organization" },
@@ -32,8 +32,9 @@ module Metanorma
32
32
 
33
33
  LANGS = %w(ja en).freeze
34
34
 
35
- JIS_HASH =
36
- { "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }.freeze
35
+ def pub_hash
36
+ { "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }
37
+ end
37
38
 
38
39
  def org_organization(node, xml, org)
39
40
  organization(xml, { name: org[:name], abbr: org[:abbr] }.compact,
@@ -92,9 +93,9 @@ module Metanorma
92
93
 
93
94
  def multiling_noko_value(value, tag, xml)
94
95
  if value.is_a?(Hash)
95
- xml.send tag do |t|
96
- value.each do |k, v|
97
- t.variant v, language: k
96
+ value.each do |k, v|
97
+ xml.send tag, language: k do |x|
98
+ x << v
98
99
  end
99
100
  end
100
101
  elsif value.is_a?(Array)
@@ -119,7 +120,7 @@ module Metanorma
119
120
 
120
121
  def copyright_parse(node)
121
122
  opt = { source: ["copyright-holder", "publisher", "pub"],
122
- role: "publisher", default: JIS_HASH }
123
+ role: "publisher", default: pub_hash }
123
124
  ret = org_attrs_parse(node, opt)
124
125
  ret.empty? and ret = [{ name: "-" }]
125
126
  ret
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.3.0".freeze
3
+ VERSION = "0.3.2".freeze
4
4
  end
5
5
  end
6
6
 
@@ -6,14 +6,15 @@ module Relaton
6
6
  class Parse < ::Relaton::Render::Iso::Parse
7
7
  def simple_or_host_xml2hash(doc, host)
8
8
  ret = super
9
- ret.merge(home_standard: home_standard(doc, ret[:publisher_raw] || ret[:author_raw]))
9
+ ret.merge(home_standard: home_standard(doc, ret[:publisher_raw] ||
10
+ ret[:author_raw]))
10
11
  end
11
12
 
12
13
  def home_standard(_doc, pubs)
13
14
  pubs&.any? do |r|
14
15
  ["International Organization for Standardization", "ISO",
15
16
  "International Electrotechnical Commission", "IEC",
16
- "一般財団法人 日本規格協会", "JIS"]
17
+ "一般財団法人 日本規格協会", "Japanese Industrial Standards"]
17
18
  .include?(r[:nonpersonal])
18
19
  end
19
20
  end
@@ -47,4 +47,5 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "timecop", "~> 0.9"
48
48
  spec.add_development_dependency "vcr", "~> 6.1.0"
49
49
  spec.add_development_dependency "webmock"
50
+ spec.add_development_dependency "xml-c14n"
50
51
  end
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.3.0
4
+ version: 0.3.2
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-07-22 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: japanese_calendar
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: xml-c14n
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
237
251
  description: |
238
252
  metanorma-jis lets you write JIS standards in AsciiDoc syntax.
239
253