lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-2.1.8.1 vs lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-2.1.9

- old
+ new

@@ -7905,10 +7905,22 @@ <xsl:copy> <xsl:apply-templates mode="contents_item"/> </xsl:copy> </xsl:template> + <xsl:template match="*[local-name() = 'sub']" mode="contents_item"> + <xsl:copy> + <xsl:apply-templates mode="contents_item"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*[local-name() = 'sup']" mode="contents_item"> + <xsl:copy> + <xsl:apply-templates mode="contents_item"/> + </xsl:copy> + </xsl:template> + <xsl:template match="*[local-name() = 'stem']" mode="contents_item"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="*[local-name() = 'br']" mode="contents_item"> @@ -9356,25 +9368,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"/> @@ -9382,11 +9402,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"> @@ -9419,17 +9441,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 ',' --> @@ -9484,19 +9527,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