aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2023-10-31 21:24:06 +0100
committerUlrich Müller <ulm@gentoo.org>2023-11-02 18:04:12 +0100
commitbcca132de057cf520806200b1bcb925b955b0966 (patch)
treefa0d4a780672110cf740341854c25cc3972eb016
parentdevbook.xsl: Use hexadecimal for character entities (diff)
downloaddevmanual-bcca132de057cf520806200b1bcb925b955b0966.tar.gz
devmanual-bcca132de057cf520806200b1bcb925b955b0966.tar.bz2
devmanual-bcca132de057cf520806200b1bcb925b955b0966.zip
devbook.xsl: Fix links created by contentsTree extraction
If the element that is extracted from the external document contains internal references, these links would be relative to the wrong start location, namely the one defined in that document. Therefore, define our own copy of /guide/@self (pointing to the location of the target document), and rebase the tree onto it. This fixes the intra-document links in appendices/todo-list/. Closes: https://bugs.gentoo.org/916523 Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--devbook.xsl18
1 files changed, 15 insertions, 3 deletions
diff --git a/devbook.xsl b/devbook.xsl
index fe9c496..626b97d 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -431,6 +431,7 @@
</xsl:call-template>
</xsl:if>
</xsl:param>
+ <xsl:param name="orig_self" select="/guide/@self"/>
<xsl:param name="extraction" select="@extraction"/>
<xsl:param name="extraction_counting"/>
@@ -446,6 +447,7 @@
<xsl:with-param name="maxdepth" select="$maxdepth"/>
<xsl:with-param name="path" select="concat($path, @href)"/>
<xsl:with-param name="path_rel" select="concat($path_rel, @href)"/>
+ <xsl:with-param name="orig_self" select="$orig_self"/>
<xsl:with-param name="extraction" select="$extraction"/>
<xsl:with-param name="extraction_counting" select="1"/>
</xsl:call-template>
@@ -461,6 +463,7 @@
<xsl:with-param name="maxdepth" select="$maxdepth"/>
<xsl:with-param name="path" select="concat($path, @href)"/>
<xsl:with-param name="path_rel" select="concat($path_rel, @href)"/>
+ <xsl:with-param name="orig_self" select="$orig_self"/>
<xsl:with-param name="extraction" select="$extraction"/>
<xsl:with-param name="extraction_counting" select="1"/>
</xsl:call-template>
@@ -474,10 +477,18 @@
<xsl:value-of select="document(concat($path, @href, 'text.xml'))/guide/chapter[1]/title"/>
</a>
<xsl:if test="$extraction != ''">
+ <!-- If the extracted element from the other document contains
+ any internal references, relative links would be based on
+ the wrong start location. So we must replace /guide/@self
+ by our own copy. Bug #916523. -->
+ <xsl:variable name="document_tree">
+ <guide self="{$orig_self}">
+ <xsl:copy-of select="document(concat($path, @href, 'text.xml'))/guide/*"/>
+ </guide>
+ </xsl:variable>
<ul>
- <xsl:for-each select="document(concat($path, @href, 'text.xml'))//*[name()=$extraction]">
- <xsl:variable name="extraction_id" select="position()"/>
- <li><xsl:apply-templates select="(//*[name()=$extraction])[position()=$extraction_id]"/></li>
+ <xsl:for-each select="exslt:node-set($document_tree)//*[name()=$extraction]">
+ <li><xsl:apply-templates select="."/></li>
</xsl:for-each>
</ul>
</xsl:if>
@@ -486,6 +497,7 @@
<xsl:with-param name="maxdepth" select="$maxdepth"/>
<xsl:with-param name="path" select="concat($path, @href)"/>
<xsl:with-param name="path_rel" select="concat($path_rel, @href)"/>
+ <xsl:with-param name="orig_self" select="$orig_self"/>
<xsl:with-param name="extraction" select="$extraction"/>
</xsl:call-template>
</li>