metanorma-bipm 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -254,6 +254,28 @@
254
254
  </fo:repeatable-page-master-alternatives>
255
255
  </fo:page-sequence-master>
256
256
 
257
+ <!-- Document pages (landscape orientation) -->
258
+ <fo:simple-page-master master-name="document-landscape-odd" page-width="{$pageHeight}" page-height="{$pageWidth}">
259
+ <fo:region-body margin-top="25.4mm" margin-bottom="22mm" margin-left="31.7mm" margin-right="40mm"/>
260
+ <fo:region-before region-name="header-odd" extent="25.4mm"/>
261
+ <fo:region-after region-name="footer" extent="22mm"/> <!-- debug: background-color="green" -->
262
+ <fo:region-start region-name="left-region" extent="17mm"/>
263
+ <fo:region-end region-name="right-region" extent="26.5mm"/>
264
+ </fo:simple-page-master>
265
+ <fo:simple-page-master master-name="document-landscape-even" page-width="{$pageHeight}" page-height="{$pageWidth}">
266
+ <fo:region-body margin-top="25.4mm" margin-bottom="22mm" margin-left="31.7mm" margin-right="40mm"/>
267
+ <fo:region-before region-name="header-even" extent="25.4mm"/>
268
+ <fo:region-after region-name="footer" extent="22mm"/> <!-- debug: background-color="green" -->
269
+ <fo:region-start region-name="left-region" extent="17mm"/>
270
+ <fo:region-end region-name="right-region" extent="26.5mm"/>
271
+ </fo:simple-page-master>
272
+ <fo:page-sequence-master master-name="document-landscape">
273
+ <fo:repeatable-page-master-alternatives>
274
+ <fo:conditional-page-master-reference odd-or-even="even" master-reference="document-landscape-even"/>
275
+ <fo:conditional-page-master-reference odd-or-even="odd" master-reference="document-landscape-odd"/>
276
+ </fo:repeatable-page-master-alternatives>
277
+ </fo:page-sequence-master>
278
+
257
279
  <!-- Index pages -->
258
280
  <fo:simple-page-master master-name="index-odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
259
281
  <fo:region-body margin-top="25.4mm" margin-bottom="22mm" margin-left="31.7mm" margin-right="41.7mm" column-count="2" column-gap="10mm"/>
@@ -329,10 +351,14 @@
329
351
  <xsl:apply-templates select="xalan:nodeset($current_document)" mode="flatxml"/>
330
352
  </xsl:variable> -->
331
353
 
332
- <xsl:variable name="flatxml">
354
+ <xsl:variable name="flatxml_">
333
355
  <xsl:apply-templates select="." mode="flatxml"/>
334
356
  </xsl:variable>
335
357
 
358
+ <xsl:variable name="flatxml">
359
+ <xsl:apply-templates select="xalan:nodeset($flatxml_)" mode="pagebreak"/>
360
+ </xsl:variable>
361
+
336
362
  <!-- flatxml=<xsl:copy-of select="$flatxml"/> -->
337
363
 
338
364
  <xsl:apply-templates select="xalan:nodeset($flatxml)/bipm:bipm-standard" mode="bipm-standard">
@@ -356,10 +382,14 @@
356
382
  <xsl:apply-templates select="xalan:nodeset($current_document)" mode="flatxml"/>
357
383
  </xsl:variable> -->
358
384
 
359
- <xsl:variable name="flatxml">
385
+ <xsl:variable name="flatxml_">
360
386
  <xsl:apply-templates select="." mode="flatxml"/>
361
387
  </xsl:variable>
362
388
 
389
+ <xsl:variable name="flatxml">
390
+ <xsl:apply-templates select="xalan:nodeset($flatxml_)" mode="pagebreak"/>
391
+ </xsl:variable>
392
+
363
393
  <xsl:apply-templates select="xalan:nodeset($flatxml)/bipm:bipm-standard" mode="bipm-standard">
364
394
  <xsl:with-param name="curr_docnum" select="$num"/>
365
395
  </xsl:apply-templates>
@@ -372,10 +402,14 @@
372
402
  </xsl:when>
373
403
  <xsl:otherwise>
374
404
 
375
- <xsl:variable name="flatxml">
405
+ <xsl:variable name="flatxml_">
376
406
  <xsl:apply-templates mode="flatxml"/>
377
407
  </xsl:variable>
378
-
408
+
409
+ <xsl:variable name="flatxml">
410
+ <xsl:apply-templates select="xalan:nodeset($flatxml_)" mode="pagebreak"/>
411
+ </xsl:variable>
412
+
379
413
  <!-- flatxml=<xsl:copy-of select="$flatxml"/> -->
380
414
 
381
415
  <!-- indexes=<xsl:copy-of select="$indexes"/> -->
@@ -861,8 +895,82 @@
861
895
  <!-- END: Flattening xml for fit notes at page sides (margins) -->
862
896
  <!-- ================================= -->
863
897
 
898
+ <!-- ================================= -->
899
+ <!-- Page breaks processing (close previous elements (clause) and start new) -->
900
+ <!-- ================================= -->
901
+ <xsl:template match="@*|node()" mode="pagebreak">
902
+ <xsl:copy>
903
+ <xsl:apply-templates select="@*|node()" mode="pagebreak"/>
904
+ </xsl:copy>
905
+ </xsl:template>
864
906
 
907
+ <xsl:template match="node()[bipm:pagebreak[@orientation]]" mode="pagebreak">
908
+ <xsl:variable name="element_name" select="local-name()"/>
909
+ <xsl:for-each select="bipm:pagebreak[@orientation]">
910
+ <xsl:variable name="pagebreak_id" select="generate-id()"/>
911
+ <xsl:variable name="pagebreak_previous_orientation" select="preceding-sibling::bipm:pagebreak[@orientation][1]/@orientation"/>
912
+
913
+ <!-- copy elements before page break -->
914
+ <xsl:element name="{$element_name}" namespace="https://www.metanorma.org/ns/bipm">
915
+ <xsl:if test="not(preceding-sibling::bipm:pagebreak[@orientation])">
916
+ <xsl:apply-templates select="../@*" mode="pagebreak"/>
917
+ </xsl:if>
918
+ <xsl:if test="$pagebreak_previous_orientation != ''">
919
+ <xsl:attribute name="orientation"><xsl:value-of select="$pagebreak_previous_orientation"/></xsl:attribute>
920
+ </xsl:if>
921
+
922
+ <xsl:apply-templates select="preceding-sibling::node()[following-sibling::bipm:pagebreak[@orientation][1][generate-id(.) = $pagebreak_id]][not(local-name() = 'pagebreak' and @orientation)]" mode="pagebreak"/>
923
+ </xsl:element>
924
+
925
+ <!-- copy elements after last page break -->
926
+ <xsl:if test="position() = last() and following-sibling::node()">
927
+ <xsl:element name="{$element_name}" namespace="https://www.metanorma.org/ns/bipm">
928
+ <xsl:attribute name="orientation"><xsl:value-of select="@orientation"/></xsl:attribute>
929
+ <xsl:apply-templates select="following-sibling::node()" mode="pagebreak"/>
930
+ </xsl:element>
931
+ </xsl:if>
932
+
933
+ </xsl:for-each>
934
+
935
+ </xsl:template>
865
936
 
937
+ <xsl:template match="bipm:pagebreak2" mode="pagebreak">
938
+ <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
939
+ <xsl:variable name="tree">
940
+ <xsl:for-each select="ancestor::*[ancestor::bipm:sections or ancestor::bipm:annex or ancestor::bipm:preface]">
941
+ <element pos="{position()}">
942
+ <xsl:value-of select="name()"/>
943
+ </element>
944
+ </xsl:for-each>
945
+ </xsl:variable>
946
+ <!-- close preceding elements -->
947
+ <xsl:for-each select="xalan:nodeset($tree)//element">
948
+ <xsl:sort data-type="number" order="descending" select="@pos"/>
949
+ <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
950
+ <xsl:value-of select="."/>
951
+ <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
952
+ </xsl:for-each>
953
+ <!-- open elements -->
954
+ <xsl:for-each select="xalan:nodeset($tree)//element">
955
+ <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
956
+ <xsl:value-of select="."/>
957
+ <xsl:for-each select="@*[local-name() != 'pos']">
958
+ <xsl:text> </xsl:text>
959
+ <xsl:value-of select="local-name()"/>
960
+ <xsl:text>="</xsl:text>
961
+ <xsl:value-of select="."/>
962
+ <xsl:text>"</xsl:text>
963
+ </xsl:for-each>
964
+ <xsl:if test="position() = 1">
965
+ <xsl:text> orientation="</xsl:text><xsl:value-of select="$orientation"/><xsl:text>"</xsl:text>
966
+ </xsl:if>
967
+ <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
968
+ </xsl:for-each>
969
+
970
+ </xsl:template>
971
+ <!-- ================================= -->
972
+ <!-- END: Page breaks processing -->
973
+ <!-- ================================= -->
866
974
 
867
975
  <xsl:template match="bipm:bipm-standard"/>
868
976
  <xsl:template match="bipm:bipm-standard" mode="bipm-standard">
@@ -1072,12 +1180,11 @@
1072
1180
 
1073
1181
 
1074
1182
  <!-- Document Pages -->
1075
-
1076
1183
  <xsl:apply-templates select="bipm:sections/*" mode="sections"/>
1077
1184
 
1078
1185
 
1079
-
1080
1186
  <!-- Normative references -->
1187
+
1081
1188
  <xsl:apply-templates select="bipm:bibliography/bipm:references[@normative='true']" mode="sections"/>
1082
1189
 
1083
1190
  <xsl:apply-templates select="bipm:annex" mode="sections"/>
@@ -1085,6 +1192,9 @@
1085
1192
  <!-- Bibliography -->
1086
1193
  <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1087
1194
 
1195
+ <!-- Document Control -->
1196
+ <xsl:apply-templates select="bipm:doccontrol" mode="sections"/>
1197
+
1088
1198
  <!-- Index -->
1089
1199
  <!-- <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:clause[@type = 'index']" mode="index" /> -->
1090
1200
  <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:indexsect" mode="index"/>
@@ -1238,7 +1348,6 @@
1238
1348
  <xsl:apply-templates select="bipm:preface/*" mode="sections"/> <!-- bipm:clause -->
1239
1349
 
1240
1350
  <!-- Document Pages -->
1241
-
1242
1351
  <xsl:apply-templates select="bipm:sections/*" mode="sections"/>
1243
1352
  <!-- <xsl:call-template name="sections_appendix"/> --> <!-- without pagebreaks -->
1244
1353
 
@@ -1250,6 +1359,9 @@
1250
1359
 
1251
1360
  <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1252
1361
 
1362
+ <!-- Document Control -->
1363
+ <xsl:apply-templates select="bipm:doccontrol" mode="sections"/>
1364
+
1253
1365
  <!-- Index -->
1254
1366
  <!-- <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:clause[@type = 'index']" mode="index" /> -->
1255
1367
  <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:indexsect" mode="index"/>
@@ -1963,11 +2075,14 @@
1963
2075
 
1964
2076
  <xsl:template match="node()" mode="sections">
1965
2077
  <fo:page-sequence master-reference="document" force-page-count="no-force">
2078
+ <xsl:if test="@orientation = 'landscape'">
2079
+ <xsl:attribute name="master-reference">document-landscape</xsl:attribute>
2080
+ </xsl:if>
2081
+
1966
2082
  <xsl:call-template name="insertFootnoteSeparator"/>
1967
2083
 
1968
2084
  <xsl:variable name="header-title">
1969
2085
  <xsl:choose>
1970
-
1971
2086
  <xsl:when test="local-name(..) = 'sections'">
1972
2087
  <xsl:choose>
1973
2088
  <xsl:when test="./bipm:title[1]/*[local-name() = 'tab']">
@@ -2008,6 +2123,7 @@
2008
2123
  </xsl:variable>
2009
2124
  <xsl:call-template name="insertHeaderFooter">
2010
2125
  <xsl:with-param name="header-title" select="$header-title"/>
2126
+ <xsl:with-param name="orientation" select="@orientation"/>
2011
2127
  </xsl:call-template>
2012
2128
 
2013
2129
  <fo:flow flow-name="xsl-region-body">
@@ -2479,13 +2595,25 @@
2479
2595
  <xsl:variable name="space-before-value" select="normalize-space($space-before)"/>
2480
2596
 
2481
2597
  <fo:table table-layout="fixed" width="174mm" line-height="135%">
2598
+ <xsl:if test="@orientation = 'landscape'">
2599
+ <xsl:attribute name="width">261mm</xsl:attribute> <!-- 87 = (297 - 210) -->
2600
+ </xsl:if>
2482
2601
  <xsl:call-template name="setId"/>
2483
2602
  <xsl:if test="$space-before-value != ''">
2484
2603
  <xsl:attribute name="space-before"><xsl:value-of select="$space-before-value"/></xsl:attribute>
2485
2604
  </xsl:if>
2486
- <fo:table-column column-width="137mm"/>
2605
+
2606
+ <xsl:choose>
2607
+ <xsl:when test="@orientation = 'landscape'">
2608
+ <fo:table-column column-width="224mm"/> <!-- +87 -->
2609
+ </xsl:when>
2610
+ <xsl:otherwise>
2611
+ <fo:table-column column-width="137mm"/>
2612
+ </xsl:otherwise>
2613
+ </xsl:choose>
2487
2614
  <fo:table-column column-width="5mm"/>
2488
2615
  <fo:table-column column-width="32mm"/>
2616
+
2489
2617
  <fo:table-body>
2490
2618
 
2491
2619
  <xsl:variable name="total_rows" select="count(*)"/>
@@ -3296,7 +3424,7 @@
3296
3424
 
3297
3425
  <!-- set height for sup -->
3298
3426
  <!-- <xsl:template match="mathml:msup[count(*) = 2 and count(mathml:mrow) = 2]/mathml:mrow[1][count(*) = 1 and mathml:mtext and (mathml:mtext/text() != '' and mathml:mtext/text() != ' ' and mathml:mtext/text() != '&#xa0;')]/mathml:mtext" mode="mtext"> -->
3299
- <xsl:template match="mathml:msup[count(*) = 2 and count(mathml:mrow) = 2]/mathml:mrow[1][count(*) = 1]/*" mode="mathml" priority="2">
3427
+ <xsl:template match="mathml:msup[count(*) = 2 and count(mathml:mrow) = 2]/mathml:mrow[1][count(*) = 1 and not(mathml:mfenced)]/*" mode="mathml" priority="3">
3300
3428
  <xsl:copy>
3301
3429
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3302
3430
  </xsl:copy>
@@ -3327,23 +3455,49 @@
3327
3455
  <mrow>
3328
3456
  <mtext>Cu</mtext>
3329
3457
  </mrow>
3330
- </mfenced>
3331
- to:
3458
+ </mfenced>
3459
+ to:
3460
+ <mfenced open="(" close=")" separators="">
3461
+ <mathml:mo rspace="-0.35em"></mathml:mo>
3462
+ <mathml:mspace width="-0.15em"/>
3463
+ <mrow>
3464
+ <mtext>Cu</mtext>
3465
+ </mrow>
3466
+ <mathml:mspace width="-0.1em"/>
3467
+ </mfenced>
3468
+ -->
3469
+ <xsl:template match="mathml:mfenced[count(*) = 1]" mode="mathml" priority="2">
3470
+ <xsl:if test="preceding-sibling::*">
3471
+ <mathml:mo rspace="-0.35em"/><!-- decrease space before opening bracket -->
3472
+ </xsl:if>
3473
+ <xsl:copy>
3474
+ <xsl:apply-templates select="@*" mode="mathml"/>
3475
+ <xsl:if test="not(@separators)">
3476
+ <xsl:attribute name="separators"/>
3477
+ </xsl:if>
3478
+ <mathml:mspace width="-0.15em"/> <!-- decrease space between opening brackets and inside text-->
3479
+ <xsl:apply-templates mode="mathml"/>
3480
+ <mathml:mspace width="-0.1em"/> <!-- decrease space between inside text and closing brackets -->
3481
+ </xsl:copy>
3482
+ </xsl:template>
3483
+
3484
+ <!-- to:
3332
3485
  <mrow>
3333
3486
  <mtext>(Cu)</mtext>
3334
3487
  </mrow> -->
3335
- <xsl:template match="mathml:mfenced[count(*) = 1 and *[count(*) = 1] and */*[count(*) = 0]] | mathml:mfenced[count(*) = 1 and *[count(*) = 1] and */*[count(*) = 1] and */*/*[count(*) = 0]]" mode="mathml" priority="2">
3488
+ <!-- <xsl:template match="mathml:mfenced[count(*) = 1 and *[count(*) = 1] and */*[count(*) = 0]] |
3489
+ mathml:mfenced[count(*) = 1 and *[count(*) = 1] and */*[count(*) = 1] and */*/*[count(*) = 0]]" mode="mathml" priority="2">
3336
3490
  <xsl:apply-templates mode="mathml"/>
3337
3491
  </xsl:template>
3338
-
3339
- <xsl:template match="mathml:mfenced[count(*) = 1]/*[count(*) = 1]/*[count(*) = 0] | mathml:mfenced[count(*) = 1]/*[count(*) = 1]/*[count(*) = 1]/*[count(*) = 0]" mode="mathml" priority="2"> <!-- [not(following-sibling::*) and not(preceding-sibling::*)] -->
3492
+ <xsl:template match="mathml:mfenced[count(*) = 1]/*[count(*) = 1]/*[count(*) = 0] |
3493
+ mathml:mfenced[count(*) = 1]/*[count(*) = 1]/*[count(*) = 1]/*[count(*) = 0]" mode="mathml" priority="2">
3340
3494
  <xsl:copy>
3341
3495
  <xsl:apply-templates select="@*" mode="mathml"/>
3342
3496
  <xsl:value-of select="ancestor::mathml:mfenced[1]/@open"/>
3343
3497
  <xsl:value-of select="."/>
3344
3498
  <xsl:value-of select="ancestor::mathml:mfenced[1]/@close"/>
3345
3499
  </xsl:copy>
3346
- </xsl:template>
3500
+ </xsl:template> -->
3347
3501
 
3348
3502
  <!-- Decrease height of / and | -->
3349
3503
  <xsl:template match="mathml:mo[normalize-space(text()) = '/' or normalize-space(text()) = '|']" mode="mathml">
@@ -3356,6 +3510,20 @@
3356
3510
  </xsl:copy>
3357
3511
  </xsl:template>
3358
3512
 
3513
+ <!-- Decrease a distance before and after of delta -->
3514
+ <xsl:template match="mathml:mo[normalize-space(text()) = 'Δ']" mode="mathml">
3515
+ <xsl:copy>
3516
+ <xsl:apply-templates select="@*" mode="mathml"/>
3517
+ <xsl:if test="not(@rspace)">
3518
+ <xsl:attribute name="rspace">0em</xsl:attribute>
3519
+ </xsl:if>
3520
+ <xsl:if test="not(@lspace) and (preceding-sibling::*[1][local-name() = 'mo'] or not(preceding-sibling::*))">
3521
+ <xsl:attribute name="lspace">0em</xsl:attribute>
3522
+ </xsl:if>
3523
+ <xsl:apply-templates mode="mathml"/>
3524
+ </xsl:copy>
3525
+ </xsl:template>
3526
+
3359
3527
  <xsl:template match="mathml:mi[string-length(normalize-space()) &gt; 1]" mode="mathml" priority="2">
3360
3528
  <xsl:if test="preceding-sibling::* and preceding-sibling::*[1][not(local-name() = 'mfenced' or local-name() = 'mo')]">
3361
3529
  <mathml:mspace width="0.3em"/>
@@ -3367,7 +3535,8 @@
3367
3535
  </xsl:template>
3368
3536
 
3369
3537
  <xsl:template name="insertHeaderFooter">
3370
- <xsl:param name="header-title"/>
3538
+ <xsl:param name="header-title"/>
3539
+ <xsl:param name="orientation"/>
3371
3540
  <fo:static-content flow-name="header-odd">
3372
3541
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3373
3542
  <fo:block text-align="right">
@@ -3382,9 +3551,12 @@
3382
3551
  </fo:block>
3383
3552
  </fo:block-container>
3384
3553
  <fo:block-container font-size="1pt" border-top="0.5pt solid black" margin-left="81mm" width="86mm">
3385
- <fo:block> </fo:block>
3386
- </fo:block-container>
3387
- </fo:static-content>
3554
+ <xsl:if test="$orientation = 'landscape'">
3555
+ <xsl:attribute name="margin-left">168mm</xsl:attribute>
3556
+ </xsl:if>
3557
+ <fo:block> </fo:block>
3558
+ </fo:block-container>
3559
+ </fo:static-content>
3388
3560
  <fo:static-content flow-name="header-even">
3389
3561
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3390
3562
  <fo:block>
@@ -4635,7 +4807,7 @@
4635
4807
 
4636
4808
 
4637
4809
 
4638
- <xsl:if test="not(ancestor::*[local-name()='preface']) and not(ancestor::*[local-name()='note_side']) and not(ancestor::*[local-name() = 'annex'] and .//*[local-name() = 'xref'][@pagenumber])">
4810
+ <xsl:if test="not(ancestor::*[local-name()='preface']) and not(ancestor::*[local-name()='note_side']) and not(ancestor::*[local-name() = 'annex'] and .//*[local-name() = 'xref'][@pagenumber]) and not(ancestor::*[local-name() = 'doccontrol'])">
4639
4811
  <attribute name="border-top">0.5pt solid black</attribute>
4640
4812
  <attribute name="border-bottom">0.5pt solid black</attribute>
4641
4813
  </xsl:if>
@@ -4751,6 +4923,9 @@
4751
4923
  <xsl:if test="not(*[local-name()='tab'])"> <!-- table without number -->
4752
4924
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
4753
4925
  </xsl:if>
4926
+ <xsl:if test="not(../preceding-sibling::*) and ancestor::node()[@orientation]">
4927
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
4928
+ </xsl:if>
4754
4929
 
4755
4930
  <xsl:apply-templates/>
4756
4931
  </fo:block>
@@ -5187,10 +5362,21 @@
5187
5362
  <xsl:attribute name="border-bottom">solid black 0.5pt</xsl:attribute>
5188
5363
  <xsl:attribute name="height">8mm</xsl:attribute>
5189
5364
  <xsl:attribute name="padding-top">2mm</xsl:attribute>
5190
- <xsl:if test="ancestor::*[local-name() = 'annex'] and ancestor::*[local-name() = 'table']//*[local-name() = 'xref'][@pagenumber]"><!-- for Annex ToC -->
5365
+ <xsl:if test="(ancestor::*[local-name() = 'annex'] and ancestor::*[local-name() = 'table']//*[local-name() = 'xref'][@pagenumber]) or ancestor::*[local-name() = 'doccontrol']"><!-- for Annex ToC -->
5191
5366
  <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>
5192
5367
  <xsl:attribute name="border-bottom">solid black 0pt</xsl:attribute>
5193
5368
  </xsl:if>
5369
+ <xsl:if test="ancestor::*[local-name() = 'doccontrol']">
5370
+ <xsl:attribute name="text-align">
5371
+ <xsl:choose>
5372
+ <xsl:when test="@align">
5373
+ <xsl:value-of select="@align"/>
5374
+ </xsl:when>
5375
+ <xsl:otherwise>left</xsl:otherwise>
5376
+ </xsl:choose>
5377
+ </xsl:attribute>
5378
+ <xsl:attribute name="display-align">before</xsl:attribute>
5379
+ </xsl:if>
5194
5380
 
5195
5381
  <xsl:if test="@colspan">
5196
5382
  <xsl:attribute name="number-columns-spanned">
@@ -5247,6 +5433,9 @@
5247
5433
  <xsl:if test="not(ancestor::*[local-name()='tr']/following-sibling::*[local-name()='tr'])"> <!-- last row -->
5248
5434
  <xsl:attribute name="padding-bottom">2mm</xsl:attribute>
5249
5435
  </xsl:if>
5436
+ <xsl:if test="ancestor::*[local-name() = 'doccontrol']">
5437
+ <xsl:attribute name="display-align">before</xsl:attribute>
5438
+ </xsl:if>
5250
5439
 
5251
5440
  <xsl:if test="@colspan">
5252
5441
  <xsl:attribute name="number-columns-spanned">
@@ -6265,7 +6454,7 @@
6265
6454
  </xsl:variable>
6266
6455
  <fo:instream-foreign-object fox:alt-text="Math">
6267
6456
 
6268
- <xsl:if test="ancestor::*[local-name() = 'formula']">
6457
+ <xsl:if test="local-name(../..) = 'formula'">
6269
6458
  <xsl:attribute name="width">95%</xsl:attribute>
6270
6459
  <xsl:attribute name="content-height">100%</xsl:attribute>
6271
6460
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
@@ -7621,8 +7810,8 @@
7621
7810
  <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
7622
7811
  <xsl:apply-templates/>
7623
7812
  </fo:block>
7624
- </xsl:template><xsl:template match="*[local-name() = 'bookmark']">
7625
- <fo:inline id="{@id}"/>
7813
+ </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7814
+ <fo:inline id="{@id}" font-size="1pt"/>
7626
7815
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7627
7816
  <!-- <row>
7628
7817
  <date>05-07-2013</date>
@@ -28,7 +28,8 @@ module IsoDoc
28
28
  c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
29
29
  end
30
30
  end
31
- @xrefs.bookmark_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
31
+ docxml.xpath(ns("//indexsect//xref")).each { |x| x.children.remove }
32
+ @xrefs.bookmark_anchor_names(docxml)
32
33
  end
33
34
 
34
35
  def sortable(s)
@@ -5649,8 +5649,8 @@
5649
5649
  <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
5650
5650
  <xsl:apply-templates/>
5651
5651
  </fo:block>
5652
- </xsl:template><xsl:template match="*[local-name() = 'bookmark']">
5653
- <fo:inline id="{@id}"/>
5652
+ </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
5653
+ <fo:inline id="{@id}" font-size="1pt"/>
5654
5654
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
5655
5655
  <!-- <row>
5656
5656
  <date>05-07-2013</date>
@@ -33,27 +33,41 @@ module IsoDoc
33
33
  doccontrol docxml
34
34
  end
35
35
 
36
- def doccontrol docxml
36
+ def doccontrol(docxml)
37
37
  return unless docxml.at(ns("//bibdata/relation[@type = 'supersedes']"))
38
38
  clause = <<~END
39
39
  <doccontrol>
40
40
  <title>Document Control</title>
41
41
  <table unnumbered="true"><tbody>
42
- <tr><td>Authors:</td><td/><td>#{list_authors(docxml)}</td></tr>
43
- <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join }
44
- <td>#{list_cochairs(docxml)}</td></tr>
45
- <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join }
46
- <td>#{list_chairs(docxml)}</td></tr>
42
+ <tr><th>Authors:</th><td/><td>#{list_authors(docxml)}</td></tr>
43
+ #{doccontrol_row1(docxml)}
44
+ #{doccontrol_row2(docxml)}
47
45
  #{list_drafts(docxml)}
48
46
  </tbody></table></doccontrol>
49
47
  END
50
48
  docxml.root << clause
51
49
  end
52
50
 
51
+ def doccontrol_row1(docxml)
52
+ return "" if list_draft(docxml, 1) == ["", ""] && list_cochairs(docxml).empty?
53
+ <<~ROW
54
+ <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join }
55
+ <td>#{list_cochairs(docxml)}</td></tr>
56
+ ROW
57
+ end
58
+
59
+ def doccontrol_row2(docxml)
60
+ return "" if list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty?
61
+ <<~ROW
62
+ <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join }
63
+ <td>#{list_chairs(docxml)}</td></tr>
64
+ ROW
65
+ end
66
+
53
67
  def list_drafts(xml)
54
68
  ret = ""
55
69
  i = 3
56
- while a = list_draft(xml, i)
70
+ while a = list_draft(xml, i) != ["", ""]
57
71
  ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join }"\
58
72
  "<td/></tr>"
59
73
  i += 1
@@ -62,14 +76,14 @@ module IsoDoc
62
76
  end
63
77
 
64
78
  def list_draft(xml, i)
65
- return unless d =
79
+ return ["", ""] unless d =
66
80
  xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{i}]/bibitem"))
67
81
  date = d&.at(ns("./date"))&.text
68
82
  draft = d&.at(ns("./version/draft"))&.text and
69
83
  draft = "Draft #{draft}"
70
84
  edn = d&.at(ns("./edition"))&.text and
71
- edn = "Edition #{edn}"
72
- [date, [draft, edn].join(" ")]
85
+ edn = "Version #{edn}"
86
+ [[draft, edn].join(" "), date]
73
87
  end
74
88
 
75
89
  def list_authors(xml)
@@ -84,6 +98,7 @@ module IsoDoc
84
98
 
85
99
  def list_cochairs(xml)
86
100
  ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
101
+ ret.empty? and return ""
87
102
  role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
88
103
  label = ret.size > 1 && role ? "#{role}s" : role
89
104
  "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"
@@ -91,6 +106,7 @@ module IsoDoc
91
106
 
92
107
  def list_chairs(xml)
93
108
  ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
109
+ ret.empty? and return ""
94
110
  role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
95
111
  label = ret.size > 1 && role ? "#{role}s" : role
96
112
  "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"