lib/isodoc/iho/iho.specification.xsl in metanorma-iho-0.6.9 vs lib/isodoc/iho/iho.specification.xsl in metanorma-iho-0.6.10

- old
+ new

@@ -7511,11 +7511,11 @@ </xsl:variable> <xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/> <!-- ====== --> <!-- eref --> <!-- ====== --> - <xsl:template match="*[local-name() = 'eref']"> + <xsl:template match="*[local-name() = 'eref']" name="eref"> <xsl:variable name="current_bibitemid" select="@bibitemid"/> <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> --> <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/> <xsl:choose> <!-- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> --> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) --> @@ -8004,25 +8004,33 @@ <bookmark><xsl:value-of select="@id"/></bookmark> </xsl:for-each> </xsl:variable> <xsl:template match="@*|node()" mode="index_add_id"> + <xsl:param name="docid"/> <xsl:copy> - <xsl:apply-templates select="@*|node()" mode="index_add_id"/> + <xsl:apply-templates select="@*|node()" mode="index_add_id"> + <xsl:with-param name="docid" select="$docid"/> + </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="*[local-name() = 'xref']" mode="index_add_id"> + <xsl:param name="docid"/> <xsl:variable name="id"> - <xsl:call-template name="generateIndexXrefId"/> + <xsl:call-template name="generateIndexXrefId"> + <xsl:with-param name="docid" select="$docid"/> + </xsl:call-template> </xsl:variable> <xsl:copy> <!-- add id to xref --> <xsl:apply-templates select="@*" mode="index_add_id"/> <xsl:attribute name="id"> <xsl:value-of select="$id"/> </xsl:attribute> - <xsl:apply-templates mode="index_add_id"/> + <xsl:apply-templates mode="index_add_id"> + <xsl:with-param name="docid" select="$docid"/> + </xsl:apply-templates> </xsl:copy> <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref: <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> --> <xsl:if test="@to"> <xsl:value-of select="$en_dash"/> @@ -8030,11 +8038,13 @@ <xsl:copy-of select="@*"/> <xsl:attribute name="target"><xsl:value-of select="@to"/></xsl:attribute> <xsl:attribute name="id"> <xsl:value-of select="$id"/><xsl:text>_to</xsl:text> </xsl:attribute> - <xsl:apply-templates mode="index_add_id"/> + <xsl:apply-templates mode="index_add_id"> + <xsl:with-param name="docid" select="$docid"/> + </xsl:apply-templates> </xsl:copy> </xsl:if> </xsl:template> <xsl:template match="@*|node()" mode="index_update"> @@ -8067,17 +8077,38 @@ <xsl:value-of select="."/> <xsl:apply-templates select="following-sibling::node()[1]" mode="process_li_element"/> </xsl:when> <xsl:when test="self::* and local-name(.) = 'xref'"> <xsl:variable name="id" select="@id"/> - <xsl:variable name="page" select="$index//item[@id = $id]"/> - <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/> - <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/> + <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/> <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/> - <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/> + <xsl:variable name="pages_"> + <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]"> + <xsl:choose> + <xsl:when test="@id = $id"> + <page><xsl:value-of select="."/></page> + </xsl:when> + <xsl:when test="@id = $id_next"> + <page_next><xsl:value-of select="."/></page_next> + </xsl:when> + <xsl:when test="@id = $id_prev"> + <page_prev><xsl:value-of select="."/></page_prev> + </xsl:when> + </xsl:choose> + </xsl:for-each> + </xsl:variable> + <xsl:variable name="pages" select="xalan:nodeset($pages_)"/> + + <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> --> + <xsl:variable name="page" select="$pages/page"/> + <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> --> + <xsl:variable name="page_next" select="$pages/page_next"/> + <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> --> + <xsl:variable name="page_prev" select="$pages/page_prev"/> + <xsl:choose> <!-- 2nd pass --> <!-- if page is equal to page for next and page is not the end of range --> <xsl:when test="$page != '' and $page_next != '' and $page = $page_next and not(contains($page, '_to'))"> <!-- case: 12, 12-14 --> <!-- skip element (i.e. remove it) and remove next text ',' --> @@ -8132,19 +8163,23 @@ <xsl:apply-templates select="node()" mode="xref_copy"/> </xsl:copy> </xsl:template> <xsl:template name="generateIndexXrefId"> + <xsl:param name="docid"/> + <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/> - <xsl:variable name="docid"> - <xsl:call-template name="getDocumentId"/> + <xsl:variable name="docid_curr"> + <xsl:value-of select="$docid"/> + <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if> </xsl:variable> + <xsl:variable name="item_number"> <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/> </xsl:variable> <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable> - <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', --> + <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', --> </xsl:template> <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4"> <fo:block xsl:use-attribute-sets="indexsect-title-style"> <!-- Index --> \ No newline at end of file