metanorma-ogc 2.2.2.1 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7392,6 +7392,18 @@
7392
7392
  </xsl:copy>
7393
7393
  </xsl:template>
7394
7394
 
7395
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7396
+ <xsl:copy>
7397
+ <xsl:apply-templates mode="contents_item"/>
7398
+ </xsl:copy>
7399
+ </xsl:template>
7400
+
7401
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7402
+ <xsl:copy>
7403
+ <xsl:apply-templates mode="contents_item"/>
7404
+ </xsl:copy>
7405
+ </xsl:template>
7406
+
7395
7407
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7396
7408
  <xsl:copy-of select="."/>
7397
7409
  </xsl:template>
@@ -8372,7 +8384,7 @@
8372
8384
  <!-- ====== -->
8373
8385
  <!-- eref -->
8374
8386
  <!-- ====== -->
8375
- <xsl:template match="*[local-name() = 'eref']">
8387
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
8376
8388
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
8377
8389
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
8378
8390
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -8874,21 +8886,29 @@
8874
8886
  </xsl:variable>
8875
8887
 
8876
8888
  <xsl:template match="@*|node()" mode="index_add_id">
8889
+ <xsl:param name="docid"/>
8877
8890
  <xsl:copy>
8878
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
8891
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
8892
+ <xsl:with-param name="docid" select="$docid"/>
8893
+ </xsl:apply-templates>
8879
8894
  </xsl:copy>
8880
8895
  </xsl:template>
8881
8896
 
8882
8897
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
8898
+ <xsl:param name="docid"/>
8883
8899
  <xsl:variable name="id">
8884
- <xsl:call-template name="generateIndexXrefId"/>
8900
+ <xsl:call-template name="generateIndexXrefId">
8901
+ <xsl:with-param name="docid" select="$docid"/>
8902
+ </xsl:call-template>
8885
8903
  </xsl:variable>
8886
8904
  <xsl:copy> <!-- add id to xref -->
8887
8905
  <xsl:apply-templates select="@*" mode="index_add_id"/>
8888
8906
  <xsl:attribute name="id">
8889
8907
  <xsl:value-of select="$id"/>
8890
8908
  </xsl:attribute>
8891
- <xsl:apply-templates mode="index_add_id"/>
8909
+ <xsl:apply-templates mode="index_add_id">
8910
+ <xsl:with-param name="docid" select="$docid"/>
8911
+ </xsl:apply-templates>
8892
8912
  </xsl:copy>
8893
8913
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
8894
8914
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -8900,7 +8920,9 @@
8900
8920
  <xsl:attribute name="id">
8901
8921
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
8902
8922
  </xsl:attribute>
8903
- <xsl:apply-templates mode="index_add_id"/>
8923
+ <xsl:apply-templates mode="index_add_id">
8924
+ <xsl:with-param name="docid" select="$docid"/>
8925
+ </xsl:apply-templates>
8904
8926
  </xsl:copy>
8905
8927
  </xsl:if>
8906
8928
  </xsl:template>
@@ -8937,12 +8959,33 @@
8937
8959
  </xsl:when>
8938
8960
  <xsl:when test="self::* and local-name(.) = 'xref'">
8939
8961
  <xsl:variable name="id" select="@id"/>
8940
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
8941
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8942
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
8943
8962
 
8963
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8944
8964
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
8945
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
8965
+
8966
+ <xsl:variable name="pages_">
8967
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
8968
+ <xsl:choose>
8969
+ <xsl:when test="@id = $id">
8970
+ <page><xsl:value-of select="."/></page>
8971
+ </xsl:when>
8972
+ <xsl:when test="@id = $id_next">
8973
+ <page_next><xsl:value-of select="."/></page_next>
8974
+ </xsl:when>
8975
+ <xsl:when test="@id = $id_prev">
8976
+ <page_prev><xsl:value-of select="."/></page_prev>
8977
+ </xsl:when>
8978
+ </xsl:choose>
8979
+ </xsl:for-each>
8980
+ </xsl:variable>
8981
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
8982
+
8983
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
8984
+ <xsl:variable name="page" select="$pages/page"/>
8985
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
8986
+ <xsl:variable name="page_next" select="$pages/page_next"/>
8987
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
8988
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
8946
8989
 
8947
8990
  <xsl:choose>
8948
8991
  <!-- 2nd pass -->
@@ -9002,16 +9045,20 @@
9002
9045
  </xsl:template>
9003
9046
 
9004
9047
  <xsl:template name="generateIndexXrefId">
9048
+ <xsl:param name="docid"/>
9049
+
9005
9050
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9006
9051
 
9007
- <xsl:variable name="docid">
9008
- <xsl:call-template name="getDocumentId"/>
9052
+ <xsl:variable name="docid_curr">
9053
+ <xsl:value-of select="$docid"/>
9054
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9009
9055
  </xsl:variable>
9056
+
9010
9057
  <xsl:variable name="item_number">
9011
9058
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9012
9059
  </xsl:variable>
9013
9060
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9014
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9061
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9015
9062
  </xsl:template>
9016
9063
 
9017
9064
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7392,6 +7392,18 @@
7392
7392
  </xsl:copy>
7393
7393
  </xsl:template>
7394
7394
 
7395
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7396
+ <xsl:copy>
7397
+ <xsl:apply-templates mode="contents_item"/>
7398
+ </xsl:copy>
7399
+ </xsl:template>
7400
+
7401
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7402
+ <xsl:copy>
7403
+ <xsl:apply-templates mode="contents_item"/>
7404
+ </xsl:copy>
7405
+ </xsl:template>
7406
+
7395
7407
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7396
7408
  <xsl:copy-of select="."/>
7397
7409
  </xsl:template>
@@ -8372,7 +8384,7 @@
8372
8384
  <!-- ====== -->
8373
8385
  <!-- eref -->
8374
8386
  <!-- ====== -->
8375
- <xsl:template match="*[local-name() = 'eref']">
8387
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
8376
8388
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
8377
8389
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
8378
8390
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -8874,21 +8886,29 @@
8874
8886
  </xsl:variable>
8875
8887
 
8876
8888
  <xsl:template match="@*|node()" mode="index_add_id">
8889
+ <xsl:param name="docid"/>
8877
8890
  <xsl:copy>
8878
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
8891
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
8892
+ <xsl:with-param name="docid" select="$docid"/>
8893
+ </xsl:apply-templates>
8879
8894
  </xsl:copy>
8880
8895
  </xsl:template>
8881
8896
 
8882
8897
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
8898
+ <xsl:param name="docid"/>
8883
8899
  <xsl:variable name="id">
8884
- <xsl:call-template name="generateIndexXrefId"/>
8900
+ <xsl:call-template name="generateIndexXrefId">
8901
+ <xsl:with-param name="docid" select="$docid"/>
8902
+ </xsl:call-template>
8885
8903
  </xsl:variable>
8886
8904
  <xsl:copy> <!-- add id to xref -->
8887
8905
  <xsl:apply-templates select="@*" mode="index_add_id"/>
8888
8906
  <xsl:attribute name="id">
8889
8907
  <xsl:value-of select="$id"/>
8890
8908
  </xsl:attribute>
8891
- <xsl:apply-templates mode="index_add_id"/>
8909
+ <xsl:apply-templates mode="index_add_id">
8910
+ <xsl:with-param name="docid" select="$docid"/>
8911
+ </xsl:apply-templates>
8892
8912
  </xsl:copy>
8893
8913
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
8894
8914
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -8900,7 +8920,9 @@
8900
8920
  <xsl:attribute name="id">
8901
8921
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
8902
8922
  </xsl:attribute>
8903
- <xsl:apply-templates mode="index_add_id"/>
8923
+ <xsl:apply-templates mode="index_add_id">
8924
+ <xsl:with-param name="docid" select="$docid"/>
8925
+ </xsl:apply-templates>
8904
8926
  </xsl:copy>
8905
8927
  </xsl:if>
8906
8928
  </xsl:template>
@@ -8937,12 +8959,33 @@
8937
8959
  </xsl:when>
8938
8960
  <xsl:when test="self::* and local-name(.) = 'xref'">
8939
8961
  <xsl:variable name="id" select="@id"/>
8940
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
8941
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8942
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
8943
8962
 
8963
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8944
8964
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
8945
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
8965
+
8966
+ <xsl:variable name="pages_">
8967
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
8968
+ <xsl:choose>
8969
+ <xsl:when test="@id = $id">
8970
+ <page><xsl:value-of select="."/></page>
8971
+ </xsl:when>
8972
+ <xsl:when test="@id = $id_next">
8973
+ <page_next><xsl:value-of select="."/></page_next>
8974
+ </xsl:when>
8975
+ <xsl:when test="@id = $id_prev">
8976
+ <page_prev><xsl:value-of select="."/></page_prev>
8977
+ </xsl:when>
8978
+ </xsl:choose>
8979
+ </xsl:for-each>
8980
+ </xsl:variable>
8981
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
8982
+
8983
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
8984
+ <xsl:variable name="page" select="$pages/page"/>
8985
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
8986
+ <xsl:variable name="page_next" select="$pages/page_next"/>
8987
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
8988
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
8946
8989
 
8947
8990
  <xsl:choose>
8948
8991
  <!-- 2nd pass -->
@@ -9002,16 +9045,20 @@
9002
9045
  </xsl:template>
9003
9046
 
9004
9047
  <xsl:template name="generateIndexXrefId">
9048
+ <xsl:param name="docid"/>
9049
+
9005
9050
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9006
9051
 
9007
- <xsl:variable name="docid">
9008
- <xsl:call-template name="getDocumentId"/>
9052
+ <xsl:variable name="docid_curr">
9053
+ <xsl:value-of select="$docid"/>
9054
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9009
9055
  </xsl:variable>
9056
+
9010
9057
  <xsl:variable name="item_number">
9011
9058
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9012
9059
  </xsl:variable>
9013
9060
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9014
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9061
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9015
9062
  </xsl:template>
9016
9063
 
9017
9064
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7392,6 +7392,18 @@
7392
7392
  </xsl:copy>
7393
7393
  </xsl:template>
7394
7394
 
7395
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7396
+ <xsl:copy>
7397
+ <xsl:apply-templates mode="contents_item"/>
7398
+ </xsl:copy>
7399
+ </xsl:template>
7400
+
7401
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7402
+ <xsl:copy>
7403
+ <xsl:apply-templates mode="contents_item"/>
7404
+ </xsl:copy>
7405
+ </xsl:template>
7406
+
7395
7407
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7396
7408
  <xsl:copy-of select="."/>
7397
7409
  </xsl:template>
@@ -8372,7 +8384,7 @@
8372
8384
  <!-- ====== -->
8373
8385
  <!-- eref -->
8374
8386
  <!-- ====== -->
8375
- <xsl:template match="*[local-name() = 'eref']">
8387
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
8376
8388
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
8377
8389
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
8378
8390
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -8874,21 +8886,29 @@
8874
8886
  </xsl:variable>
8875
8887
 
8876
8888
  <xsl:template match="@*|node()" mode="index_add_id">
8889
+ <xsl:param name="docid"/>
8877
8890
  <xsl:copy>
8878
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
8891
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
8892
+ <xsl:with-param name="docid" select="$docid"/>
8893
+ </xsl:apply-templates>
8879
8894
  </xsl:copy>
8880
8895
  </xsl:template>
8881
8896
 
8882
8897
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
8898
+ <xsl:param name="docid"/>
8883
8899
  <xsl:variable name="id">
8884
- <xsl:call-template name="generateIndexXrefId"/>
8900
+ <xsl:call-template name="generateIndexXrefId">
8901
+ <xsl:with-param name="docid" select="$docid"/>
8902
+ </xsl:call-template>
8885
8903
  </xsl:variable>
8886
8904
  <xsl:copy> <!-- add id to xref -->
8887
8905
  <xsl:apply-templates select="@*" mode="index_add_id"/>
8888
8906
  <xsl:attribute name="id">
8889
8907
  <xsl:value-of select="$id"/>
8890
8908
  </xsl:attribute>
8891
- <xsl:apply-templates mode="index_add_id"/>
8909
+ <xsl:apply-templates mode="index_add_id">
8910
+ <xsl:with-param name="docid" select="$docid"/>
8911
+ </xsl:apply-templates>
8892
8912
  </xsl:copy>
8893
8913
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
8894
8914
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -8900,7 +8920,9 @@
8900
8920
  <xsl:attribute name="id">
8901
8921
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
8902
8922
  </xsl:attribute>
8903
- <xsl:apply-templates mode="index_add_id"/>
8923
+ <xsl:apply-templates mode="index_add_id">
8924
+ <xsl:with-param name="docid" select="$docid"/>
8925
+ </xsl:apply-templates>
8904
8926
  </xsl:copy>
8905
8927
  </xsl:if>
8906
8928
  </xsl:template>
@@ -8937,12 +8959,33 @@
8937
8959
  </xsl:when>
8938
8960
  <xsl:when test="self::* and local-name(.) = 'xref'">
8939
8961
  <xsl:variable name="id" select="@id"/>
8940
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
8941
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8942
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
8943
8962
 
8963
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8944
8964
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
8945
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
8965
+
8966
+ <xsl:variable name="pages_">
8967
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
8968
+ <xsl:choose>
8969
+ <xsl:when test="@id = $id">
8970
+ <page><xsl:value-of select="."/></page>
8971
+ </xsl:when>
8972
+ <xsl:when test="@id = $id_next">
8973
+ <page_next><xsl:value-of select="."/></page_next>
8974
+ </xsl:when>
8975
+ <xsl:when test="@id = $id_prev">
8976
+ <page_prev><xsl:value-of select="."/></page_prev>
8977
+ </xsl:when>
8978
+ </xsl:choose>
8979
+ </xsl:for-each>
8980
+ </xsl:variable>
8981
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
8982
+
8983
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
8984
+ <xsl:variable name="page" select="$pages/page"/>
8985
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
8986
+ <xsl:variable name="page_next" select="$pages/page_next"/>
8987
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
8988
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
8946
8989
 
8947
8990
  <xsl:choose>
8948
8991
  <!-- 2nd pass -->
@@ -9002,16 +9045,20 @@
9002
9045
  </xsl:template>
9003
9046
 
9004
9047
  <xsl:template name="generateIndexXrefId">
9048
+ <xsl:param name="docid"/>
9049
+
9005
9050
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9006
9051
 
9007
- <xsl:variable name="docid">
9008
- <xsl:call-template name="getDocumentId"/>
9052
+ <xsl:variable name="docid_curr">
9053
+ <xsl:value-of select="$docid"/>
9054
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9009
9055
  </xsl:variable>
9056
+
9010
9057
  <xsl:variable name="item_number">
9011
9058
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9012
9059
  </xsl:variable>
9013
9060
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9014
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9061
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9015
9062
  </xsl:template>
9016
9063
 
9017
9064
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -7392,6 +7392,18 @@
7392
7392
  </xsl:copy>
7393
7393
  </xsl:template>
7394
7394
 
7395
+ <xsl:template match="*[local-name() = 'sub']" mode="contents_item">
7396
+ <xsl:copy>
7397
+ <xsl:apply-templates mode="contents_item"/>
7398
+ </xsl:copy>
7399
+ </xsl:template>
7400
+
7401
+ <xsl:template match="*[local-name() = 'sup']" mode="contents_item">
7402
+ <xsl:copy>
7403
+ <xsl:apply-templates mode="contents_item"/>
7404
+ </xsl:copy>
7405
+ </xsl:template>
7406
+
7395
7407
  <xsl:template match="*[local-name() = 'stem']" mode="contents_item">
7396
7408
  <xsl:copy-of select="."/>
7397
7409
  </xsl:template>
@@ -8372,7 +8384,7 @@
8372
8384
  <!-- ====== -->
8373
8385
  <!-- eref -->
8374
8386
  <!-- ====== -->
8375
- <xsl:template match="*[local-name() = 'eref']">
8387
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
8376
8388
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
8377
8389
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
8378
8390
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -8874,21 +8886,29 @@
8874
8886
  </xsl:variable>
8875
8887
 
8876
8888
  <xsl:template match="@*|node()" mode="index_add_id">
8889
+ <xsl:param name="docid"/>
8877
8890
  <xsl:copy>
8878
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
8891
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
8892
+ <xsl:with-param name="docid" select="$docid"/>
8893
+ </xsl:apply-templates>
8879
8894
  </xsl:copy>
8880
8895
  </xsl:template>
8881
8896
 
8882
8897
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
8898
+ <xsl:param name="docid"/>
8883
8899
  <xsl:variable name="id">
8884
- <xsl:call-template name="generateIndexXrefId"/>
8900
+ <xsl:call-template name="generateIndexXrefId">
8901
+ <xsl:with-param name="docid" select="$docid"/>
8902
+ </xsl:call-template>
8885
8903
  </xsl:variable>
8886
8904
  <xsl:copy> <!-- add id to xref -->
8887
8905
  <xsl:apply-templates select="@*" mode="index_add_id"/>
8888
8906
  <xsl:attribute name="id">
8889
8907
  <xsl:value-of select="$id"/>
8890
8908
  </xsl:attribute>
8891
- <xsl:apply-templates mode="index_add_id"/>
8909
+ <xsl:apply-templates mode="index_add_id">
8910
+ <xsl:with-param name="docid" select="$docid"/>
8911
+ </xsl:apply-templates>
8892
8912
  </xsl:copy>
8893
8913
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
8894
8914
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -8900,7 +8920,9 @@
8900
8920
  <xsl:attribute name="id">
8901
8921
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
8902
8922
  </xsl:attribute>
8903
- <xsl:apply-templates mode="index_add_id"/>
8923
+ <xsl:apply-templates mode="index_add_id">
8924
+ <xsl:with-param name="docid" select="$docid"/>
8925
+ </xsl:apply-templates>
8904
8926
  </xsl:copy>
8905
8927
  </xsl:if>
8906
8928
  </xsl:template>
@@ -8937,12 +8959,33 @@
8937
8959
  </xsl:when>
8938
8960
  <xsl:when test="self::* and local-name(.) = 'xref'">
8939
8961
  <xsl:variable name="id" select="@id"/>
8940
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
8941
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8942
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
8943
8962
 
8963
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
8944
8964
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
8945
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
8965
+
8966
+ <xsl:variable name="pages_">
8967
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
8968
+ <xsl:choose>
8969
+ <xsl:when test="@id = $id">
8970
+ <page><xsl:value-of select="."/></page>
8971
+ </xsl:when>
8972
+ <xsl:when test="@id = $id_next">
8973
+ <page_next><xsl:value-of select="."/></page_next>
8974
+ </xsl:when>
8975
+ <xsl:when test="@id = $id_prev">
8976
+ <page_prev><xsl:value-of select="."/></page_prev>
8977
+ </xsl:when>
8978
+ </xsl:choose>
8979
+ </xsl:for-each>
8980
+ </xsl:variable>
8981
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
8982
+
8983
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
8984
+ <xsl:variable name="page" select="$pages/page"/>
8985
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
8986
+ <xsl:variable name="page_next" select="$pages/page_next"/>
8987
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
8988
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
8946
8989
 
8947
8990
  <xsl:choose>
8948
8991
  <!-- 2nd pass -->
@@ -9002,16 +9045,20 @@
9002
9045
  </xsl:template>
9003
9046
 
9004
9047
  <xsl:template name="generateIndexXrefId">
9048
+ <xsl:param name="docid"/>
9049
+
9005
9050
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
9006
9051
 
9007
- <xsl:variable name="docid">
9008
- <xsl:call-template name="getDocumentId"/>
9052
+ <xsl:variable name="docid_curr">
9053
+ <xsl:value-of select="$docid"/>
9054
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
9009
9055
  </xsl:variable>
9056
+
9010
9057
  <xsl:variable name="item_number">
9011
9058
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
9012
9059
  </xsl:variable>
9013
9060
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
9014
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9061
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
9015
9062
  </xsl:template>
9016
9063
 
9017
9064
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">