%
use Apache::Request;
my $apr = Apache::Request->new($r);
my $sect = $apr->param('section');
$r->no_cache(1);
my $this_page = $r->uri;
my ($prev, $next);
my $sects = findvalue('count(/article/sect1)');
$sects = "$sects";
if ($sects > 1) {
if ($sect >= $sects) {
$prev = $sects - 1;
}
elsif ($sect <= 1) {
$next = 2;
}
else {
$prev = $sect - 1;
$next = $sect + 1;
}
}
%>
<%
$t->{'xref'}{testcode} = sub {
my ($node, $t) = @_;
my $id = findvalue('@linkend', $node);
my ($dest) = findnodes("id('$id')/title");
my $sect = findvalue("count(ancestor::sect1/preceding-sibling::sect1) + 1", $dest);
$t->{pre} = "{pre} .= $id . '">';
$t->{pre} .= findvalue("id('$id')/title/text()");
$t->{post} = '';
return -1;
};
%>
<%= findvalue('/article/artheader/title/text()') %>
<%
if (!$sect) {
# display title/TOC page
print apply_templates('/article/artheader/*');
my $page = 0;
foreach my $sect (findnodes('/article/sect1')) {
$page++;
print "";
print findvalue('title/text()', $sect);
print "
\n";
}
%>
<%
}
else {
%>
|
<%
if ($prev) {
%>
Prev
<% } else {
%>
Prev
<% } %>
| Top |
<%
if ($next) {
%>
Next
<% } else { %>
Next
<% } %>
|
<%
# display particular page
foreach my $section (findnodes("/article/sect1[$sect]")) {
# should only be 1
print apply_templates($section);
}
}
if ($sect) {
%>
|
<%
if ($prev) {
%>
Prev
<% } else {
%>
Prev
<% } %>
| Top |
<%
if ($next) {
%>
Next
<% } else { %>
Next
<% } %>
|
<% }
%>