If you're documenting a large XML construct, the content of each fragment must be properly nested.
You might be tempted to document a template this way:
<p>The template preamble...</p> <src:fragment id="xpath.location"> <xsl:template name="xpath.location"> <xsl:param name="node" select="."/> <xsl:param name="path" select="''"/> <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:fragref linkend="xpath.location.body"/>
</src:fragment> <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> </xsl:template> </src:fragment>