metanorma-itu 2.1.8.1 → 2.1.9

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: cc3399686f48e214718550368bb135a0bd7610505b58dd718302e6b102f3481f
4
- data.tar.gz: ef00c2d8b32c81a5dff7b0e064dbfca1a39e5ce231349d58ed1dfff9b9260ec2
3
+ metadata.gz: 7f72fef8d6e3a4fcaab329f7c4af6243e9b311c3b7f33fd99c35be35916faac6
4
+ data.tar.gz: 5d3d9a69cb643e04e4d65086d20a445fa3cc37af6b214bbbc3e64665a90c16f1
5
5
  SHA512:
6
- metadata.gz: f0b46736932f751c01a8f81752eaec3a1369fef503364745467eb434df221a022697e83b9b5aa4218d66b81f539803fa17d0303331c4241a79591504f3ef6e5c
7
- data.tar.gz: 731eab3ba5a12e8fac1c0b1d84dcdb7810a92ea450151578c6acf089330b0256951763633c190a64301bbbaa483c993ab6565fc330718f4544f9f06318368f56
6
+ metadata.gz: 882e426a2baf071bf46e8e432d41fc8e914d80e6aebbd2dd7b0c000453629d171b8b74ac0f94541b14948ffd16033af282f0a1d0f20cccb1a84049c1055aa315
7
+ data.tar.gz: e69929e2e5434ad6a1eb741a067fb3653dae77de44f657b00b5a13d501657455829649cac8d3f889c6645a0ebd3be632354b5a9931a116fa6f9a3b575009a13c
@@ -6,8 +6,8 @@ require_relative "i18n"
6
6
  module IsoDoc
7
7
  module ITU
8
8
  module Init
9
- def metadata_init(lang, script, i18n)
10
- @meta = Metadata.new(lang, script, i18n)
9
+ def metadata_init(lang, script, locale, i18n)
10
+ @meta = Metadata.new(lang, script, locale, i18n)
11
11
  end
12
12
 
13
13
  def xref_init(lang, script, _klass, i18n, options)
@@ -16,8 +16,9 @@ module IsoDoc
16
16
  @xrefs = Xref.new(lang, script, html, i18n, options)
17
17
  end
18
18
 
19
- def i18n_init(lang, script, i18nyaml = nil)
20
- @i18n = I18n.new(lang, script, i18nyaml: i18nyaml || @i18nyaml)
19
+ def i18n_init(lang, script, locale, i18nyaml = nil)
20
+ @i18n = I18n.new(lang, script, locale: locale,
21
+ i18nyaml: i18nyaml || @i18nyaml)
21
22
  end
22
23
 
23
24
  def fileloc(loc)
@@ -7907,6 +7907,18 @@
7907
7907
  </xsl:copy>
7908
7908
  </xsl:template>
7909
7909
 
7910
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7911
+ <xsl:copy>
7912
+ <xsl:apply-templates mode="contents_item"/>
7913
+ </xsl:copy>
7914
+ </xsl:template>
7915
+
7916
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7917
+ <xsl:copy>
7918
+ <xsl:apply-templates mode="contents_item"/>
7919
+ </xsl:copy>
7920
+ </xsl:template>
7921
+
7910
7922
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7911
7923
  <xsl:copy-of select="."/>
7912
7924
  </xsl:template>
@@ -9358,21 +9370,29 @@
9358
9370
  </xsl:variable>
9359
9371
 
9360
9372
  <xsl:template match="@*|node()" mode="index_add_id">
9373
+ <xsl:param name="docid"/>
9361
9374
  <xsl:copy>
9362
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
9375
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
9376
+ <xsl:with-param name="docid" select="$docid"/>
9377
+ </xsl:apply-templates>
9363
9378
  </xsl:copy>
9364
9379
  </xsl:template>
9365
9380
 
9366
9381
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
9382
+ <xsl:param name="docid"/>
9367
9383
  <xsl:variable name="id">
9368
- <xsl:call-template name="generateIndexXrefId"/>
9384
+ <xsl:call-template name="generateIndexXrefId">
9385
+ <xsl:with-param name="docid" select="$docid"/>
9386
+ </xsl:call-template>
9369
9387
  </xsl:variable>
9370
9388
  <xsl:copy> <!-- add id to xref -->
9371
9389
  <xsl:apply-templates select="@*" mode="index_add_id"/>
9372
9390
  <xsl:attribute name="id">
9373
9391
  <xsl:value-of select="$id"/>
9374
9392
  </xsl:attribute>
9375
- <xsl:apply-templates mode="index_add_id"/>
9393
+ <xsl:apply-templates mode="index_add_id">
9394
+ <xsl:with-param name="docid" select="$docid"/>
9395
+ </xsl:apply-templates>
9376
9396
  </xsl:copy>
9377
9397
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
9378
9398
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -9384,7 +9404,9 @@
9384
9404
  <xsl:attribute name="id">
9385
9405
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
9386
9406
  </xsl:attribute>
9387
- <xsl:apply-templates mode="index_add_id"/>
9407
+ <xsl:apply-templates mode="index_add_id">
9408
+ <xsl:with-param name="docid" select="$docid"/>
9409
+ </xsl:apply-templates>
9388
9410
  </xsl:copy>
9389
9411
  </xsl:if>
9390
9412
  </xsl:template>
@@ -9421,12 +9443,33 @@
9421
9443
  </xsl:when>
9422
9444
  <xsl:when test="self::* and local-name(.) = 'xref'">
9423
9445
  <xsl:variable name="id" select="@id"/>
9424
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
9425
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9426
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
9427
9446
 
9447
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9428
9448
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
9429
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
9449
+
9450
+ <xsl:variable name="pages_">
9451
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
9452
+ <xsl:choose>
9453
+ <xsl:when test="@id = $id">
9454
+ <page><xsl:value-of select="."/></page>
9455
+ </xsl:when>
9456
+ <xsl:when test="@id = $id_next">
9457
+ <page_next><xsl:value-of select="."/></page_next>
9458
+ </xsl:when>
9459
+ <xsl:when test="@id = $id_prev">
9460
+ <page_prev><xsl:value-of select="."/></page_prev>
9461
+ </xsl:when>
9462
+ </xsl:choose>
9463
+ </xsl:for-each>
9464
+ </xsl:variable>
9465
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
9466
+
9467
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
9468
+ <xsl:variable name="page" select="$pages/page"/>
9469
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
9470
+ <xsl:variable name="page_next" select="$pages/page_next"/>
9471
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
9472
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
9430
9473
 
9431
9474
  <xsl:choose>
9432
9475
  <!-- 2nd pass -->
@@ -9486,16 +9529,20 @@
9486
9529
  </xsl:template>
9487
9530
 
9488
9531
  <xsl:template name="generateIndexXrefId">
9532
+ <xsl:param name="docid"/>
9533
+
9489
9534
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9490
9535
 
9491
- <xsl:variable name="docid">
9492
- <xsl:call-template name="getDocumentId"/>
9536
+ <xsl:variable name="docid_curr">
9537
+ <xsl:value-of select="$docid"/>
9538
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9493
9539
  </xsl:variable>
9540
+
9494
9541
  <xsl:variable name="item_number">
9495
9542
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9496
9543
  </xsl:variable>
9497
9544
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9498
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9545
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9499
9546
  </xsl:template>
9500
9547
 
9501
9548
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7907,6 +7907,18 @@
7907
7907
  </xsl:copy>
7908
7908
  </xsl:template>
7909
7909
 
7910
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7911
+ <xsl:copy>
7912
+ <xsl:apply-templates mode="contents_item"/>
7913
+ </xsl:copy>
7914
+ </xsl:template>
7915
+
7916
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7917
+ <xsl:copy>
7918
+ <xsl:apply-templates mode="contents_item"/>
7919
+ </xsl:copy>
7920
+ </xsl:template>
7921
+
7910
7922
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7911
7923
  <xsl:copy-of select="."/>
7912
7924
  </xsl:template>
@@ -9358,21 +9370,29 @@
9358
9370
  </xsl:variable>
9359
9371
 
9360
9372
  <xsl:template match="@*|node()" mode="index_add_id">
9373
+ <xsl:param name="docid"/>
9361
9374
  <xsl:copy>
9362
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
9375
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
9376
+ <xsl:with-param name="docid" select="$docid"/>
9377
+ </xsl:apply-templates>
9363
9378
  </xsl:copy>
9364
9379
  </xsl:template>
9365
9380
 
9366
9381
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
9382
+ <xsl:param name="docid"/>
9367
9383
  <xsl:variable name="id">
9368
- <xsl:call-template name="generateIndexXrefId"/>
9384
+ <xsl:call-template name="generateIndexXrefId">
9385
+ <xsl:with-param name="docid" select="$docid"/>
9386
+ </xsl:call-template>
9369
9387
  </xsl:variable>
9370
9388
  <xsl:copy> <!-- add id to xref -->
9371
9389
  <xsl:apply-templates select="@*" mode="index_add_id"/>
9372
9390
  <xsl:attribute name="id">
9373
9391
  <xsl:value-of select="$id"/>
9374
9392
  </xsl:attribute>
9375
- <xsl:apply-templates mode="index_add_id"/>
9393
+ <xsl:apply-templates mode="index_add_id">
9394
+ <xsl:with-param name="docid" select="$docid"/>
9395
+ </xsl:apply-templates>
9376
9396
  </xsl:copy>
9377
9397
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
9378
9398
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -9384,7 +9404,9 @@
9384
9404
  <xsl:attribute name="id">
9385
9405
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
9386
9406
  </xsl:attribute>
9387
- <xsl:apply-templates mode="index_add_id"/>
9407
+ <xsl:apply-templates mode="index_add_id">
9408
+ <xsl:with-param name="docid" select="$docid"/>
9409
+ </xsl:apply-templates>
9388
9410
  </xsl:copy>
9389
9411
  </xsl:if>
9390
9412
  </xsl:template>
@@ -9421,12 +9443,33 @@
9421
9443
  </xsl:when>
9422
9444
  <xsl:when test="self::* and local-name(.) = 'xref'">
9423
9445
  <xsl:variable name="id" select="@id"/>
9424
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
9425
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9426
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
9427
9446
 
9447
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9428
9448
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
9429
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
9449
+
9450
+ <xsl:variable name="pages_">
9451
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
9452
+ <xsl:choose>
9453
+ <xsl:when test="@id = $id">
9454
+ <page><xsl:value-of select="."/></page>
9455
+ </xsl:when>
9456
+ <xsl:when test="@id = $id_next">
9457
+ <page_next><xsl:value-of select="."/></page_next>
9458
+ </xsl:when>
9459
+ <xsl:when test="@id = $id_prev">
9460
+ <page_prev><xsl:value-of select="."/></page_prev>
9461
+ </xsl:when>
9462
+ </xsl:choose>
9463
+ </xsl:for-each>
9464
+ </xsl:variable>
9465
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
9466
+
9467
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
9468
+ <xsl:variable name="page" select="$pages/page"/>
9469
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
9470
+ <xsl:variable name="page_next" select="$pages/page_next"/>
9471
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
9472
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
9430
9473
 
9431
9474
  <xsl:choose>
9432
9475
  <!-- 2nd pass -->
@@ -9486,16 +9529,20 @@
9486
9529
  </xsl:template>
9487
9530
 
9488
9531
  <xsl:template name="generateIndexXrefId">
9532
+ <xsl:param name="docid"/>
9533
+
9489
9534
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9490
9535
 
9491
- <xsl:variable name="docid">
9492
- <xsl:call-template name="getDocumentId"/>
9536
+ <xsl:variable name="docid_curr">
9537
+ <xsl:value-of select="$docid"/>
9538
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9493
9539
  </xsl:variable>
9540
+
9494
9541
  <xsl:variable name="item_number">
9495
9542
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9496
9543
  </xsl:variable>
9497
9544
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9498
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9545
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9499
9546
  </xsl:template>
9500
9547
 
9501
9548
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7907,6 +7907,18 @@
7907
7907
  </xsl:copy>
7908
7908
  </xsl:template>
7909
7909
 
7910
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7911
+ <xsl:copy>
7912
+ <xsl:apply-templates mode="contents_item"/>
7913
+ </xsl:copy>
7914
+ </xsl:template>
7915
+
7916
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7917
+ <xsl:copy>
7918
+ <xsl:apply-templates mode="contents_item"/>
7919
+ </xsl:copy>
7920
+ </xsl:template>
7921
+
7910
7922
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7911
7923
  <xsl:copy-of select="."/>
7912
7924
  </xsl:template>
@@ -9358,21 +9370,29 @@
9358
9370
  </xsl:variable>
9359
9371
 
9360
9372
  <xsl:template match="@*|node()" mode="index_add_id">
9373
+ <xsl:param name="docid"/>
9361
9374
  <xsl:copy>
9362
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
9375
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
9376
+ <xsl:with-param name="docid" select="$docid"/>
9377
+ </xsl:apply-templates>
9363
9378
  </xsl:copy>
9364
9379
  </xsl:template>
9365
9380
 
9366
9381
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
9382
+ <xsl:param name="docid"/>
9367
9383
  <xsl:variable name="id">
9368
- <xsl:call-template name="generateIndexXrefId"/>
9384
+ <xsl:call-template name="generateIndexXrefId">
9385
+ <xsl:with-param name="docid" select="$docid"/>
9386
+ </xsl:call-template>
9369
9387
  </xsl:variable>
9370
9388
  <xsl:copy> <!-- add id to xref -->
9371
9389
  <xsl:apply-templates select="@*" mode="index_add_id"/>
9372
9390
  <xsl:attribute name="id">
9373
9391
  <xsl:value-of select="$id"/>
9374
9392
  </xsl:attribute>
9375
- <xsl:apply-templates mode="index_add_id"/>
9393
+ <xsl:apply-templates mode="index_add_id">
9394
+ <xsl:with-param name="docid" select="$docid"/>
9395
+ </xsl:apply-templates>
9376
9396
  </xsl:copy>
9377
9397
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
9378
9398
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -9384,7 +9404,9 @@
9384
9404
  <xsl:attribute name="id">
9385
9405
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
9386
9406
  </xsl:attribute>
9387
- <xsl:apply-templates mode="index_add_id"/>
9407
+ <xsl:apply-templates mode="index_add_id">
9408
+ <xsl:with-param name="docid" select="$docid"/>
9409
+ </xsl:apply-templates>
9388
9410
  </xsl:copy>
9389
9411
  </xsl:if>
9390
9412
  </xsl:template>
@@ -9421,12 +9443,33 @@
9421
9443
  </xsl:when>
9422
9444
  <xsl:when test="self::* and local-name(.) = 'xref'">
9423
9445
  <xsl:variable name="id" select="@id"/>
9424
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
9425
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9426
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
9427
9446
 
9447
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9428
9448
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
9429
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
9449
+
9450
+ <xsl:variable name="pages_">
9451
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
9452
+ <xsl:choose>
9453
+ <xsl:when test="@id = $id">
9454
+ <page><xsl:value-of select="."/></page>
9455
+ </xsl:when>
9456
+ <xsl:when test="@id = $id_next">
9457
+ <page_next><xsl:value-of select="."/></page_next>
9458
+ </xsl:when>
9459
+ <xsl:when test="@id = $id_prev">
9460
+ <page_prev><xsl:value-of select="."/></page_prev>
9461
+ </xsl:when>
9462
+ </xsl:choose>
9463
+ </xsl:for-each>
9464
+ </xsl:variable>
9465
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
9466
+
9467
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
9468
+ <xsl:variable name="page" select="$pages/page"/>
9469
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
9470
+ <xsl:variable name="page_next" select="$pages/page_next"/>
9471
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
9472
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
9430
9473
 
9431
9474
  <xsl:choose>
9432
9475
  <!-- 2nd pass -->
@@ -9486,16 +9529,20 @@
9486
9529
  </xsl:template>
9487
9530
 
9488
9531
  <xsl:template name="generateIndexXrefId">
9532
+ <xsl:param name="docid"/>
9533
+
9489
9534
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9490
9535
 
9491
- <xsl:variable name="docid">
9492
- <xsl:call-template name="getDocumentId"/>
9536
+ <xsl:variable name="docid_curr">
9537
+ <xsl:value-of select="$docid"/>
9538
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9493
9539
  </xsl:variable>
9540
+
9494
9541
  <xsl:variable name="item_number">
9495
9542
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9496
9543
  </xsl:variable>
9497
9544
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9498
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9545
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9499
9546
  </xsl:template>
9500
9547
 
9501
9548
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7907,6 +7907,18 @@
7907
7907
  </xsl:copy>
7908
7908
  </xsl:template>
7909
7909
 
7910
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7911
+ <xsl:copy>
7912
+ <xsl:apply-templates mode="contents_item"/>
7913
+ </xsl:copy>
7914
+ </xsl:template>
7915
+
7916
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7917
+ <xsl:copy>
7918
+ <xsl:apply-templates mode="contents_item"/>
7919
+ </xsl:copy>
7920
+ </xsl:template>
7921
+
7910
7922
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7911
7923
  <xsl:copy-of select="."/>
7912
7924
  </xsl:template>
@@ -9358,21 +9370,29 @@
9358
9370
  </xsl:variable>
9359
9371
 
9360
9372
  <xsl:template match="@*|node()" mode="index_add_id">
9373
+ <xsl:param name="docid"/>
9361
9374
  <xsl:copy>
9362
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
9375
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
9376
+ <xsl:with-param name="docid" select="$docid"/>
9377
+ </xsl:apply-templates>
9363
9378
  </xsl:copy>
9364
9379
  </xsl:template>
9365
9380
 
9366
9381
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
9382
+ <xsl:param name="docid"/>
9367
9383
  <xsl:variable name="id">
9368
- <xsl:call-template name="generateIndexXrefId"/>
9384
+ <xsl:call-template name="generateIndexXrefId">
9385
+ <xsl:with-param name="docid" select="$docid"/>
9386
+ </xsl:call-template>
9369
9387
  </xsl:variable>
9370
9388
  <xsl:copy> <!-- add id to xref -->
9371
9389
  <xsl:apply-templates select="@*" mode="index_add_id"/>
9372
9390
  <xsl:attribute name="id">
9373
9391
  <xsl:value-of select="$id"/>
9374
9392
  </xsl:attribute>
9375
- <xsl:apply-templates mode="index_add_id"/>
9393
+ <xsl:apply-templates mode="index_add_id">
9394
+ <xsl:with-param name="docid" select="$docid"/>
9395
+ </xsl:apply-templates>
9376
9396
  </xsl:copy>
9377
9397
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
9378
9398
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -9384,7 +9404,9 @@
9384
9404
  <xsl:attribute name="id">
9385
9405
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
9386
9406
  </xsl:attribute>
9387
- <xsl:apply-templates mode="index_add_id"/>
9407
+ <xsl:apply-templates mode="index_add_id">
9408
+ <xsl:with-param name="docid" select="$docid"/>
9409
+ </xsl:apply-templates>
9388
9410
  </xsl:copy>
9389
9411
  </xsl:if>
9390
9412
  </xsl:template>
@@ -9421,12 +9443,33 @@
9421
9443
  </xsl:when>
9422
9444
  <xsl:when test="self::* and local-name(.) = 'xref'">
9423
9445
  <xsl:variable name="id" select="@id"/>
9424
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
9425
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9426
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
9427
9446
 
9447
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
9428
9448
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
9429
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
9449
+
9450
+ <xsl:variable name="pages_">
9451
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
9452
+ <xsl:choose>
9453
+ <xsl:when test="@id = $id">
9454
+ <page><xsl:value-of select="."/></page>
9455
+ </xsl:when>
9456
+ <xsl:when test="@id = $id_next">
9457
+ <page_next><xsl:value-of select="."/></page_next>
9458
+ </xsl:when>
9459
+ <xsl:when test="@id = $id_prev">
9460
+ <page_prev><xsl:value-of select="."/></page_prev>
9461
+ </xsl:when>
9462
+ </xsl:choose>
9463
+ </xsl:for-each>
9464
+ </xsl:variable>
9465
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
9466
+
9467
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
9468
+ <xsl:variable name="page" select="$pages/page"/>
9469
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
9470
+ <xsl:variable name="page_next" select="$pages/page_next"/>
9471
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
9472
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
9430
9473
 
9431
9474
  <xsl:choose>
9432
9475
  <!-- 2nd pass -->
@@ -9486,16 +9529,20 @@
9486
9529
  </xsl:template>
9487
9530
 
9488
9531
  <xsl:template name="generateIndexXrefId">
9532
+ <xsl:param name="docid"/>
9533
+
9489
9534
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9490
9535
 
9491
- <xsl:variable name="docid">
9492
- <xsl:call-template name="getDocumentId"/>
9536
+ <xsl:variable name="docid_curr">
9537
+ <xsl:value-of select="$docid"/>
9538
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9493
9539
  </xsl:variable>
9540
+
9494
9541
  <xsl:variable name="item_number">
9495
9542
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9496
9543
  </xsl:variable>
9497
9544
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9498
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9545
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9499
9546
  </xsl:template>
9500
9547
 
9501
9548
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">