metanorma-bipm 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,6 @@
11
11
  <!-- <item id="#">N_page</item> -->
12
12
  <!-- param for second pass -->
13
13
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
14
- <xsl:variable name="index" select="document($external_index)"/>
15
14
 
16
15
  <xsl:variable name="first_pass" select="count($index//item) = 0"/>
17
16
 
@@ -167,14 +166,7 @@
167
166
  </xsl:choose>
168
167
  </xsl:variable>
169
168
 
170
- <xsl:variable name="bookmark_in_fn">
171
- <xsl:for-each select="//bipm:bookmark[ancestor::bipm:fn]">
172
- <bookmark><xsl:value-of select="@id"/></bookmark>
173
- </xsl:for-each>
174
- </xsl:variable>
175
169
 
176
- <xsl:variable name="dash" select="'–'"/>
177
-
178
170
  <xsl:variable name="ids">
179
171
  <xsl:for-each select="//*[@id]">
180
172
  <id><xsl:value-of select="@id"/></id>
@@ -287,8 +279,9 @@
287
279
 
288
280
  </fo:layout-master-set>
289
281
 
290
-
291
- <xsl:call-template name="addPDFUAmeta"/>
282
+ <fo:declarations>
283
+ <xsl:call-template name="addPDFUAmeta"/>
284
+ </fo:declarations>
292
285
 
293
286
  <xsl:call-template name="addBookmarks">
294
287
  <xsl:with-param name="contents" select="$contents"/>
@@ -1401,17 +1394,20 @@
1401
1394
 
1402
1395
  <xsl:variable name="titles_length" select="string-length($title_appendix_fr) + string-length($title_appendix_en) + string-length($title_annex_fr) + string-length($title_annex_en) + string-length($title_part_fr) + string-length($title_part_en) + string-length($title_subpart_fr) + string-length($title_subpart_fr)"/>
1403
1396
 
1404
- <xsl:variable name="font-size-number-factor">
1397
+ <!-- <xsl:variable name="font-size-number-factor">
1405
1398
  <xsl:choose>
1406
1399
  <xsl:when test="$titles_length &gt; 350">0.7</xsl:when>
1407
1400
  <xsl:when test="$titles_length &gt; 250">0.85</xsl:when>
1401
+ <xsl:when test="$titles_length &gt; 130">0.9</xsl:when>
1408
1402
  <xsl:otherwise>1</xsl:otherwise>
1409
1403
  </xsl:choose>
1410
- </xsl:variable>
1404
+ </xsl:variable> -->
1411
1405
 
1412
1406
  <xsl:variable name="space-factor">
1413
1407
  <xsl:choose>
1414
1408
  <xsl:when test="$titles_length &gt; 250">0.3</xsl:when>
1409
+ <xsl:when test="$titles_length &gt; 200">0.5</xsl:when>
1410
+ <xsl:when test="$titles_length &gt; 150">0.7</xsl:when>
1415
1411
  <xsl:otherwise>1</xsl:otherwise>
1416
1412
  </xsl:choose>
1417
1413
  </xsl:variable>
@@ -1419,11 +1415,21 @@
1419
1415
  <xsl:variable name="font-size-factor">
1420
1416
  <xsl:choose>
1421
1417
  <xsl:when test="$titles_length &gt; 350">0.5</xsl:when>
1422
- <xsl:when test="$titles_length &gt; 250">0.65</xsl:when>
1418
+ <xsl:when test="$titles_length &gt; 250">0.55</xsl:when>
1419
+ <xsl:when test="$titles_length &gt; 180">0.65</xsl:when>
1420
+ <xsl:when test="$titles_length &gt; 130">0.8</xsl:when>
1423
1421
  <xsl:otherwise>1</xsl:otherwise>
1424
1422
  </xsl:choose>
1425
1423
  </xsl:variable>
1426
-
1424
+
1425
+ <xsl:variable name="font-size-number-factor">
1426
+ <xsl:choose>
1427
+ <xsl:when test="$font-size-factor &lt; 1"><xsl:value-of select="$font-size-factor *1.3"/></xsl:when>
1428
+ <xsl:otherwise>1</xsl:otherwise>
1429
+ </xsl:choose>
1430
+ </xsl:variable>
1431
+
1432
+ <!-- <fo:block font-size="6pt">DEBUG font-size-factor=<xsl:value-of select="$font-size-factor"/>, titles_length=<xsl:value-of select="$titles_length"/></fo:block> -->
1427
1433
  <!-- Appendix titles processing -->
1428
1434
  <xsl:variable name="appendix_num" select="normalize-space((//bipm:bipm-standard)[1]/bipm:bibdata/bipm:ext/bipm:structuredidentifier/bipm:appendix)"/>
1429
1435
  <xsl:if test="$appendix_num != ''">
@@ -3060,6 +3066,18 @@
3060
3066
  </fo:block>
3061
3067
  </xsl:template>
3062
3068
 
3069
+ <xsl:template match="bipm:preferred">
3070
+ <fo:block font-weight="bold" keep-with-next="always" space-before="8pt" margin-bottom="6pt">
3071
+ <xsl:if test="ancestor::bipm:term/bipm:name">
3072
+ <fo:inline>
3073
+ <xsl:attribute name="padding-right">2mm</xsl:attribute>
3074
+ <xsl:apply-templates select="ancestor::bipm:term/bipm:name" mode="presentation"/>
3075
+ </fo:inline>
3076
+ </xsl:if>
3077
+ <xsl:apply-templates/>
3078
+ </fo:block>
3079
+ </xsl:template>
3080
+
3063
3081
  <xsl:template match="bipm:bibitem">
3064
3082
  <fo:block id="{@id}" margin-bottom="12pt" start-indent="25mm" text-indent="-25mm" line-height="115%">
3065
3083
  <xsl:if test=".//bipm:fn">
@@ -3321,9 +3339,9 @@
3321
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::*)] -->
3322
3340
  <xsl:copy>
3323
3341
  <xsl:apply-templates select="@*" mode="mathml"/>
3324
- <xsl:value-of select="ancestor::mathml:mfenced/@open"/>
3342
+ <xsl:value-of select="ancestor::mathml:mfenced[1]/@open"/>
3325
3343
  <xsl:value-of select="."/>
3326
- <xsl:value-of select="ancestor::mathml:mfenced/@close"/>
3344
+ <xsl:value-of select="ancestor::mathml:mfenced[1]/@close"/>
3327
3345
  </xsl:copy>
3328
3346
  </xsl:template>
3329
3347
 
@@ -3331,12 +3349,22 @@
3331
3349
  <xsl:template match="mathml:mo[normalize-space(text()) = '/' or normalize-space(text()) = '|']" mode="mathml">
3332
3350
  <xsl:copy>
3333
3351
  <xsl:apply-templates select="@*" mode="mathml"/>
3334
- <xsl:if test="not(@stretchy)">
3352
+ <xsl:if test="not(@stretchy) and not(preceding-sibling::*[1][local-name() = 'mfrac'] and following-sibling::*[1][local-name() = 'mfrac'])">
3335
3353
  <xsl:attribute name="stretchy">false</xsl:attribute>
3336
3354
  </xsl:if>
3337
3355
  <xsl:apply-templates mode="mathml"/>
3338
3356
  </xsl:copy>
3339
3357
  </xsl:template>
3358
+
3359
+ <xsl:template match="mathml:mi[string-length(normalize-space()) &gt; 1]" mode="mathml" priority="2">
3360
+ <xsl:if test="preceding-sibling::* and preceding-sibling::*[1][not(local-name() = 'mfenced' or local-name() = 'mo')]">
3361
+ <mathml:mspace width="0.3em"/>
3362
+ </xsl:if>
3363
+ <xsl:copy-of select="."/>
3364
+ <xsl:if test="following-sibling::* and following-sibling::*[1][not(local-name() = 'mfenced' or local-name() = 'mo')]">
3365
+ <mathml:mspace width="0.3em"/>
3366
+ </xsl:if>
3367
+ </xsl:template>
3340
3368
 
3341
3369
  <xsl:template name="insertHeaderFooter">
3342
3370
  <xsl:param name="header-title"/>
@@ -3514,152 +3542,6 @@
3514
3542
  <!-- Index processing -->
3515
3543
  <!-- =================== -->
3516
3544
 
3517
- <xsl:template match="@*|node()" mode="index_add_id">
3518
- <xsl:copy>
3519
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
3520
- </xsl:copy>
3521
- </xsl:template>
3522
-
3523
- <xsl:template match="bipm:xref" mode="index_add_id">
3524
- <xsl:variable name="id">
3525
- <xsl:call-template name="generateIndexXrefId"/>
3526
- </xsl:variable>
3527
- <xsl:copy> <!-- add id to xref -->
3528
- <xsl:apply-templates select="@*" mode="index_add_id"/>
3529
- <xsl:attribute name="id">
3530
- <xsl:value-of select="$id"/>
3531
- </xsl:attribute>
3532
- <xsl:apply-templates mode="index_add_id"/>
3533
- </xsl:copy>
3534
- <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
3535
- <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
3536
- <xsl:if test="@to">
3537
- <xsl:value-of select="$dash"/>
3538
- <xsl:copy>
3539
- <xsl:copy-of select="@*"/>
3540
- <xsl:attribute name="target"><xsl:value-of select="@to"/></xsl:attribute>
3541
- <xsl:attribute name="id">
3542
- <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
3543
- </xsl:attribute>
3544
- <xsl:apply-templates mode="index_add_id"/>
3545
- </xsl:copy>
3546
- </xsl:if>
3547
- </xsl:template>
3548
-
3549
- <xsl:template match="@*|node()" mode="index_update">
3550
- <xsl:copy>
3551
- <xsl:apply-templates select="@*|node()" mode="index_update"/>
3552
- </xsl:copy>
3553
- </xsl:template>
3554
-
3555
- <!-- <xsl:template match="bipm:clause[@type = 'index']//bipm:li" mode="index_update"> -->
3556
- <xsl:template match="bipm:indexsect//bipm:li" mode="index_update">
3557
- <xsl:copy>
3558
- <xsl:apply-templates select="@*" mode="index_update"/>
3559
- <xsl:apply-templates select="node()[1]" mode="process_li_element"/>
3560
- </xsl:copy>
3561
- </xsl:template>
3562
-
3563
- <!-- <xsl:template match="bipm:clause[@type = 'index']//bipm:li/node()" mode="process_li_element" priority="2"> -->
3564
- <xsl:template match="bipm:indexsect//bipm:li/node()" mode="process_li_element" priority="2">
3565
- <xsl:param name="element"/>
3566
- <xsl:param name="remove" select="'false'"/>
3567
- <xsl:param name="target"/>
3568
- <!-- <node></node> -->
3569
- <xsl:choose>
3570
- <xsl:when test="self::text() and (normalize-space(.) = ',' or normalize-space(.) = $dash) and $remove = 'true'">
3571
- <!-- skip text (i.e. remove it) and process next element -->
3572
- <!-- [removed_<xsl:value-of select="."/>] -->
3573
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
3574
- <xsl:with-param name="target"><xsl:value-of select="$target"/></xsl:with-param>
3575
- </xsl:apply-templates>
3576
- </xsl:when>
3577
- <xsl:when test="self::text()">
3578
- <xsl:value-of select="."/>
3579
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
3580
- </xsl:when>
3581
- <xsl:when test="self::* and local-name(.) = 'xref'">
3582
- <xsl:variable name="id" select="@id"/>
3583
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
3584
- <xsl:variable name="id_next" select="following-sibling::bipm:xref[1]/@id"/>
3585
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
3586
-
3587
- <xsl:variable name="id_prev" select="preceding-sibling::bipm:xref[1]/@id"/>
3588
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
3589
-
3590
- <xsl:choose>
3591
- <!-- 2nd pass -->
3592
- <!-- if page is equal to page for next and page is not the end of range -->
3593
- <xsl:when test="$page != '' and $page_next != '' and $page = $page_next and not(contains($page, '_to'))"> <!-- case: 12, 12-14 -->
3594
- <!-- skip element (i.e. remove it) and remove next text ',' -->
3595
- <!-- [removed_xref] -->
3596
-
3597
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
3598
- <xsl:with-param name="remove">true</xsl:with-param>
3599
- <xsl:with-param name="target">
3600
- <xsl:choose>
3601
- <xsl:when test="$target != ''"><xsl:value-of select="$target"/></xsl:when>
3602
- <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise>
3603
- </xsl:choose>
3604
- </xsl:with-param>
3605
- </xsl:apply-templates>
3606
- </xsl:when>
3607
-
3608
- <xsl:when test="$page != '' and $page_prev != '' and $page = $page_prev and contains($page_prev, '_to')"> <!-- case: 12-14, 14, ... -->
3609
- <!-- remove xref -->
3610
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
3611
- <xsl:with-param name="remove">true</xsl:with-param>
3612
- </xsl:apply-templates>
3613
- </xsl:when>
3614
-
3615
- <xsl:otherwise>
3616
- <xsl:apply-templates select="." mode="xref_copy">
3617
- <xsl:with-param name="target" select="$target"/>
3618
- </xsl:apply-templates>
3619
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
3620
- </xsl:otherwise>
3621
- </xsl:choose>
3622
- </xsl:when>
3623
- <xsl:when test="self::* and local-name(.) = 'ul'">
3624
- <!-- ul -->
3625
- <xsl:apply-templates select="." mode="index_update"/>
3626
- </xsl:when>
3627
- <xsl:otherwise>
3628
- <xsl:apply-templates select="." mode="xref_copy">
3629
- <xsl:with-param name="target" select="$target"/>
3630
- </xsl:apply-templates>
3631
- <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
3632
- </xsl:otherwise>
3633
- </xsl:choose>
3634
- </xsl:template>
3635
-
3636
- <xsl:template match="@*|node()" mode="xref_copy">
3637
- <xsl:param name="target"/>
3638
- <xsl:copy>
3639
- <xsl:apply-templates select="@*" mode="xref_copy"/>
3640
- <xsl:if test="$target != '' and not(xalan:nodeset($bookmark_in_fn)//bookmark[. = $target])">
3641
- <xsl:attribute name="target"><xsl:value-of select="$target"/></xsl:attribute>
3642
- </xsl:if>
3643
- <xsl:apply-templates select="node()" mode="xref_copy"/>
3644
- </xsl:copy>
3645
- </xsl:template>
3646
-
3647
-
3648
- <xsl:template name="generateIndexXrefId">
3649
- <xsl:variable name="level" select="count(ancestor::bipm:ul)"/>
3650
- <!-- <xsl:variable name="parent_ul_id" select="generate-id(ancestor::bipm:ul[1])"/>
3651
- <xsl:variable name="item_number" select="count(ancestor::bipm:li[ancestor::bipm:ul[generate-id() = $parent_ul_id]])"/> -->
3652
- <xsl:variable name="docid">
3653
- <xsl:call-template name="getDocumentId"/>
3654
- </xsl:variable>
3655
- <xsl:variable name="item_number">
3656
- <!-- <xsl:number count="bipm:li[ancestor::bipm:clause[@type = 'index']]" level="any" /> -->
3657
- <xsl:number count="bipm:li[ancestor::bipm:indexsect]" level="any"/>
3658
- </xsl:variable>
3659
- <xsl:variable name="xref_number"><xsl:number count="bipm:xref"/></xsl:variable>
3660
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
3661
- </xsl:template>
3662
-
3663
3545
  <!-- <xsl:template match="bipm:clause[@type = 'index']" /> -->
3664
3546
  <!-- <xsl:template match="bipm:clause[@type = 'index']" mode="index"> -->
3665
3547
  <xsl:template match="bipm:indexsect"/>
@@ -3715,17 +3597,7 @@
3715
3597
  <xsl:apply-templates/>
3716
3598
  </fo:block>
3717
3599
  </xsl:template>
3718
-
3719
- <!-- <xsl:template match="bipm:clause[@type = 'index']/bipm:clause" priority="4"> -->
3720
- <xsl:template match="bipm:indexsect/bipm:clause" priority="4">
3721
- <xsl:apply-templates/>
3722
- <fo:block>
3723
- <xsl:if test="following-sibling::bipm:clause">
3724
- <fo:block> </fo:block>
3725
- </xsl:if>
3726
- </fo:block>
3727
- </xsl:template>
3728
-
3600
+
3729
3601
  <!-- <xsl:template match="bipm:clause[@type = 'index']/bipm:clause/bipm:title" priority="4"> -->
3730
3602
  <xsl:template match="bipm:indexsect/bipm:clause/bipm:title" priority="4">
3731
3603
  <!-- Letter A, B, C, ... -->
@@ -3734,22 +3606,6 @@
3734
3606
  </fo:block>
3735
3607
  </xsl:template>
3736
3608
 
3737
- <!-- <xsl:template match="bipm:clause[@type = 'index']//bipm:ul" priority="4"> -->
3738
- <xsl:template match="bipm:indexsect//bipm:ul" priority="4">
3739
- <xsl:apply-templates/>
3740
- </xsl:template>
3741
-
3742
- <!-- <xsl:template match="bipm:clause[@type = 'index']//bipm:li" priority="4"> -->
3743
- <xsl:template match="bipm:indexsect//bipm:li" priority="4">
3744
- <xsl:variable name="level" select="count(ancestor::bipm:ul)"/>
3745
- <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
3746
- <xsl:apply-templates/>
3747
- </fo:block>
3748
- </xsl:template>
3749
-
3750
- <xsl:template match="bipm:bookmark">
3751
- <fo:inline id="{@id}"/>
3752
- </xsl:template>
3753
3609
 
3754
3610
  <xsl:template match="*[local-name() = 'stem']/text()">
3755
3611
  <xsl:value-of select="normalize-space()"/>
@@ -4416,6 +4272,7 @@
4416
4272
 
4417
4273
 
4418
4274
 
4275
+
4419
4276
  </xsl:attribute-set><xsl:attribute-set name="termexample-name-style">
4420
4277
 
4421
4278
 
@@ -5017,7 +4874,15 @@
5017
4874
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
5018
4875
  <xsl:value-of select="@target"/>
5019
4876
  </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
5020
- <xsl:variable name="math_text" select="normalize-space(.)"/>
4877
+ <xsl:variable name="mathml">
4878
+ <xsl:for-each select="*">
4879
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4880
+ <xsl:copy-of select="."/>
4881
+ </xsl:if>
4882
+ </xsl:for-each>
4883
+ </xsl:variable>
4884
+
4885
+ <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
5021
4886
  <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
5022
4887
  </xsl:template><xsl:template match="*[local-name()='table2']"/><xsl:template match="*[local-name()='thead']"/><xsl:template match="*[local-name()='thead']" mode="process">
5023
4888
  <xsl:param name="cols-count"/>
@@ -6051,6 +5916,10 @@
6051
5916
  <fo:inline font-size="10pt" color="red" text-decoration="line-through">
6052
5917
  <xsl:apply-templates/>
6053
5918
  </fo:inline>
5919
+ </xsl:template><xsl:template match="*[local-name()='hi']">
5920
+ <fo:inline background-color="yellow">
5921
+ <xsl:apply-templates/>
5922
+ </fo:inline>
6054
5923
  </xsl:template><xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
6055
5924
  <xsl:variable name="text" select="normalize-space(.)"/>
6056
5925
  <fo:inline font-size="75%">
@@ -6395,6 +6264,14 @@
6395
6264
  <xsl:apply-templates select="." mode="mathml"/>
6396
6265
  </xsl:variable>
6397
6266
  <fo:instream-foreign-object fox:alt-text="Math">
6267
+
6268
+ <xsl:if test="ancestor::*[local-name() = 'formula']">
6269
+ <xsl:attribute name="width">95%</xsl:attribute>
6270
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6271
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6272
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6273
+ </xsl:if>
6274
+
6398
6275
  <!-- <xsl:copy-of select="."/> -->
6399
6276
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
6400
6277
  </fo:instream-foreign-object>
@@ -6413,7 +6290,7 @@
6413
6290
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
6414
6291
  </xsl:copy>
6415
6292
  <mathml:mspace width="0.5ex"/>
6416
- </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
6293
+ </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
6417
6294
  <xsl:variable name="target">
6418
6295
  <xsl:choose>
6419
6296
  <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
@@ -6447,8 +6324,6 @@
6447
6324
  </xsl:otherwise>
6448
6325
  </xsl:choose>
6449
6326
  </fo:inline>
6450
- </xsl:template><xsl:template match="*[local-name()='bookmark']">
6451
- <fo:inline id="{@id}"/>
6452
6327
  </xsl:template><xsl:template match="*[local-name()='appendix']">
6453
6328
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
6454
6329
  <xsl:apply-templates select="*[local-name()='title']" mode="process"/>
@@ -6670,6 +6545,7 @@
6670
6545
  <fo:block id="{@id}">
6671
6546
  <xsl:apply-templates/>
6672
6547
  </fo:block>
6548
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
6673
6549
  </xsl:template><xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']//*[local-name() = 'p']">
6674
6550
  <fo:block xsl:use-attribute-sets="figure-pseudocode-p-style">
6675
6551
  <xsl:apply-templates/>
@@ -7267,10 +7143,11 @@
7267
7143
  </xsl:choose>
7268
7144
 
7269
7145
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'p']">
7270
-
7146
+ <xsl:variable name="num"><xsl:number/></xsl:variable>
7271
7147
  <xsl:variable name="element">
7272
7148
  block
7273
7149
 
7150
+
7274
7151
  </xsl:variable>
7275
7152
  <xsl:choose>
7276
7153
  <xsl:when test="normalize-space($element) = 'block'">
@@ -7374,32 +7251,50 @@
7374
7251
  <xsl:text>— </xsl:text>
7375
7252
  <xsl:apply-templates/>
7376
7253
  </xsl:template><xsl:template match="*[local-name() = 'eref']">
7377
- <fo:inline xsl:use-attribute-sets="eref-style">
7378
- <xsl:if test="@type = 'footnote'">
7379
-
7380
- <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
7381
- <xsl:attribute name="font-size">80%</xsl:attribute>
7382
- <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
7383
- <xsl:attribute name="vertical-align">super</xsl:attribute>
7384
-
7385
-
7386
- </xsl:if>
7387
-
7388
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
7389
-
7390
- <xsl:if test="@type = 'inline'">
7391
-
7392
- <xsl:attribute name="color">blue</xsl:attribute>
7393
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
7394
-
7395
-
7396
-
7397
- </xsl:if>
7398
-
7399
-
7400
- <xsl:apply-templates/>
7401
- </fo:basic-link>
7402
- </fo:inline>
7254
+
7255
+ <xsl:variable name="bibitemid">
7256
+ <xsl:choose>
7257
+ <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"/>
7258
+ <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
7259
+ <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
7260
+ </xsl:choose>
7261
+ </xsl:variable>
7262
+
7263
+ <xsl:choose>
7264
+ <xsl:when test="normalize-space($bibitemid) != ''">
7265
+ <fo:inline xsl:use-attribute-sets="eref-style">
7266
+ <xsl:if test="@type = 'footnote'">
7267
+
7268
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
7269
+ <xsl:attribute name="font-size">80%</xsl:attribute>
7270
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
7271
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
7272
+
7273
+
7274
+ </xsl:if>
7275
+
7276
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
7277
+ <xsl:if test="normalize-space(@citeas) = ''">
7278
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
7279
+ </xsl:if>
7280
+ <xsl:if test="@type = 'inline'">
7281
+
7282
+ <xsl:attribute name="color">blue</xsl:attribute>
7283
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
7284
+
7285
+
7286
+
7287
+ </xsl:if>
7288
+
7289
+ <xsl:apply-templates/>
7290
+ </fo:basic-link>
7291
+
7292
+ </fo:inline>
7293
+ </xsl:when>
7294
+ <xsl:otherwise>
7295
+ <fo:inline><xsl:apply-templates/></fo:inline>
7296
+ </xsl:otherwise>
7297
+ </xsl:choose>
7403
7298
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
7404
7299
  <!-- zero-space char -->
7405
7300
  <xsl:variable name="depth">
@@ -7581,6 +7476,153 @@
7581
7476
  </fo:block>
7582
7477
  </xsl:otherwise>
7583
7478
  </xsl:choose>
7479
+ </xsl:template><xsl:variable name="index" select="document($external_index)"/><xsl:variable name="dash" select="'–'"/><xsl:variable name="bookmark_in_fn">
7480
+ <xsl:for-each select="//*[local-name() = 'bookmark'][ancestor::*[local-name() = 'fn']]">
7481
+ <bookmark><xsl:value-of select="@id"/></bookmark>
7482
+ </xsl:for-each>
7483
+ </xsl:variable><xsl:template match="@*|node()" mode="index_add_id">
7484
+ <xsl:copy>
7485
+ <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
7486
+ </xsl:copy>
7487
+ </xsl:template><xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
7488
+ <xsl:variable name="id">
7489
+ <xsl:call-template name="generateIndexXrefId"/>
7490
+ </xsl:variable>
7491
+ <xsl:copy> <!-- add id to xref -->
7492
+ <xsl:apply-templates select="@*" mode="index_add_id"/>
7493
+ <xsl:attribute name="id">
7494
+ <xsl:value-of select="$id"/>
7495
+ </xsl:attribute>
7496
+ <xsl:apply-templates mode="index_add_id"/>
7497
+ </xsl:copy>
7498
+ <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
7499
+ <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
7500
+ <xsl:if test="@to">
7501
+ <xsl:value-of select="$dash"/>
7502
+ <xsl:copy>
7503
+ <xsl:copy-of select="@*"/>
7504
+ <xsl:attribute name="target"><xsl:value-of select="@to"/></xsl:attribute>
7505
+ <xsl:attribute name="id">
7506
+ <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
7507
+ </xsl:attribute>
7508
+ <xsl:apply-templates mode="index_add_id"/>
7509
+ </xsl:copy>
7510
+ </xsl:if>
7511
+ </xsl:template><xsl:template match="@*|node()" mode="index_update">
7512
+ <xsl:copy>
7513
+ <xsl:apply-templates select="@*|node()" mode="index_update"/>
7514
+ </xsl:copy>
7515
+ </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']" mode="index_update">
7516
+ <xsl:copy>
7517
+ <xsl:apply-templates select="@*" mode="index_update"/>
7518
+ <xsl:apply-templates select="node()[1]" mode="process_li_element"/>
7519
+ </xsl:copy>
7520
+ </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']/node()" mode="process_li_element" priority="2">
7521
+ <xsl:param name="element"/>
7522
+ <xsl:param name="remove" select="'false'"/>
7523
+ <xsl:param name="target"/>
7524
+ <!-- <node></node> -->
7525
+ <xsl:choose>
7526
+ <xsl:when test="self::text() and (normalize-space(.) = ',' or normalize-space(.) = $dash) and $remove = 'true'">
7527
+ <!-- skip text (i.e. remove it) and process next element -->
7528
+ <!-- [removed_<xsl:value-of select="."/>] -->
7529
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
7530
+ <xsl:with-param name="target"><xsl:value-of select="$target"/></xsl:with-param>
7531
+ </xsl:apply-templates>
7532
+ </xsl:when>
7533
+ <xsl:when test="self::text()">
7534
+ <xsl:value-of select="."/>
7535
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
7536
+ </xsl:when>
7537
+ <xsl:when test="self::* and local-name(.) = 'xref'">
7538
+ <xsl:variable name="id" select="@id"/>
7539
+ <xsl:variable name="page" select="$index//item[@id = $id]"/>
7540
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
7541
+ <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
7542
+
7543
+ <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
7544
+ <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
7545
+
7546
+ <xsl:choose>
7547
+ <!-- 2nd pass -->
7548
+ <!-- if page is equal to page for next and page is not the end of range -->
7549
+ <xsl:when test="$page != '' and $page_next != '' and $page = $page_next and not(contains($page, '_to'))"> <!-- case: 12, 12-14 -->
7550
+ <!-- skip element (i.e. remove it) and remove next text ',' -->
7551
+ <!-- [removed_xref] -->
7552
+
7553
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
7554
+ <xsl:with-param name="remove">true</xsl:with-param>
7555
+ <xsl:with-param name="target">
7556
+ <xsl:choose>
7557
+ <xsl:when test="$target != ''"><xsl:value-of select="$target"/></xsl:when>
7558
+ <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise>
7559
+ </xsl:choose>
7560
+ </xsl:with-param>
7561
+ </xsl:apply-templates>
7562
+ </xsl:when>
7563
+
7564
+ <xsl:when test="$page != '' and $page_prev != '' and $page = $page_prev and contains($page_prev, '_to')"> <!-- case: 12-14, 14, ... -->
7565
+ <!-- remove xref -->
7566
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element">
7567
+ <xsl:with-param name="remove">true</xsl:with-param>
7568
+ </xsl:apply-templates>
7569
+ </xsl:when>
7570
+
7571
+ <xsl:otherwise>
7572
+ <xsl:apply-templates select="." mode="xref_copy">
7573
+ <xsl:with-param name="target" select="$target"/>
7574
+ </xsl:apply-templates>
7575
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
7576
+ </xsl:otherwise>
7577
+ </xsl:choose>
7578
+ </xsl:when>
7579
+ <xsl:when test="self::* and local-name(.) = 'ul'">
7580
+ <!-- ul -->
7581
+ <xsl:apply-templates select="." mode="index_update"/>
7582
+ </xsl:when>
7583
+ <xsl:otherwise>
7584
+ <xsl:apply-templates select="." mode="xref_copy">
7585
+ <xsl:with-param name="target" select="$target"/>
7586
+ </xsl:apply-templates>
7587
+ <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/>
7588
+ </xsl:otherwise>
7589
+ </xsl:choose>
7590
+ </xsl:template><xsl:template match="@*|node()" mode="xref_copy">
7591
+ <xsl:param name="target"/>
7592
+ <xsl:copy>
7593
+ <xsl:apply-templates select="@*" mode="xref_copy"/>
7594
+ <xsl:if test="$target != '' and not(xalan:nodeset($bookmark_in_fn)//bookmark[. = $target])">
7595
+ <xsl:attribute name="target"><xsl:value-of select="$target"/></xsl:attribute>
7596
+ </xsl:if>
7597
+ <xsl:apply-templates select="node()" mode="xref_copy"/>
7598
+ </xsl:copy>
7599
+ </xsl:template><xsl:template name="generateIndexXrefId">
7600
+ <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
7601
+
7602
+ <xsl:variable name="docid">
7603
+ <xsl:call-template name="getDocumentId"/>
7604
+ </xsl:variable>
7605
+ <xsl:variable name="item_number">
7606
+ <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
7607
+ </xsl:variable>
7608
+ <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
7609
+ <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
7610
+ </xsl:template><xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'clause']" priority="4">
7611
+ <xsl:apply-templates/>
7612
+ <fo:block>
7613
+ <xsl:if test="following-sibling::*[local-name() = 'clause']">
7614
+ <fo:block> </fo:block>
7615
+ </xsl:if>
7616
+ </fo:block>
7617
+ </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'ul']" priority="4">
7618
+ <xsl:apply-templates/>
7619
+ </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']" priority="4">
7620
+ <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
7621
+ <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
7622
+ <xsl:apply-templates/>
7623
+ </fo:block>
7624
+ </xsl:template><xsl:template match="*[local-name() = 'bookmark']">
7625
+ <fo:inline id="{@id}"/>
7584
7626
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7585
7627
  <!-- <row>
7586
7628
  <date>05-07-2013</date>
@@ -7825,70 +7867,68 @@
7825
7867
  <xsl:variable name="lang">
7826
7868
  <xsl:call-template name="getLang"/>
7827
7869
  </xsl:variable>
7828
- <fo:declarations>
7829
- <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
7830
- <pdf:dictionary type="normal" key="ViewerPreferences">
7831
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
7832
- </pdf:dictionary>
7833
- </pdf:catalog>
7834
- <x:xmpmeta xmlns:x="adobe:ns:meta/">
7835
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
7836
- <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
7837
- <!-- Dublin Core properties go here -->
7838
- <dc:title>
7839
- <xsl:variable name="title">
7840
- <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
7841
-
7842
-
7843
- <xsl:value-of select="*[local-name() = 'title'][@language = $lang and @type = 'main']"/>
7844
-
7845
-
7846
-
7847
-
7848
-
7849
- </xsl:for-each>
7850
- </xsl:variable>
7851
- <xsl:choose>
7852
- <xsl:when test="normalize-space($title) != ''">
7853
- <xsl:value-of select="$title"/>
7854
- </xsl:when>
7855
- <xsl:otherwise>
7856
- <xsl:text> </xsl:text>
7857
- </xsl:otherwise>
7858
- </xsl:choose>
7859
- </dc:title>
7860
- <dc:creator>
7870
+ <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
7871
+ <pdf:dictionary type="normal" key="ViewerPreferences">
7872
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
7873
+ </pdf:dictionary>
7874
+ </pdf:catalog>
7875
+ <x:xmpmeta xmlns:x="adobe:ns:meta/">
7876
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
7877
+ <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
7878
+ <!-- Dublin Core properties go here -->
7879
+ <dc:title>
7880
+ <xsl:variable name="title">
7861
7881
  <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
7862
7882
 
7863
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']">
7864
- <xsl:value-of select="*[local-name() = 'organization']/*[local-name() = 'name']"/>
7865
- <xsl:if test="position() != last()">; </xsl:if>
7866
- </xsl:for-each>
7867
-
7868
7883
 
7884
+ <xsl:value-of select="*[local-name() = 'title'][@language = $lang and @type = 'main']"/>
7869
7885
 
7870
- </xsl:for-each>
7871
- </dc:creator>
7872
- <dc:description>
7873
- <xsl:variable name="abstract">
7874
7886
 
7875
- <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*[local-name() = 'abstract']//text()"/>
7876
7887
 
7877
7888
 
7878
- </xsl:variable>
7879
- <xsl:value-of select="normalize-space($abstract)"/>
7880
- </dc:description>
7881
- <pdf:Keywords>
7882
- <xsl:call-template name="insertKeywords"/>
7883
- </pdf:Keywords>
7884
- </rdf:Description>
7885
- <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="">
7886
- <!-- XMP properties go here -->
7887
- <xmp:CreatorTool/>
7888
- </rdf:Description>
7889
- </rdf:RDF>
7890
- </x:xmpmeta>
7891
- </fo:declarations>
7889
+
7890
+ </xsl:for-each>
7891
+ </xsl:variable>
7892
+ <xsl:choose>
7893
+ <xsl:when test="normalize-space($title) != ''">
7894
+ <xsl:value-of select="$title"/>
7895
+ </xsl:when>
7896
+ <xsl:otherwise>
7897
+ <xsl:text> </xsl:text>
7898
+ </xsl:otherwise>
7899
+ </xsl:choose>
7900
+ </dc:title>
7901
+ <dc:creator>
7902
+ <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
7903
+
7904
+ <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']">
7905
+ <xsl:value-of select="*[local-name() = 'organization']/*[local-name() = 'name']"/>
7906
+ <xsl:if test="position() != last()">; </xsl:if>
7907
+ </xsl:for-each>
7908
+
7909
+
7910
+
7911
+ </xsl:for-each>
7912
+ </dc:creator>
7913
+ <dc:description>
7914
+ <xsl:variable name="abstract">
7915
+
7916
+ <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*[local-name() = 'abstract']//text()"/>
7917
+
7918
+
7919
+ </xsl:variable>
7920
+ <xsl:value-of select="normalize-space($abstract)"/>
7921
+ </dc:description>
7922
+ <pdf:Keywords>
7923
+ <xsl:call-template name="insertKeywords"/>
7924
+ </pdf:Keywords>
7925
+ </rdf:Description>
7926
+ <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="">
7927
+ <!-- XMP properties go here -->
7928
+ <xmp:CreatorTool/>
7929
+ </rdf:Description>
7930
+ </rdf:RDF>
7931
+ </x:xmpmeta>
7892
7932
  </xsl:template><xsl:template name="getId">
7893
7933
  <xsl:choose>
7894
7934
  <xsl:when test="../@id">