The solution is to divide the template into fragments differently.
<p>The template...</p> <src:fragment id="xpath.location"> <xsl:template name="xpath.location"> <src:fragref linkend="xpath.location.params"/> <src:fragref linkend="xpath.location.next.path"/> <src:fragref linkend="xpath.location.body"/> </src:fragment> </xsl:template> <p>The body of the template...</p> <src:fragment id="xpath.location.body"> <xsl:choose> <xsl:when test="$node/parent::*"> <xsl:call-template name="xpath.location"> <xsl:with-param name="node" select="$node/parent::*"/> <xsl:with-param name="path" select="$next.path"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text>/</xsl:text> <xsl:value-of select="$next.path"/> </xsl:otherwise> </xsl:choose> </src:fragment> <p>The parameters...</p> <src:fragment id="xpath.location.params"> <xsl:param name="node" select="."/> <xsl:param name="path" select="''"/> </src:fragment> <p>The next path segment...</p> <src:fragment id="xpath.location.next.path"> <xsl:variable name="next.path"> <xsl:value-of select="local-name($node)"/> <xsl:if test="$path != ''">/</xsl:if> <xsl:value-of select="$path"/> </xsl:variable> </src:fragment>
This is not always the most obvious documentation strategy.