<%
$t->{'a'}{pre} = '<i>';
$t->{'a'}{post} = '</i>';
$t->{'a'}{showtag} = 1;

my ($i, $j);
$t->{'title'}{testcode} =
        sub {
                my $node = shift;
                if (findvalue('parent::section = true()', $node)) {
						$i++; $j = 0;
                        $t->{'title'}{pre} = "<a name=\"$i\"></a><h2>";
						$t->{'title'}{post} = '</h2>';
                }
                elsif (findvalue('parent::subsection = true()', $node)) {
						$j++;
                        $t->{'title'}{pre} = "<a name=\"$i\.$j\"></a><h3>";
						$t->{'title'}{post} = '</h3>';
                }
				else {
					$t->{'title'}{pre} = '<title>';
					$t->{'title'}{post} = '</title>';
				}
                return 1;
        };
		
$t->{'section'}{post} = '<p>';
$t->{'subsection'}{pre} = '<blockquote>';
$t->{'subsection'}{post} = '</blockquote><br>';

%><html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<%= apply_templates('/page/head/title') %>
</head>
<body bgcolor="white">
	<h1><%= findvalue('/page/head/title/text()') %></h1>

<!-- table of contents -->
<%
my $x = 0;
foreach my $section (findnodes('/page/body/section')) {
	$x++;
	print "<a href=\"#$x\">", findvalue('./title/text()', $section), "</a><br>\n";
	my $y = 0;
	foreach my $subsect (findnodes('./subsection', $section)) {
		$y++;
		print " - <a href=\"#$x.$y\">", findvalue('./title/text()', $subsect), "</a><br>\n";
	}
}
%>

<!-- Main document body -->
<%= apply_templates('/page/body/section') %>

<!-- Footer -->
<br>
<div align="center">
<small>This page is copyright Fastnet Software Ltd, 2000.
Contact <a href="mailto:matt@sergeant.org">Matt Sergeant</a>
for details and availability.</small><br>
<small>This page was generated by XPathScript, using the
<a href="http://xml.sergeant.org/axkit/"
>Apache XML Delivery Toolkit</a>.</small>
</div>
</body>
</html>

