diff options
author | Ulrich Müller <ulm@gentoo.org> | 2023-10-30 17:18:01 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2023-10-31 21:01:56 +0100 |
commit | a1d3905fbbdae968ec4e99ede58a9d24f7e79c2e (patch) | |
tree | e1986369b9e978ae7e9d00ab8f3f2715dbb1e0d3 | |
parent | devbook.xsl: Update the findNext template for relative links (diff) | |
download | devmanual-a1d3905fbbdae968ec4e99ede58a9d24f7e79c2e.tar.gz devmanual-a1d3905fbbdae968ec4e99ede58a9d24f7e79c2e.tar.bz2 devmanual-a1d3905fbbdae968ec4e99ede58a9d24f7e79c2e.zip |
devbook.xsl: Replace str:repeatString by a non-recursive version
Also rename the template to repeat-string, i.e. move it out of the
str namespace.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | devbook.xsl | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/devbook.xsl b/devbook.xsl index 668fa01..ce617d3 100644 --- a/devbook.xsl +++ b/devbook.xsl @@ -290,12 +290,18 @@ <xsl:value-of select="translate($lcdata, translate($lcdata, $allowed, ''), '')"/> </xsl:template> +<xsl:template name="repeat-string"> + <xsl:param name="count"/> + <xsl:param name="append"/> + <xsl:value-of select="str:padding($count * string-length($append), $append)"/> +</xsl:template> + <xsl:template name="relative-path"> <xsl:param name="path"/> <xsl:param name="self"/> <xsl:choose> <xsl:when test="$path = '' or $self = '' or substring-before($path, '/') != substring-before($self, '/')"> - <xsl:call-template name="str:repeatString"> + <xsl:call-template name="repeat-string"> <xsl:with-param name="count" select="string-length($self) - string-length(translate($self, '/', ''))"/> <xsl:with-param name="append">../</xsl:with-param> </xsl:call-template> @@ -418,7 +424,7 @@ </xsl:param> <xsl:param name="path_rel"> <xsl:if test="$depth = 0 and $path = '' and /guide/@self != ''"> - <xsl:call-template name="str:repeatString"> + <xsl:call-template name="repeat-string"> <xsl:with-param name="count" select="string-length(/guide/@self) - string-length(translate(/guide/@self, '/' , ''))"/> <xsl:with-param name="append">../</xsl:with-param> @@ -495,7 +501,7 @@ <xsl:variable name="relative_path_depth" select="string-length(/guide/@self) - string-length(translate(/guide/@self, '/' , ''))"/> <xsl:variable name="relative_path_depth_recursion"> - <xsl:call-template name="str:repeatString"> + <xsl:call-template name="repeat-string"> <xsl:with-param name="count" select="$relative_path_depth"/> <xsl:with-param name="append">../</xsl:with-param> </xsl:call-template> @@ -721,24 +727,6 @@ </html> </xsl:template> -<xsl:template name="str:repeatString"> - <xsl:param name="string"/> - <xsl:param name="count"/> - <xsl:param name="append"/> - <xsl:choose> - <xsl:when test="$count != 0"> - <xsl:call-template name="str:repeatString"> - <xsl:with-param name="string" select="concat($string, $append)"/> - <xsl:with-param name="count" select="$count - 1"/> - <xsl:with-param name="append" select="$append"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$string"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - <xsl:template name="findNext"> <xsl:param name="self" select="/guide/@self"/> <xsl:choose> @@ -884,7 +872,7 @@ <xsl:choose> <xsl:when test="$depth > 0"> <xsl:variable name="relative_path_depth_recursion"> - <xsl:call-template name="str:repeatString"> + <xsl:call-template name="repeat-string"> <xsl:with-param name="count" select="$depth"/> <xsl:with-param name="append">../</xsl:with-param> </xsl:call-template> |