metanorma-ieee 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,12 +69,16 @@
69
69
  </xsl:choose>
70
70
  </xsl:variable>
71
71
 
72
+ <!-- https://github.com/metanorma/metanorma-csa/issues/329 -->
73
+ <!-- if stage >= 60 -->
74
+ <xsl:variable name="stage_published" select="normalize-space((//mn:metanorma)[1]/mn:metanorma-extension/mn:semantic-metadata/mn:stage-published)"/>
75
+
72
76
  <xsl:variable name="trial_use" select="(//mn:metanorma)[1]/mn:bibdata/mn:ext/mn:trial-use[normalize-space(@language) = '']"/>
73
77
 
74
78
  <xsl:variable name="current_template">
75
79
  <xsl:choose>
76
80
  <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and $stage = 'draft'">draft</xsl:when>
77
- <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and ($stage = 'published' or $stage = 'approved')">standard</xsl:when>
81
+ <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and ($stage = 'published' or $stage = 'approved' or $stage_published = 'true')">standard</xsl:when>
78
82
  <xsl:when test="$doctype = 'whitepaper' and $subdoctype = 'icap'">icap-whitepaper</xsl:when>
79
83
  <xsl:when test="$doctype = 'whitepaper' and $subdoctype = 'industry-connection-report'">industry-connection-report</xsl:when>
80
84
  <xsl:otherwise><xsl:value-of select="$doctype"/></xsl:otherwise>
@@ -414,9 +418,11 @@
414
418
  </xsl:choose>
415
419
  </xsl:variable>
416
420
 
417
- <xsl:variable name="society" select="/mn:metanorma/mn:bibdata/mn:ext/mn:editorialgroup/mn:society"/>
421
+ <!-- <xsl:variable name="society" select="/mn:metanorma/mn:bibdata/mn:ext/mn:editorialgroup/mn:society"/> -->
422
+ <xsl:variable name="society" select="/mn:metanorma/mn:bibdata/mn:contributor[mn:role[@type = 'authorizer']/mn:description = 'committee']/mn:organization/mn:subdivision[@type = 'Society']/mn:name"/>
418
423
 
419
- <xsl:variable name="committee" select="/mn:metanorma/mn:bibdata/mn:ext/mn:editorialgroup/mn:committee"/>
424
+ <!-- <xsl:variable name="committee" select="/mn:metanorma/mn:bibdata/mn:ext/mn:editorialgroup/mn:committee"/> -->
425
+ <xsl:variable name="committee" select="/mn:metanorma/mn:bibdata/mn:contributor[mn:role[@type = 'authorizer']/mn:description = 'committee']/mn:organization/mn:subdivision[@type = 'Committee']/mn:name"/>
420
426
 
421
427
  <xsl:variable name="approved_by">IEEE SA Standards Board</xsl:variable>
422
428
  <xsl:variable name="approved_date">
@@ -1262,7 +1268,7 @@
1262
1268
 
1263
1269
  </xsl:when> <!-- $stage = 'draft' -->
1264
1270
 
1265
- <xsl:when test="$stage = 'published' or $stage = 'approved'">
1271
+ <xsl:when test="$stage = 'published' or $stage = 'approved' or $stage_published = 'true'">
1266
1272
 
1267
1273
  <xsl:variable name="provisional-distance-between-starts">10</xsl:variable>
1268
1274
 
@@ -1414,7 +1420,7 @@
1414
1420
  </xsl:when>
1415
1421
  <xsl:otherwise>
1416
1422
  <fo:block xsl:use-attribute-sets="toc-title-style">
1417
- <xsl:if test="($current_template = 'standard' or $current_template = 'draft') and ($stage = 'published' or $stage = 'approved')">
1423
+ <xsl:if test="($current_template = 'standard' or $current_template = 'draft') and ($stage = 'published' or $stage = 'approved' or $stage_published = 'true')">
1418
1424
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1419
1425
  </xsl:if>
1420
1426
  <!-- Contents -->
@@ -1426,13 +1432,17 @@
1426
1432
  </xsl:template>
1427
1433
 
1428
1434
  <xsl:template match="mn:boilerplate/mn:copyright-statement//mn:p" priority="2">
1429
- <fo:block margin-top="6pt" margin-bottom="6pt" text-align="justify">
1435
+ <fo:block xsl:use-attribute-sets="copyright-statement-p-style">
1436
+ <xsl:call-template name="refine_copyright-statement-p-style"/>
1437
+
1430
1438
  <xsl:apply-templates/>
1431
1439
  </fo:block>
1432
1440
  </xsl:template>
1433
1441
 
1434
1442
  <xsl:template match="mn:boilerplate/mn:license-statement//mn:p" priority="2">
1435
- <fo:block margin-top="6pt" margin-bottom="6pt" text-align="justify">
1443
+ <fo:block xsl:use-attribute-sets="license-statement-p-style">
1444
+ <xsl:call-template name="refine_license-statement-p-style"/>
1445
+
1436
1446
  <xsl:apply-templates/>
1437
1447
  </fo:block>
1438
1448
  </xsl:template>
@@ -1531,8 +1541,10 @@
1531
1541
 
1532
1542
  <xsl:variable name="officemembers_count" select="count($officemembers/officemember)"/>
1533
1543
 
1534
- <xsl:variable name="mod" select="$officemembers_count mod 3"/>
1535
- <xsl:variable name="floor" select="floor($officemembers_count div 3)"/>
1544
+ <xsl:variable name="cols">3</xsl:variable>
1545
+
1546
+ <xsl:variable name="mod" select="$officemembers_count mod $cols"/>
1547
+ <xsl:variable name="floor" select="floor($officemembers_count div $cols)"/>
1536
1548
 
1537
1549
  <xsl:variable name="max">
1538
1550
  <xsl:choose>
@@ -1541,11 +1553,41 @@
1541
1553
  </xsl:choose>
1542
1554
  </xsl:variable>
1543
1555
 
1544
- <!-- <fo:block>officemembers_count=<xsl:value-of select="$officemembers_count"/></fo:block>
1545
- <fo:block>mod=<xsl:value-of select="$mod"/></fo:block>
1556
+ <!-- <fo:block>DEBUG officemembers_count=<xsl:value-of select="$officemembers_count"/></fo:block> -->
1557
+ <!-- <fo:block>mod=<xsl:value-of select="$mod"/></fo:block>
1546
1558
  <fo:block>floor=<xsl:value-of select="$floor"/></fo:block>
1547
1559
  <fo:block>max=<xsl:value-of select="$max"/></fo:block> -->
1548
1560
 
1561
+ <!-- From https://github.com/metanorma/metanorma-ieee/issues/533#issuecomment-3178212854:
1562
+ Algorithm:
1563
+ 3 cases: 0 extra, all balanced; 1 extra, place in middle, 2 extra, place on both sides.
1564
+
1565
+ The number of rows in each column is "ceil(names/cols)".
1566
+ The number of extras is calculated as "names mod cols"
1567
+ In the 1 extra case, place an additional line break after the "floor(names/cols)"-th item.
1568
+ In the 2 extra case, place an additional line break after the "ceil(names/cols) + floor(names/cols)"-th item
1569
+ -->
1570
+
1571
+ <xsl:variable name="number_in_each_column" select="ceiling($officemembers_count div $cols)"/>
1572
+ <!-- <fo:block>DEBUG number_in_each_column=<xsl:value-of select="$number_in_each_column"/></fo:block> -->
1573
+ <xsl:variable name="number_extras" select="$officemembers_count mod $cols"/>
1574
+ <!-- <fo:block>DEBUG number_extras=<xsl:value-of select="$number_extras"/></fo:block> -->
1575
+
1576
+ <xsl:variable name="officemembers_updated_">
1577
+ <xsl:for-each select="$officemembers/officemember">
1578
+ <xsl:copy-of select="."/>
1579
+ <xsl:choose>
1580
+ <xsl:when test="$number_extras = 1 and position() = $floor">
1581
+ <officemember/>
1582
+ </xsl:when>
1583
+ <xsl:when test="$number_extras = 2 and position() = ($number_in_each_column + $floor)">
1584
+ <officemember/>
1585
+ </xsl:when>
1586
+ </xsl:choose>
1587
+ </xsl:for-each>
1588
+ </xsl:variable>
1589
+ <xsl:variable name="officemembers_updated" select="xalan:nodeset($officemembers_updated_)"/>
1590
+
1549
1591
  <fo:block font-size="9pt">
1550
1592
  <fo:block> </fo:block>
1551
1593
  <fo:table width="100%" table-layout="fixed">
@@ -1553,7 +1595,7 @@
1553
1595
  <fo:table-column column-width="proportional-column-width(55)"/>
1554
1596
  <fo:table-column column-width="proportional-column-width(42)"/>
1555
1597
  <fo:table-body>
1556
- <xsl:for-each select="$officemembers/officemember[position() &lt;= $max]">
1598
+ <xsl:for-each select="$officemembers_updated/officemember[position() &lt;= $number_in_each_column]"> <!-- $max -->
1557
1599
  <fo:table-row>
1558
1600
  <fo:table-cell padding-right="3mm">
1559
1601
  <fo:block>
@@ -1562,12 +1604,12 @@
1562
1604
  </fo:table-cell>
1563
1605
  <fo:table-cell padding-right="3mm">
1564
1606
  <fo:block>
1565
- <xsl:apply-templates select="following-sibling::*[number($max)]/node()"/>
1607
+ <xsl:apply-templates select="following-sibling::*[number($number_in_each_column)]/node()"/> <!-- $max -->
1566
1608
  </fo:block>
1567
1609
  </fo:table-cell>
1568
1610
  <fo:table-cell>
1569
1611
  <fo:block>
1570
- <xsl:apply-templates select="following-sibling::*[number($max) * 2]/node()"/>
1612
+ <xsl:apply-templates select="following-sibling::*[number($number_in_each_column) * 2]/node()"/> <!-- $max -->
1571
1613
  </fo:block>
1572
1614
  </fo:table-cell>
1573
1615
  </fo:table-row>
@@ -1617,9 +1659,7 @@
1617
1659
 
1618
1660
  <xsl:variable name="attributes_">
1619
1661
  <attributes>
1620
- <xsl:if test="@align = 'center' and ancestor::mn:clause[@id = 'boilerplate-participants' or normalize-space(mn:fmt-title) = 'Participants'] and following-sibling::*[1][self::mn:p and @align = 'center']">
1621
- <xsl:attribute name="space-after">0</xsl:attribute>
1622
- </xsl:if>
1662
+
1623
1663
  <xsl:call-template name="setTextAlignment">
1624
1664
  <xsl:with-param name="default">justify</xsl:with-param>
1625
1665
  </xsl:call-template>
@@ -1635,6 +1675,11 @@
1635
1675
  <xsl:attribute name="font-family">Times New Roman</xsl:attribute>
1636
1676
  <xsl:attribute name="space-after">6pt</xsl:attribute>
1637
1677
  </xsl:if>
1678
+
1679
+ <xsl:if test="@align = 'center' and ancestor::mn:clause[@id = 'boilerplate-participants' or normalize-space(mn:fmt-title) = 'Participants'] and following-sibling::*[1][self::mn:p and @align = 'center']">
1680
+ <xsl:attribute name="space-after">0</xsl:attribute>
1681
+ </xsl:if>
1682
+
1638
1683
  </attributes>
1639
1684
  </xsl:variable>
1640
1685
 
@@ -1645,7 +1690,7 @@
1645
1690
  <xsl:for-each select="$attributes/attributes/@*">
1646
1691
  <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
1647
1692
  </xsl:for-each>
1648
-
1693
+ <!-- <fo:block>debug current_template=<xsl:value-of select="$current_template"/></fo:block> -->
1649
1694
  <xsl:apply-templates/>
1650
1695
  </fo:block>
1651
1696
  </xsl:otherwise>
@@ -3010,7 +3055,7 @@
3010
3055
  </xsl:template>
3011
3056
 
3012
3057
  <xsl:template name="insertFootnoteSeparator">
3013
- <fo:static-content flow-name="xsl-footnote-separator">
3058
+ <fo:static-content flow-name="xsl-footnote-separator" role="artifact">
3014
3059
  <fo:block>
3015
3060
  <fo:leader leader-pattern="rule" rule-thickness="0.5pt" leader-length="35%">
3016
3061
  <xsl:if test="$current_template = 'whitepaper' or $current_template= 'icap-whitepaper' or $current_template = 'industry-connection-report'">
@@ -5485,13 +5530,26 @@
5485
5530
  <xsl:attribute-set name="copyright-statement-style">
5486
5531
  </xsl:attribute-set> <!-- copyright-statement-style -->
5487
5532
 
5533
+ <xsl:template name="refine_copyright-statement-style">
5534
+ </xsl:template>
5535
+
5488
5536
  <xsl:attribute-set name="copyright-statement-title-style">
5489
5537
  </xsl:attribute-set> <!-- copyright-statement-title-style -->
5490
5538
 
5539
+ <xsl:template name="refine_copyright-statement-title-style">
5540
+ </xsl:template>
5541
+
5491
5542
  <xsl:attribute-set name="copyright-statement-p-style">
5492
5543
  </xsl:attribute-set> <!-- copyright-statement-p-style -->
5493
5544
 
5494
- <xsl:attribute-set name="license-statement-style">
5545
+ <xsl:template name="refine_copyright-statement-p-style">
5546
+ <xsl:attribute name="margin-top">6pt</xsl:attribute>
5547
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
5548
+ <xsl:attribute name="text-align">justify</xsl:attribute>
5549
+
5550
+ </xsl:template>
5551
+
5552
+ <xsl:attribute-set name="license-statement-style">
5495
5553
  </xsl:attribute-set> <!-- license-statement-style -->
5496
5554
 
5497
5555
  <xsl:attribute-set name="license-statement-title-style">
@@ -5499,8 +5557,15 @@
5499
5557
  </xsl:attribute-set> <!-- license-statement-title-style -->
5500
5558
 
5501
5559
  <xsl:attribute-set name="license-statement-p-style">
5560
+ <xsl:attribute name="margin-top">6pt</xsl:attribute>
5561
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
5562
+ <xsl:attribute name="text-align">justify</xsl:attribute>
5502
5563
  </xsl:attribute-set> <!-- license-statement-p-style -->
5503
5564
 
5565
+ <xsl:template name="refine_license-statement-p-style">
5566
+
5567
+ </xsl:template>
5568
+
5504
5569
  <xsl:attribute-set name="legal-statement-style">
5505
5570
  </xsl:attribute-set> <!-- legal-statement-style -->
5506
5571
 
@@ -5528,6 +5593,8 @@
5528
5593
  <!-- ================================= -->
5529
5594
  <xsl:template match="mn:copyright-statement">
5530
5595
  <fo:block xsl:use-attribute-sets="copyright-statement-style" role="SKIP">
5596
+ <xsl:call-template name="refine_copyright-statement-style"/>
5597
+
5531
5598
  <xsl:apply-templates/>
5532
5599
  </fo:block>
5533
5600
  </xsl:template> <!-- copyright-statement -->
@@ -6636,7 +6703,7 @@
6636
6703
  </xsl:otherwise>
6637
6704
  </xsl:choose>
6638
6705
  </xsl:variable>
6639
- <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color' or $key = 'baseline-shift'">
6706
+ <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color' or $key = 'baseline-shift' or $key = 'line-height' ">
6640
6707
  <style name="{$key}"><xsl:value-of select="$value"/></style>
6641
6708
  </xsl:if>
6642
6709
  <xsl:if test="$key = 'text-indent'">
@@ -14253,13 +14320,31 @@
14253
14320
  <!-- skip here, see the template 'fmt-review-start' -->
14254
14321
  </xsl:when>
14255
14322
  <xsl:otherwise>
14256
- <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
14257
- <fo:inline id="{@id}" font-size="1pt"><xsl:if test="preceding-sibling::node()[self::mn:fmt-annotation-start][@source = $bookmark_id] and following-sibling::node()[self::mn:fmt-annotation-end][@source = $bookmark_id]"><xsl:attribute name="line-height">0.1</xsl:attribute></xsl:if><xsl:value-of select="$hair_space"/></fo:inline>
14258
- <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
14259
- <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
14323
+ <xsl:choose>
14324
+ <xsl:when test="parent::mn:example or parent::mn:termexample or parent::mn:note or parent::mn:termnote">
14325
+ <fo:block font-size="1pt" line-height="0.1">
14326
+ <xsl:call-template name="fo_inline_bookmark">
14327
+ <xsl:with-param name="bookmark_id" select="$bookmark_id"/>
14328
+ </xsl:call-template>
14329
+ </fo:block>
14330
+ </xsl:when>
14331
+ <xsl:otherwise>
14332
+ <xsl:call-template name="fo_inline_bookmark">
14333
+ <xsl:with-param name="bookmark_id" select="$bookmark_id"/>
14334
+ </xsl:call-template>
14335
+ </xsl:otherwise>
14336
+ </xsl:choose>
14260
14337
  </xsl:otherwise>
14261
14338
  </xsl:choose>
14262
14339
  </xsl:template>
14340
+
14341
+ <xsl:template name="fo_inline_bookmark">
14342
+ <xsl:param name="bookmark_id"/>
14343
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
14344
+ <fo:inline id="{@id}" font-size="1pt"><xsl:if test="preceding-sibling::node()[self::mn:fmt-annotation-start][@source = $bookmark_id] and following-sibling::node()[self::mn:fmt-annotation-end][@source = $bookmark_id]"><xsl:attribute name="line-height">0.1</xsl:attribute></xsl:if><xsl:value-of select="$hair_space"/></fo:inline>
14345
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
14346
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
14347
+ </xsl:template>
14263
14348
  <!-- =================== -->
14264
14349
  <!-- End of Index processing -->
14265
14350
  <!-- =================== -->
@@ -16145,11 +16230,35 @@
16145
16230
 
16146
16231
  <xsl:template match="mn:svgmap"/>
16147
16232
 
16233
+ <xsl:template match="mn:name[following-sibling::*[1][self::mn:fmt-name]]"/>
16234
+
16148
16235
  <!-- for correct rendering combining chars, added in mode="update_xml_step2" -->
16149
16236
  <xsl:template match="*[local-name() = 'lang_none']">
16150
16237
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
16151
16238
  </xsl:template>
16152
16239
 
16240
+ <xsl:template name="addTagElementT">
16241
+ <xsl:variable name="title_">
16242
+ <xsl:apply-templates select="mn:fmt-title"/>
16243
+ </xsl:variable>
16244
+ <xsl:variable name="title__">
16245
+ <xsl:for-each select="xalan:nodeset($title_)/*/node()">
16246
+ <xsl:choose>
16247
+ <xsl:when test="self::text()"><xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text> </xsl:text></xsl:when>
16248
+ <xsl:otherwise><xsl:text> </xsl:text><xsl:copy-of select="."/><xsl:text> </xsl:text></xsl:otherwise>
16249
+ </xsl:choose>
16250
+ </xsl:for-each>
16251
+ </xsl:variable>
16252
+ <xsl:variable name="title" select="normalize-space($title__)"/>
16253
+ <xsl:if test="$title != ''">
16254
+ <xsl:attribute name="fox:title">
16255
+ <xsl:if test="ancestor::mn:sections">
16256
+ <xsl:text>Section </xsl:text>
16257
+ </xsl:if>
16258
+ <xsl:value-of select="$title"/></xsl:attribute>
16259
+ </xsl:if>
16260
+ </xsl:template>
16261
+
16153
16262
  <xsl:template name="replaceChar">
16154
16263
  <xsl:param name="text"/>
16155
16264
  <xsl:param name="replace"/>
@@ -16430,7 +16539,8 @@
16430
16539
  <xsl:for-each select="(//mn:metanorma)[1]/mn:bibdata">
16431
16540
  <rdf:Seq>
16432
16541
  <rdf:li>
16433
- <xsl:value-of select="mn:ext/mn:editorialgroup/mn:committee"/>
16542
+ <!-- <xsl:value-of select="mn:ext/mn:editorialgroup/mn:committee"/> -->
16543
+ <xsl:value-of select="mn:contributor[mn:role[@type = 'authorizer']/mn:description = 'committee']/mn:organization/mn:subdivision[@type = 'Committee']/mn:name"/>
16434
16544
  </rdf:li>
16435
16545
  </rdf:Seq>
16436
16546
 
@@ -16915,6 +17025,13 @@
16915
17025
  <xsl:with-param name="default" select="$text_align_default"/>
16916
17026
  </xsl:call-template>
16917
17027
  <xsl:call-template name="setKeepAttributes"/>
17028
+ <xsl:if test="node()[1][self::mn:span][contains(@style, 'line-height')]">
17029
+ <xsl:variable name="styles">
17030
+ <xsl:apply-templates select="*[1]"/>
17031
+ </xsl:variable>
17032
+ <!-- move attribute line-height from inline to block -->
17033
+ <xsl:attribute name="line-height"><xsl:value-of select="xalan:nodeset($styles)//*/@line-height"/></xsl:attribute>
17034
+ </xsl:if>
16918
17035
  </xsl:template>
16919
17036
 
16920
17037
  <xsl:template name="setKeepAttributes">
@@ -16940,34 +17057,41 @@
16940
17057
  <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage{$suffix}_{$name}_{$number}_{generate-id()}">
16941
17058
  <fo:block>
16942
17059
  <xsl:for-each select="/mn:metanorma/mn:metanorma-extension/mn:presentation-metadata[mn:name = $name][1]/mn:value/mn:image[$num]">
16943
- <xsl:choose>
16944
- <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
16945
- <fo:instream-foreign-object fox:alt-text="Image Front">
16946
- <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
16947
- <xsl:call-template name="getSVG"/>
16948
- </fo:instream-foreign-object>
16949
- </xsl:when>
16950
- <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
16951
- <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
16952
- </xsl:when>
16953
- <xsl:otherwise> <!-- bitmap image -->
16954
- <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
16955
- <xsl:if test="$coverimage_src != ''">
16956
- <xsl:variable name="coverpage">
16957
- <xsl:call-template name="getImageURL">
16958
- <xsl:with-param name="src" select="$coverimage_src"/>
16959
- </xsl:call-template>
16960
- </xsl:variable>
16961
- <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
16962
- <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
16963
- </xsl:if>
16964
- </xsl:otherwise>
16965
- </xsl:choose>
17060
+
17061
+ <xsl:call-template name="insertPageImage"/>
17062
+
16966
17063
  </xsl:for-each>
16967
17064
  </fo:block>
16968
17065
  </fo:block-container>
16969
17066
  </xsl:template>
16970
17067
 
17068
+ <xsl:template name="insertPageImage">
17069
+ <xsl:param name="svg_content_height" select="$pageHeight"/>
17070
+ <xsl:param name="bitmap_width" select="$pageWidth"/>
17071
+ <xsl:choose>
17072
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
17073
+ <fo:instream-foreign-object fox:alt-text="Image Front">
17074
+ <xsl:attribute name="content-height"><xsl:value-of select="$svg_content_height"/>mm</xsl:attribute>
17075
+ <xsl:call-template name="getSVG"/>
17076
+ </fo:instream-foreign-object>
17077
+ </xsl:when>
17078
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
17079
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
17080
+ </xsl:when>
17081
+ <xsl:otherwise> <!-- bitmap image -->
17082
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
17083
+ <xsl:if test="$coverimage_src != ''">
17084
+ <xsl:variable name="coverpage">
17085
+ <xsl:call-template name="getImageURL">
17086
+ <xsl:with-param name="src" select="$coverimage_src"/>
17087
+ </xsl:call-template>
17088
+ </xsl:variable>
17089
+ <fo:external-graphic src="{$coverpage}" width="{$bitmap_width}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
17090
+ </xsl:if>
17091
+ </xsl:otherwise>
17092
+ </xsl:choose>
17093
+ </xsl:template>
17094
+
16971
17095
  <xsl:template name="getImageURL">
16972
17096
  <xsl:param name="src"/>
16973
17097
  <xsl:choose>
@@ -17395,6 +17519,14 @@
17395
17519
  </xsl:attribute>
17396
17520
  </xsl:template>
17397
17521
 
17522
+ <xsl:template name="getCharByCodePoint">
17523
+ <xsl:param name="codepoint"/>
17524
+ <xsl:param name="radix">16</xsl:param>
17525
+ <xsl:variable name="codepointInt" select="java:java.lang.Integer.parseInt($codepoint,$radix)"/>
17526
+ <xsl:variable name="chars" select="java:java.lang.Character.toChars($codepointInt)"/>
17527
+ <xsl:value-of select="java:java.lang.String.new($chars)"/>
17528
+ </xsl:template>
17529
+
17398
17530
  <xsl:template name="substring-after-last">
17399
17531
  <xsl:param name="value"/>
17400
17532
  <xsl:param name="delimiter"/>
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  class Metadata < IsoDoc::Metadata
7
7
  def initialize(lang, script, i18n, fonts_options = {})
8
8
  super
9
- @metadata[:issueddate] = "&lt;Date Approved&gt;"
9
+ @metadata[:ieee_sasb_approveddate] = "&lt;Date Approved&gt;"
10
10
  logos
11
11
  end
12
12
 
@@ -64,28 +64,30 @@ module IsoDoc
64
64
  end
65
65
 
66
66
  def society(xml)
67
- society = xml.at(ns("//bibdata/ext/editorialgroup/" \
68
- "society"))&.text || "&lt;Society&gt;"
67
+ society = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \
68
+ "organization/subdivision[@type='Society']/name"))&.text ||
69
+ "&lt;Society&gt;"
69
70
  set(:society, society)
70
71
  end
71
72
 
72
73
  def tc(xml)
73
- tc = xml.at(ns("//bibdata/ext/editorialgroup/" \
74
- "committee"))&.text || "&lt;Committee Name&gt;"
74
+ tc = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \
75
+ "organization/subdivision[@type='Committee']/name"))&.text ||
76
+ "&lt;Committee Name&gt;"
75
77
  set(:technical_committee, tc)
76
78
  end
77
79
 
78
80
  def wg(xml)
79
- wg = xml.at(ns("//bibdata/ext/editorialgroup/" \
80
- "working-group")) or return nil
81
+ wg = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \
82
+ "organization/subdivision[@type='Working group']/name")) or return nil
81
83
  set(:working_group, wg.text)
82
84
  end
83
85
 
84
86
  def bg(xml)
85
- bg = xml.at(ns("//bibdata/ext/editorialgroup/" \
86
- "balloting-group")) or return nil
87
+ bg = xml.at(ns("//bibdata/contributor[role/@type = 'authorizer']/" \
88
+ "organization/subdivision[@type='Balloting group']/name")) or return nil
87
89
  set(:balloting_group, bg.text)
88
- set(:balloting_group_type, bg["type"])
90
+ set(:balloting_group_type, bg.parent["subtype"])
89
91
  end
90
92
 
91
93
  def otherid(isoxml, _out)
@@ -117,10 +117,12 @@ module IsoDoc
117
117
  end
118
118
 
119
119
  def availability_note(bib)
120
- note = bib.at(ns("./note[@type = 'Availability']")) or return ""
121
- id = UUIDTools::UUID.random_create.to_s
122
- @new_ids[id] = nil
123
- "<fn id='#{id}' reference='#{id}'><p>#{note.content}</p></fn>"
120
+ notes = bib.xpath(ns("./note[@type = 'Availability']"))
121
+ notes.map do |note|
122
+ id = UUIDTools::UUID.random_create.to_s
123
+ @new_ids[id] = nil
124
+ "<fn id='#{id}' reference='#{id}'><p>#{note.content}</p></fn>"
125
+ end.join
124
126
  end
125
127
 
126
128
  def omit_docid_prefix(prefix)
@@ -130,10 +132,11 @@ module IsoDoc
130
132
 
131
133
  def bracket_if_num(num)
132
134
  num.nil? and return nil
133
- num = num.text.sub(/^\[/, "").sub(/\]$/, "")
134
- return "[#{num}]" if /^B?\d+$/.match?(num)
135
-
136
- num
135
+ ret = num.dup
136
+ ret.xpath(ns(".//fn")).each(&:remove)
137
+ ret = ret.text.strip.sub(/^\[/, "").sub(/\]$/, "")
138
+ /^B?\d+$/.match?(ret) and return "[#{ret}]"
139
+ ret
137
140
  end
138
141
  end
139
142
  end
@@ -31,6 +31,13 @@ module IsoDoc
31
31
  end
32
32
  end
33
33
 
34
+ def wrap_nodeset_in_parens(xpath)
35
+ unless xpath.empty?
36
+ xpath[0].previous = " ("
37
+ xpath[-1].next = ")"
38
+ end
39
+ end
40
+
34
41
  def unwrap_definition1(d)
35
42
  %w(verbal-definition non-verbal-representation).each do |e|
36
43
  v = d.at(ns("./#{e}")) or next
@@ -41,11 +48,7 @@ module IsoDoc
41
48
  v.children =
42
49
  "#{p.map(&:children).map { |x| to_xml(x) }.join("\n")}#{s}"
43
50
  else
44
- s = v.xpath(ns("./source"))
45
- unless s.empty?
46
- s[0].previous = " ("
47
- s[-1].next = ")"
48
- end
51
+ wrap_nodeset_in_parens(v.xpath(ns("./source")))
49
52
  end
50
53
  v.replace(v.children)
51
54
  end
@@ -77,6 +80,7 @@ module IsoDoc
77
80
  def: term.at(ns("./fmt-definition")),
78
81
  rels: term.at(ns("./fmt-related"))&.remove,
79
82
  source: term.at(ns("./fmt-termsource"))&.remove,
83
+ fns: term.xpath(ns("./fn")).map(&:remove),
80
84
  )
81
85
  term.at(ns("./fmt-admitted"))&.remove
82
86
  ins = term.at(ns("./fmt-definition")) and
@@ -96,8 +100,7 @@ module IsoDoc
96
100
  def collapse_term_related1(rels)
97
101
  rels.xpath(ns("./p")).each do |p|
98
102
  orig = p.at(ns(".//semx[@element = 'related']"))
99
- reln = "<em>#{@i18n.relatedterms[orig['type']]}:</em> "
100
- p.add_first_child reln
103
+ p.add_first_child "<em>#{@i18n.relatedterms[orig['type']]}:</em> "
101
104
  p.xpath(ns(".//semx[@element = 'related']")).each do |r|
102
105
  r.at(ns("./fmt-preferred")) or
103
106
  r.add_first_child "**RELATED TERM NOT FOUND**"
@@ -107,9 +110,8 @@ module IsoDoc
107
110
 
108
111
  def collapse_term_template(opt)
109
112
  defn, multiblock = collapse_unwrap_definition(opt[:def])
110
- opt[:source] and src = "(#{to_xml(opt[:source].remove.children).strip})"
111
113
  t = collapse_term_pref(opt)
112
- tail = "#{collapse_term_related(opt[:rels])} #{src}"
114
+ tail = collapse_term_template_tail(opt)
113
115
  if multiblock
114
116
  tail = tail.strip.empty? ? "" : "<p>#{tail}</p>"
115
117
  "<p>#{t}:</p> #{defn}#{tail}"
@@ -117,14 +119,16 @@ module IsoDoc
117
119
  end
118
120
  end
119
121
 
122
+ def collapse_term_template_tail(opt)
123
+ opt[:source] and src = "(#{to_xml(opt[:source].children).strip})"
124
+ opt[:fns].empty? or fn = opt[:fns].map(&:to_xml).join
125
+ "#{collapse_term_related(opt[:rels])} #{src}#{fn}"
126
+ end
127
+
120
128
  def collapse_term_pref(opt)
121
129
  p = opt[:pref]
122
130
  p.text.strip.empty? and return "**TERM NOT FOUND**"
123
- s = p.xpath(ns(".//semx[@element = 'source']"))
124
- unless s.empty?
125
- s[0].previous = " ("
126
- s[-1].next = ")"
127
- end
131
+ wrap_nodeset_in_parens(p.xpath(ns(".//semx[@element = 'source']")))
128
132
  p.xpath(ns(".//fmt-termsource")).each { |x| x.replace(x.children) }
129
133
  to_xml(p.children).strip
130
134
  end
@@ -228,6 +228,16 @@ module IsoDoc
228
228
  n.children.wrap("<em></em>")
229
229
  end
230
230
 
231
+ # before processing, move license termnotes to fn at end of term,
232
+ # so they aren't numbered as termnotes
233
+ def conversions(docxml)
234
+ docxml.xpath(ns("//termnote[@type='license']")).each do |n|
235
+ n.name = "fn"
236
+ n.parent << n
237
+ end
238
+ super
239
+ end
240
+
231
241
  include Init
232
242
  end
233
243
  end
@@ -114,7 +114,7 @@ module IsoDoc
114
114
  "<div class='WordSection'>#{para}#{d}</div>"
115
115
  end.join(SECTIONBREAK)
116
116
  div.document.at("//div[@class = 'WordSectionIntro']")
117
- .previous_element.previous = SECTIONBREAK + out
117
+ .previous_element.previous = SECTIONBREAK + out + SECTIONBREAK
118
118
  end
119
119
 
120
120
  def feedback_table(docxml)
@@ -203,16 +203,16 @@ module IsoDoc
203
203
  end
204
204
  end
205
205
 
206
- # "Figure 1" remove each of these: strip elements in caption associated
206
+ # "Figure 1" remove each of these: strip elements in caption associated
207
207
  # with autonumbering -- # but not in footnotes. The autonumber captions
208
- # are provided by Word styles instead
208
+ # are provided by Word styles instead.
209
+ # Retain the em-dash delimiting caption
209
210
  def strip_caption_semx(name)
210
211
  name.xpath(".//xmlns:semx[@element = 'autonum']/"\
211
212
  "preceding-sibling::*[normalize-space() = '']").each do |s|
212
213
  s.ancestors("fn").empty? and s.remove
213
214
  end
214
215
  name.xpath(ns(".//span[@class = 'fmt-element-name'] | "\
215
- ".//span[@class = 'fmt-caption-delim'] | "\
216
216
  ".//semx[@element = 'autonum']")).each do |s|
217
217
  s.ancestors("fn").empty? and s.remove
218
218
  end