A Complete XML Example

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:src="http://nwalsh.com/xmlns/litprog/fragment">
<head>
<title>XPath Location Template</title>
</head>
<body>
<h1>xpath.location</h1>

<p>Calculate an XPath child-sequence to
an element node.</p>

<h2>Synopsis</h2>

<src:fragment id="top" mundane-result-prefixes="xsl">
<xsl:template name="xpath.location">
  <src:fragref linkend="xpath.location.node"/>
  <src:fragref linkend="xpath.location.path"/>

  <xsl:variable name="next.path">
    <xsl:value-of select="local-name($node)"/>
    ...
  </xsl:variable>
  ...
</xsl:template>
</src:fragment>

<h3>Public Parameters</h3>
<dl>
<dt>$node</dt>
<dd>
<src:fragment id='xpath.location.node'>
<xsl:param name="node" select="."/>
</src:fragment>
<p>The target node. If unspecified, the context
node is used.</p></dd>
</dl>

<h3>Private Parameters</h3>
<dl>
<dt>$path</dt>
<dd>
<src:fragment id="xpath.location.path">
<xsl:param name="path" select="''"/>
</src:fragment>
<p>The partially constructed path. Initially the empty string,
this parameter holds the path built during recursive invocation
of the template.</p></dd>
</dl>

<h2>Description</h2>
<p>The xpath.location template calculates
the absolute path from the root of
the tree to an element node, by default,
the context node.</p>
</body>
</html>
  • Documentation is pervasively attached to the source.

  • The code is immersed in the documentation.

  • The documentation is immersed in the code.

  • The order of the code fragments in the documentation is entirely independent of the order of the code fragments in the program.