mirror of https://github.com/tLDP/python-tldp
tools and data to allow testing the build chain
This commit is contained in:
parent
d28460aaff
commit
6047756027
|
@ -0,0 +1,737 @@
|
||||||
|
#!/usr/bin/perl -- # -*- Perl -*-
|
||||||
|
#
|
||||||
|
# $Id: collateindex.pl,v 1.10 2004/10/24 17:05:41 petere78 Exp $
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
collateindex.pl - generate DocBook index files
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
B<collateindex.pl> [B<-f>] [B<-g>] [B<-i> I<id>] [B<-I> I<scope>] [B<-N>]
|
||||||
|
[B<-o> F<file>] [B<-p>] [B<-P> F<file>] [B<-q>] [B<-s> I<name>]
|
||||||
|
[B<-S> I<scope>] [B<-t> I<name>] [B<-x>] F<file>
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
B<collateindex.pl> creates index data for DocBook XML or SGML files.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
use File::Basename;
|
||||||
|
use Getopt::Std;
|
||||||
|
|
||||||
|
$me = basename($0);
|
||||||
|
|
||||||
|
$usage = "Usage: $0 [options] file
|
||||||
|
Try \"perldoc $me\" for documentation.\n";
|
||||||
|
|
||||||
|
( $version = '$Revision: 1.10 $' ) =~ s/^\$[R]evision:\s*([^ ]*)\s*\$$/$1/;
|
||||||
|
|
||||||
|
=head1 OPTIONS
|
||||||
|
|
||||||
|
=over 5
|
||||||
|
|
||||||
|
=item B<-f>
|
||||||
|
|
||||||
|
Force the output file to be written, even if it appears to have been
|
||||||
|
edited by hand.
|
||||||
|
|
||||||
|
=item B<-g>
|
||||||
|
|
||||||
|
Group terms with IndexDiv based on the first letter of the term (or
|
||||||
|
its SortAs attribute). (This might not handle all language environments.)
|
||||||
|
|
||||||
|
=item B<-i> I<id>
|
||||||
|
|
||||||
|
The ID to use for the E<lt>indexE<gt> tag.
|
||||||
|
|
||||||
|
=item B<-I> I<scope>
|
||||||
|
|
||||||
|
The implied scope, must be C<all>, C<local>, or C<global>. IndexTerms
|
||||||
|
which do not specify a scope will have the implied scope. If
|
||||||
|
unspecified, C<all> is assumed.
|
||||||
|
|
||||||
|
=item B<-N>
|
||||||
|
|
||||||
|
New index (generates an empty index file).
|
||||||
|
|
||||||
|
=item B<-o> F<file>
|
||||||
|
|
||||||
|
Output to F<file>. Defaults to F<stdout>.
|
||||||
|
|
||||||
|
=item B<-p>
|
||||||
|
|
||||||
|
Link to points in the document. The default is to link to the closest
|
||||||
|
containing section.
|
||||||
|
|
||||||
|
=item B<-P> F<file>
|
||||||
|
|
||||||
|
Read a preamble from F<file>. The contents of F<file> will be
|
||||||
|
inserted before the E<lt>indexE<gt> tag.
|
||||||
|
|
||||||
|
=item B<-q>
|
||||||
|
|
||||||
|
Run quietly.
|
||||||
|
|
||||||
|
=item B<-s> I<name>
|
||||||
|
|
||||||
|
Name the IndexDiv that contains symbols. The default is C<Symbols>.
|
||||||
|
Meaningless if B<-g> is not used.
|
||||||
|
|
||||||
|
=item B<-S> I<scope>
|
||||||
|
|
||||||
|
Scope of the index, must be C<all>, C<local>, or C<global>. If
|
||||||
|
unspecified, C<all> is assumed.
|
||||||
|
|
||||||
|
=item B<-t> I<name>
|
||||||
|
|
||||||
|
Title for the index.
|
||||||
|
|
||||||
|
=item B<-x>
|
||||||
|
|
||||||
|
Make a SetIndex.
|
||||||
|
|
||||||
|
=item B<-V>
|
||||||
|
|
||||||
|
Print version number and exit.
|
||||||
|
|
||||||
|
=item F<file>
|
||||||
|
|
||||||
|
The file containing index data generated with the DocBook DSSSL
|
||||||
|
HTML stylesheet (usually called F<HTML.index>).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
die $usage if ! getopts('Dfgi:NpP:s:o:S:I:t:xqV');
|
||||||
|
|
||||||
|
$linkpoints = $opt_p;
|
||||||
|
$lettergroups = $opt_g;
|
||||||
|
$symbolsname = $opt_s || "Symbols";
|
||||||
|
$title = $opt_t;
|
||||||
|
$preamble = $opt_P;
|
||||||
|
$outfile = $opt_o || '-';
|
||||||
|
$indexid = $opt_i;
|
||||||
|
$scope = uc($opt_S) || 'ALL';
|
||||||
|
$impliedscope = uc($opt_I) || 'ALL';
|
||||||
|
$setindex = $opt_x;
|
||||||
|
$forceoutput = $opt_f;
|
||||||
|
$newindex = $opt_N;
|
||||||
|
$debug = $opt_D;
|
||||||
|
$quiet = $opt_q;
|
||||||
|
|
||||||
|
if ( $opt_V ) {
|
||||||
|
print "collateindex.pl $version\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$indextag = $setindex ? 'setindex' : 'index';
|
||||||
|
|
||||||
|
if ($newindex) {
|
||||||
|
safe_open(*OUT, $outfile);
|
||||||
|
if ($indexid) {
|
||||||
|
print OUT "<$indextag id='$indexid'>\n\n";
|
||||||
|
} else {
|
||||||
|
print OUT "<$indextag>\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print OUT "<!-- This file was produced by collateindex.pl. -->\n";
|
||||||
|
print OUT "<!-- Remove this comment if you edit this file by hand! -->\n";
|
||||||
|
|
||||||
|
print OUT "</$indextag>\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dat = shift @ARGV || die $usage;
|
||||||
|
die "$me: file \"$dat\" does not exist\n" if ! -f $dat;
|
||||||
|
|
||||||
|
%legal_scopes = ('ALL' => 1, 'LOCAL' => 1, 'GLOBAL' => 1);
|
||||||
|
if ($scope && !$legal_scopes{$scope}) {
|
||||||
|
die "$me: invalid scope: $scope\n";
|
||||||
|
}
|
||||||
|
if ($impliedscope && !$legal_scopes{$impliedscope}) {
|
||||||
|
die "$me: invalid implied scope: $impliedscope\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
@term = ();
|
||||||
|
%id = ();
|
||||||
|
|
||||||
|
$termcount = 0;
|
||||||
|
|
||||||
|
$quiet || print STDERR "Processing $dat...\n";
|
||||||
|
|
||||||
|
# Read the index file, creating an array of objects. Each object
|
||||||
|
# represents and indexterm and has fields for the content of the
|
||||||
|
# indexterm
|
||||||
|
|
||||||
|
open (F, $dat);
|
||||||
|
while (<F>) {
|
||||||
|
chop;
|
||||||
|
chop if /\r$/;
|
||||||
|
|
||||||
|
if (/^\/indexterm/i) {
|
||||||
|
push (@term, $idx);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^indexterm (.*)$/i) {
|
||||||
|
$termcount++;
|
||||||
|
$idx = {};
|
||||||
|
$idx->{'zone'} = {};
|
||||||
|
$idx->{'href'} = $1;
|
||||||
|
$idx->{'count'} = $termcount;
|
||||||
|
$idx->{'scope'} = $impliedscope;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^indexpoint (.*)$/i) {
|
||||||
|
$idx->{'hrefpoint'} = $1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^title (.*)$/i) {
|
||||||
|
$idx->{'title'} = $1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^primary[\[ ](.*)$/i) {
|
||||||
|
if (/^primary\[(.*?)\] (.*)$/i) {
|
||||||
|
$idx->{'psortas'} = &escape($1);
|
||||||
|
$idx->{'primary'} = &escape($2);
|
||||||
|
} else {
|
||||||
|
$idx->{'psortas'} = &escape($1);
|
||||||
|
$idx->{'primary'} = &escape($1);
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^secondary[\[ ](.*)$/i) {
|
||||||
|
if (/^secondary\[(.*?)\] (.*)$/i) {
|
||||||
|
$idx->{'ssortas'} = &escape($1);
|
||||||
|
$idx->{'secondary'} = &escape($2);
|
||||||
|
} else {
|
||||||
|
$idx->{'ssortas'} = &escape($1);
|
||||||
|
$idx->{'secondary'} = &escape($1);
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^tertiary[\[ ](.*)$/i) {
|
||||||
|
if (/^tertiary\[(.*?)\] (.*)$/i) {
|
||||||
|
$idx->{'tsortas'} = &escape($1);
|
||||||
|
$idx->{'tertiary'} = &escape($2);
|
||||||
|
} else {
|
||||||
|
$idx->{'tsortas'} = &escape($1);
|
||||||
|
$idx->{'tertiary'} = &escape($1);
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^see (.*)$/i) {
|
||||||
|
$idx->{'see'} = &escape($1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^seealso (.*)$/i) {
|
||||||
|
$idx->{'seealso'} = &escape($1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^significance (.*)$/i) {
|
||||||
|
$idx->{'significance'} = &escape($1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^class (.*)$/i) {
|
||||||
|
$idx->{'class'} = &escape($1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^scope (.*)$/i) {
|
||||||
|
$idx->{'scope'} = &escape(uc($1));
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^startref (.*)$/i) {
|
||||||
|
$idx->{'startref'} = $1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^id (.*)$/i) {
|
||||||
|
$idx->{'id'} = $1;
|
||||||
|
$id{$1} = $idx;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^zone (.*)$/i) {
|
||||||
|
my($href) = $1;
|
||||||
|
$_ = scalar(<F>);
|
||||||
|
chop;
|
||||||
|
die "$me: invalid zone: $_\n" if !/^title (.*)$/i;
|
||||||
|
$idx->{'zone'}->{$href} = $1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
die "$me: unrecognized tag in input: $_\n";
|
||||||
|
}
|
||||||
|
close (F);
|
||||||
|
|
||||||
|
$quiet || print STDERR "$termcount entries loaded...\n";
|
||||||
|
|
||||||
|
# Fixup the startrefs...
|
||||||
|
# In DocBook, STARTREF is a #CONREF attribute; support this by copying
|
||||||
|
# all of the fields from the indexterm with the id specified by STARTREF
|
||||||
|
# to the indexterm that has the STARTREF.
|
||||||
|
foreach $idx (@term) {
|
||||||
|
my($ididx, $field);
|
||||||
|
if ($idx->{'startref'}) {
|
||||||
|
$ididx = $id{$idx->{'startref'}};
|
||||||
|
foreach $field ('primary', 'secondary', 'tertiary', 'see', 'seealso',
|
||||||
|
'psortas', 'ssortas', 'tsortas', 'significance',
|
||||||
|
'class', 'scope') {
|
||||||
|
$idx->{$field} = $ididx->{$field};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sort the index terms
|
||||||
|
@term = sort termsort @term;
|
||||||
|
|
||||||
|
# Move all of the non-alphabetic entries to the front of the index.
|
||||||
|
@term = sortsymbols(@term);
|
||||||
|
|
||||||
|
safe_open(*OUT, $outfile);
|
||||||
|
|
||||||
|
# Write the index...
|
||||||
|
if ($indexid) {
|
||||||
|
print OUT "<$indextag id='$indexid'>\n\n";
|
||||||
|
} else {
|
||||||
|
print OUT "<$indextag>\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print OUT "<!-- This file was produced by collateindex.pl. -->\n";
|
||||||
|
print OUT "<!-- Remove this comment if you edit this file by hand! -->\n";
|
||||||
|
|
||||||
|
print OUT "<!-- ULINK is abused here.
|
||||||
|
|
||||||
|
The URL attribute holds the URL that points from the index entry
|
||||||
|
back to the appropriate place in the output produced by the HTML
|
||||||
|
stylesheet. (It's much easier to calculate this URL in the first
|
||||||
|
pass.)
|
||||||
|
|
||||||
|
The Role attribute holds the ID (either real or manufactured) of
|
||||||
|
the corresponding INDEXTERM. This is used by the print backends
|
||||||
|
to produce page numbers.
|
||||||
|
|
||||||
|
The entries below are sorted and collated into the correct order.
|
||||||
|
Duplicates may be removed in the HTML backend, but in the print
|
||||||
|
backends, it is impossible to suppress duplicate pages or coalesce
|
||||||
|
sequences of pages into a range.
|
||||||
|
-->\n\n";
|
||||||
|
|
||||||
|
print OUT "<title>$title</title>\n\n" if $title;
|
||||||
|
|
||||||
|
$last = {}; # the last indexterm we processed
|
||||||
|
$first = 1; # this is the first one
|
||||||
|
$group = ""; # we're not in a group yet
|
||||||
|
$lastout = ""; # we've not put anything out yet
|
||||||
|
@seealsos = (); # See also stack.
|
||||||
|
|
||||||
|
foreach $idx (@term) {
|
||||||
|
next if $idx->{'startref'}; # no way to represent spans...
|
||||||
|
next if ($idx->{'scope'} eq 'LOCAL') && ($scope eq 'GLOBAL');
|
||||||
|
next if ($idx->{'scope'} eq 'GLOBAL') && ($scope eq 'LOCAL');
|
||||||
|
next if &same($idx, $last); # suppress duplicates
|
||||||
|
|
||||||
|
$termcount--;
|
||||||
|
|
||||||
|
# If primary changes, output a whole new index term, otherwise just
|
||||||
|
# output another secondary or tertiary, as appropriate. We know from
|
||||||
|
# sorting that the terms will always be in the right order.
|
||||||
|
if (!&tsame($last, $idx, 'primary')) {
|
||||||
|
print "DIFF PRIM\n" if $debug;
|
||||||
|
&end_entry() if not $first;
|
||||||
|
|
||||||
|
if ($lettergroups) {
|
||||||
|
# If we're grouping, make the right indexdivs
|
||||||
|
$letter = $idx->{'psortas'};
|
||||||
|
$letter = $idx->{'primary'} if !$letter;
|
||||||
|
$letter = uc(substr($letter, 0, 1));
|
||||||
|
|
||||||
|
# symbols are a special case
|
||||||
|
if (($letter lt 'A') || ($letter gt 'Z')) {
|
||||||
|
if (($group eq '')
|
||||||
|
|| (($group ge 'A') && ($group le 'Z'))) {
|
||||||
|
print OUT "</indexdiv>\n" if !$first;
|
||||||
|
print OUT "<indexdiv><title>$symbolsname</title>\n\n";
|
||||||
|
$group = $letter;
|
||||||
|
}
|
||||||
|
} elsif (($group eq '') || ($group ne $letter)) {
|
||||||
|
print OUT "</indexdiv>\n" if !$first;
|
||||||
|
print OUT "<indexdiv><title>$letter</title>\n\n";
|
||||||
|
$group = $letter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = 0; # there can only be on first ;-)
|
||||||
|
|
||||||
|
print OUT "<indexentry>\n";
|
||||||
|
print OUT " <primaryie>", $idx->{'primary'};
|
||||||
|
$lastout = "primaryie";
|
||||||
|
|
||||||
|
if ($idx->{'secondary'}) {
|
||||||
|
print OUT "\n </primaryie>\n";
|
||||||
|
print OUT " <secondaryie>", $idx->{'secondary'};
|
||||||
|
$lastout = "secondaryie";
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($idx->{'tertiary'}) {
|
||||||
|
print OUT "\n </secondaryie>\n";
|
||||||
|
print OUT " <tertiaryie>", $idx->{'tertiary'};
|
||||||
|
$lastout = "tertiaryie";
|
||||||
|
}
|
||||||
|
} elsif (!&tsame($last, $idx, 'secondary')) {
|
||||||
|
print "DIFF SEC\n" if $debug;
|
||||||
|
|
||||||
|
print OUT "\n </$lastout>\n" if $lastout;
|
||||||
|
|
||||||
|
foreach (@seealsos) {
|
||||||
|
# it'd be nice to make this a link...
|
||||||
|
print OUT $indent, " <seealsoie>", &escape($_), "</seealsoie>\n";
|
||||||
|
}
|
||||||
|
@seealsos = ();
|
||||||
|
|
||||||
|
print OUT " <secondaryie>", $idx->{'secondary'};
|
||||||
|
$lastout = "secondaryie";
|
||||||
|
if ($idx->{'tertiary'}) {
|
||||||
|
print OUT "\n </secondaryie>\n";
|
||||||
|
print OUT " <tertiaryie>", $idx->{'tertiary'};
|
||||||
|
$lastout = "tertiaryie";
|
||||||
|
}
|
||||||
|
} elsif (!&tsame($last, $idx, 'tertiary')) {
|
||||||
|
print "DIFF TERT\n" if $debug;
|
||||||
|
|
||||||
|
print OUT "\n </$lastout>\n" if $lastout;
|
||||||
|
|
||||||
|
foreach (@seealsos) {
|
||||||
|
# it'd be nice to make this a link...
|
||||||
|
print OUT $indent, " <seealsoie>", &escape($_), "</seealsoie>\n";
|
||||||
|
}
|
||||||
|
@seealsos = ();
|
||||||
|
|
||||||
|
if ($idx->{'tertiary'}) {
|
||||||
|
print OUT " <tertiaryie>", $idx->{'tertiary'};
|
||||||
|
$lastout = "tertiaryie";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&print_term($idx);
|
||||||
|
|
||||||
|
$last = $idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Termcount is > 0 iff some entries were skipped.
|
||||||
|
$quiet || print STDERR "$termcount entries ignored...\n";
|
||||||
|
|
||||||
|
&end_entry();
|
||||||
|
|
||||||
|
print OUT "</indexdiv>\n" if $lettergroups;
|
||||||
|
print OUT "</$indextag>\n";
|
||||||
|
|
||||||
|
close (OUT);
|
||||||
|
|
||||||
|
$quiet || print STDERR "Done.\n";
|
||||||
|
|
||||||
|
sub same {
|
||||||
|
my($a) = shift;
|
||||||
|
my($b) = shift;
|
||||||
|
|
||||||
|
my($aP) = $a->{'psortas'} || $a->{'primary'};
|
||||||
|
my($aS) = $a->{'ssortas'} || $a->{'secondary'};
|
||||||
|
my($aT) = $a->{'tsortas'} || $a->{'tertiary'};
|
||||||
|
|
||||||
|
my($bP) = $b->{'psortas'} || $b->{'primary'};
|
||||||
|
my($bS) = $b->{'ssortas'} || $b->{'secondary'};
|
||||||
|
my($bT) = $b->{'tsortas'} || $b->{'tertiary'};
|
||||||
|
|
||||||
|
my($same);
|
||||||
|
|
||||||
|
$aP =~ s/^\s*//; $aP =~ s/\s*$//; $aP = uc($aP);
|
||||||
|
$aS =~ s/^\s*//; $aS =~ s/\s*$//; $aS = uc($aS);
|
||||||
|
$aT =~ s/^\s*//; $aT =~ s/\s*$//; $aT = uc($aT);
|
||||||
|
$bP =~ s/^\s*//; $bP =~ s/\s*$//; $bP = uc($bP);
|
||||||
|
$bS =~ s/^\s*//; $bS =~ s/\s*$//; $bS = uc($bS);
|
||||||
|
$bT =~ s/^\s*//; $bT =~ s/\s*$//; $bT = uc($bT);
|
||||||
|
|
||||||
|
# print "[$aP]=[$bP]\n";
|
||||||
|
# print "[$aS]=[$bS]\n";
|
||||||
|
# print "[$aT]=[$bT]\n";
|
||||||
|
|
||||||
|
# Two index terms are the same if:
|
||||||
|
# 1. the primary, secondary, and tertiary entries are the same
|
||||||
|
# (or have the same SORTAS)
|
||||||
|
# AND
|
||||||
|
# 2. They occur in the same titled section
|
||||||
|
# AND
|
||||||
|
# 3. They point to the same place
|
||||||
|
#
|
||||||
|
# Notes: Scope is used to suppress some entries, but can't be used
|
||||||
|
# for comparing duplicates.
|
||||||
|
# Interpretation of "the same place" depends on whether or
|
||||||
|
# not $linkpoints is true.
|
||||||
|
|
||||||
|
$same = (($aP eq $bP)
|
||||||
|
&& ($aS eq $bS)
|
||||||
|
&& ($aT eq $bT)
|
||||||
|
&& ($a->{'title'} eq $b->{'title'})
|
||||||
|
&& ($a->{'href'} eq $b->{'href'}));
|
||||||
|
|
||||||
|
# If we're linking to points, they're only the same if they link
|
||||||
|
# to exactly the same spot.
|
||||||
|
$same = $same && ($a->{'hrefpoint'} eq $b->{'hrefpoint'})
|
||||||
|
if $linkpoints;
|
||||||
|
|
||||||
|
if ($same) {
|
||||||
|
warn "$me: duplicated index entry found: $aP $aS $aT\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$same;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub tsame {
|
||||||
|
# Unlike same(), tsame only compares a single term
|
||||||
|
my($a) = shift;
|
||||||
|
my($b) = shift;
|
||||||
|
my($term) = shift;
|
||||||
|
my($sterm) = substr($term, 0, 1) . "sortas";
|
||||||
|
my($A, $B);
|
||||||
|
|
||||||
|
$A = $a->{$sterm} || $a->{$term};
|
||||||
|
$B = $b->{$sterm} || $b->{$term};
|
||||||
|
|
||||||
|
$A =~ s/^\s*//; $A =~ s/\s*$//; $A = uc($A);
|
||||||
|
$B =~ s/^\s*//; $B =~ s/\s*$//; $B = uc($B);
|
||||||
|
|
||||||
|
return $A eq $B;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub end_entry {
|
||||||
|
# End any open elements...
|
||||||
|
print OUT "\n </$lastout>\n" if $lastout;
|
||||||
|
|
||||||
|
foreach (@seealsos) {
|
||||||
|
# it'd be nice to make this a link...
|
||||||
|
print OUT $indent, " <seealsoie>", &escape($_), "</seealsoie>\n";
|
||||||
|
}
|
||||||
|
@seealsos = ();
|
||||||
|
|
||||||
|
print OUT "</indexentry>\n\n";
|
||||||
|
$lastout = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub print_term {
|
||||||
|
# Print out the links for an indexterm. There can be more than
|
||||||
|
# one if the term has a ZONE that points to more than one place.
|
||||||
|
# (do we do the right thing in that case?)
|
||||||
|
my($idx) = shift;
|
||||||
|
my($key, $indent, @hrefs);
|
||||||
|
my(%href) = ();
|
||||||
|
my(%phref) = ();
|
||||||
|
|
||||||
|
$indent = " ";
|
||||||
|
|
||||||
|
if ($idx->{'see'}) {
|
||||||
|
# it'd be nice to make this a link...
|
||||||
|
if ($lastout) {
|
||||||
|
print OUT "\n </$lastout>\n";
|
||||||
|
$lastout = "";
|
||||||
|
}
|
||||||
|
print OUT $indent, "<seeie>", &escape($idx->{'see'}), "</seeie>\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keys %{$idx->{'zone'}}) {
|
||||||
|
foreach $key (keys %{$idx->{'zone'}}) {
|
||||||
|
$href{$key} = $idx->{'zone'}->{$key};
|
||||||
|
$phref{$key} = $key;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$href{$idx->{'href'}} = $idx->{'title'};
|
||||||
|
$phref{$idx->{'href'}} = $idx->{'hrefpoint'};
|
||||||
|
}
|
||||||
|
|
||||||
|
# We can't use <LINK> because we don't know the ID of the term in the
|
||||||
|
# original source (and, in fact, it might not have one).
|
||||||
|
print OUT ",\n";
|
||||||
|
@hrefs = keys %href;
|
||||||
|
while (@hrefs) {
|
||||||
|
my($linkend) = "";
|
||||||
|
my($role) = "";
|
||||||
|
$key = shift @hrefs;
|
||||||
|
if ($linkpoints) {
|
||||||
|
$linkend = $phref{$key};
|
||||||
|
} else {
|
||||||
|
$linkend = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role = $phref{$key};
|
||||||
|
$role = $1 if $role =~ /\#(.*)$/;
|
||||||
|
$role = $1 if $role =~ /(.*)\./;
|
||||||
|
|
||||||
|
print OUT $indent;
|
||||||
|
print OUT "<ulink url=\"$linkend\" role=\"$role\">";
|
||||||
|
print OUT "<emphasis>" if ($idx->{'significance'} eq 'PREFERRED');
|
||||||
|
print OUT &escape($href{$key});
|
||||||
|
print OUT "</emphasis>" if ($idx->{'significance'} eq 'PREFERRED');
|
||||||
|
print OUT "</ulink>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($idx->{'seealso'}) {
|
||||||
|
push @seealsos, $idx->{'seealso'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub termsort {
|
||||||
|
my($aP) = $a->{'psortas'} || $a->{'primary'};
|
||||||
|
my($aS) = $a->{'ssortas'} || $a->{'secondary'};
|
||||||
|
my($aT) = $a->{'tsortas'} || $a->{'tertiary'};
|
||||||
|
my($ap) = $a->{'count'};
|
||||||
|
|
||||||
|
my($bP) = $b->{'psortas'} || $b->{'primary'};
|
||||||
|
my($bS) = $b->{'ssortas'} || $b->{'secondary'};
|
||||||
|
my($bT) = $b->{'tsortas'} || $b->{'tertiary'};
|
||||||
|
my($bp) = $b->{'count'};
|
||||||
|
|
||||||
|
$aP =~ s/^\s*//; $aP =~ s/\s*$//; $aP = uc($aP);
|
||||||
|
$aS =~ s/^\s*//; $aS =~ s/\s*$//; $aS = uc($aS);
|
||||||
|
$aT =~ s/^\s*//; $aT =~ s/\s*$//; $aT = uc($aT);
|
||||||
|
$bP =~ s/^\s*//; $bP =~ s/\s*$//; $bP = uc($bP);
|
||||||
|
$bS =~ s/^\s*//; $bS =~ s/\s*$//; $bS = uc($bS);
|
||||||
|
$bT =~ s/^\s*//; $bT =~ s/\s*$//; $bT = uc($bT);
|
||||||
|
|
||||||
|
if ($aP eq $bP) {
|
||||||
|
if ($aS eq $bS) {
|
||||||
|
if ($aT eq $bT) {
|
||||||
|
# make sure seealso's always sort to the bottom
|
||||||
|
return 1 if ($a->{'seealso'});
|
||||||
|
return -1 if ($b->{'seealso'});
|
||||||
|
# if everything else is the same, keep these elements
|
||||||
|
# in document order (so the index links are in the right
|
||||||
|
# order)
|
||||||
|
return $ap <=> $bp;
|
||||||
|
} else {
|
||||||
|
return $aT cmp $bT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $aS cmp $bS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $aP cmp $bP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub sortsymbols {
|
||||||
|
my(@term) = @_;
|
||||||
|
my(@new) = ();
|
||||||
|
my(@sym) = ();
|
||||||
|
my($letter);
|
||||||
|
my($idx);
|
||||||
|
|
||||||
|
# Move the non-letter things to the front. Should digits be thier
|
||||||
|
# own group? Maybe...
|
||||||
|
foreach $idx (@term) {
|
||||||
|
$letter = $idx->{'psortas'};
|
||||||
|
$letter = $idx->{'primary'} if !$letter;
|
||||||
|
$letter = uc(substr($letter, 0, 1));
|
||||||
|
|
||||||
|
if (($letter lt 'A') || ($letter gt 'Z')) {
|
||||||
|
push (@sym, $idx);
|
||||||
|
} else {
|
||||||
|
push (@new, $idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (@sym, @new);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub safe_open {
|
||||||
|
local(*OUT) = shift;
|
||||||
|
local(*F, $_);
|
||||||
|
|
||||||
|
if (($outfile ne '-') && (!$forceoutput)) {
|
||||||
|
my($handedit) = 1;
|
||||||
|
if (open (OUT, $outfile)) {
|
||||||
|
while (<OUT>) {
|
||||||
|
if (/<!-- Remove this comment if you edit this file by hand! -->/){
|
||||||
|
$handedit = 0;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close (OUT);
|
||||||
|
} else {
|
||||||
|
$handedit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($handedit) {
|
||||||
|
print STDERR "$me: file \"$outfile\" appears to have been edited by hand\n";
|
||||||
|
print STDERR "Use the -f option or specify a different output file name.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open (OUT, ">$outfile") || die "$me: could not open file \"$outfile\": $!\n";
|
||||||
|
|
||||||
|
if ($preamble) {
|
||||||
|
# Copy the preamble
|
||||||
|
if (open(F, $preamble)) {
|
||||||
|
while (<F>) {
|
||||||
|
print OUT $_;
|
||||||
|
}
|
||||||
|
close(F);
|
||||||
|
} else {
|
||||||
|
warn "$me: could not open preamble file \"$preamble\": $!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub escape {
|
||||||
|
# make sure & and < don't show up in the index
|
||||||
|
local $_ = shift;
|
||||||
|
s/&/&/sg;
|
||||||
|
s/</</sg;
|
||||||
|
s/>/>/sg; # what the heck
|
||||||
|
|
||||||
|
return $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=head1 EXAMPLE
|
||||||
|
|
||||||
|
B<collateindex.pl> B<-o> F<index.sgml> F<HTML.index>
|
||||||
|
|
||||||
|
=head1 EXIT STATUS
|
||||||
|
|
||||||
|
=over 5
|
||||||
|
|
||||||
|
=item B<0>
|
||||||
|
|
||||||
|
Success
|
||||||
|
|
||||||
|
=item B<1>
|
||||||
|
|
||||||
|
Failure
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Norm Walsh E<lt>ndw@nwalsh.comE<gt>
|
||||||
|
|
||||||
|
Minor updates by Adam Di Carlo E<lt>adam@onshore.comE<gt> and Peter Eisentraut E<lt>peter_e@gmx.netE<gt>
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
version='1.0'
|
||||||
|
xmlns="http://www.w3.org/TR/xhtml1/transitional"
|
||||||
|
exclude-result-prefixes="#default">
|
||||||
|
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!-- This stylesheet calls Norman Walsh's 'docbook.xsl' stylesheet
|
||||||
|
and therefore generates MULTIPLE HTML FILES as output. -->
|
||||||
|
|
||||||
|
<!-- Note the the *order* of the import statements below is important and
|
||||||
|
should not be changed. -->
|
||||||
|
|
||||||
|
<!-- Change this to the path to where you have installed Norman
|
||||||
|
Walsh's XSL stylesheets -->
|
||||||
|
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
|
||||||
|
|
||||||
|
<!-- Imports the common LDP customization layer. -->
|
||||||
|
<xsl:import href="ldp-html-common.xsl"/>
|
||||||
|
|
||||||
|
<!-- If there was some reason to override 'ldp-html-common.xsl' or to
|
||||||
|
perform any other customizations that affect *only* the generation
|
||||||
|
of multiple HTML files, those templates or parameters could be
|
||||||
|
entered here. -->
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,239 @@
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
version='1.0'
|
||||||
|
xmlns="http://www.w3.org/TR/xhtml1/transitional"
|
||||||
|
exclude-result-prefixes="#default"
|
||||||
|
>
|
||||||
|
|
||||||
|
<!-- $Id -->
|
||||||
|
|
||||||
|
<!-- Experimental stylesheet by Dan York
|
||||||
|
This is an attempt to replicate the customizations done in ldp.dsl
|
||||||
|
Each customization in ldp.dsl is listed in the order in which it
|
||||||
|
appears (in ldp.dsl) with the corresponding XSLT template or setting
|
||||||
|
below it. Where there is no XSLT code below an item, that particular
|
||||||
|
customization of ldp.dsl is not yet supported here. Some additional
|
||||||
|
options and features have been added and are noted as not being in
|
||||||
|
ldp.dsl. The work on this stylesheet began 5 Jul 2001. -->
|
||||||
|
|
||||||
|
<!-- Note that this file, 'ldp-html-common.xsl', is NOT intended to be
|
||||||
|
called directly. Instead, you should call either of two stylesheets:
|
||||||
|
'ldp-html.xsl' or 'ldp-html-chunk.xsl'. The former generates a SINGLE
|
||||||
|
HTML file, while the latter performs "chunking" to generate MULTIPLE
|
||||||
|
HTML files. Both of those files import the appropriate Norman Walsh
|
||||||
|
stylesheet and then import this customization layer. -->
|
||||||
|
|
||||||
|
<!-- NOT IN LDP.DSL - This stylesheet supports the additional use of the
|
||||||
|
"role" and "condition" attributes to the <author> tag. The XSLT template
|
||||||
|
is listed later in the stylesheet, but the text lables are listed
|
||||||
|
here in order to make localization of the stylesheet easier. Note
|
||||||
|
that spaces *are* significant in the value, so you should have a
|
||||||
|
space after the colon. -->
|
||||||
|
|
||||||
|
<xsl:variable name="maintainerlabel">Maintainer: </xsl:variable>
|
||||||
|
<xsl:variable name="authorlabel">Author: </xsl:variable>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- NOT IN LDP.DSL
|
||||||
|
Creates header content in all generated HTML files -->
|
||||||
|
|
||||||
|
<xsl:template name="user.head.content">
|
||||||
|
<xsl:param name="node" select="."/>
|
||||||
|
<meta name="generator" content="Experimental LDP.XSL $Revision$"/>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:comment> Generated by LDP XSLT customization layer
|
||||||
|
based on Norman Walsh's DocBook XSL stylesheets.
|
||||||
|
More information at http://www.linuxdoc.org/ </xsl:comment>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- declare-characteristic preserve-sdata?
|
||||||
|
No longer appears necessary as it is a JadeTex issue. -->
|
||||||
|
|
||||||
|
<!-- generate-legalnotice-link?
|
||||||
|
Not currently supported in Norm's XSL stylesheets. Logged
|
||||||
|
at SourceForge as a bug. -->
|
||||||
|
|
||||||
|
<!-- Should graphics be used for admonitions (notes, warnings)? 0 or 1 -->
|
||||||
|
<xsl:param name="admon.graphics" select="0"/>
|
||||||
|
|
||||||
|
<!-- If using admon graphics (1 above), what is path to graphics?
|
||||||
|
Should be the path relative to your document and MUST end with
|
||||||
|
a trailing slash. Also, this parameter needs to be on a
|
||||||
|
single line. -->
|
||||||
|
<xsl:param name="admon.graphics.path">images/</xsl:param>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Make funcsynopsis look pretty -->
|
||||||
|
<xsl:param name="funcsynopsis.decoration" select="1" type="boolean" />
|
||||||
|
|
||||||
|
<!-- Extension for HTML files -->
|
||||||
|
<xsl:param name="html.ext" select="'.html'"/>
|
||||||
|
|
||||||
|
<!-- Generate TOCs for book, article, part -->
|
||||||
|
<xsl:param name="generate.book.toc" select="1" type="boolean"/>
|
||||||
|
<xsl:param name="generate.article.toc" select="1" type="boolean"/>
|
||||||
|
<xsl:param name="generate.part.toc" select="1" type="boolean"/>
|
||||||
|
|
||||||
|
<!-- generate-book-titlepage -->
|
||||||
|
|
||||||
|
<!-- generate-article-titlepage -->
|
||||||
|
|
||||||
|
<!-- Equivalent to chunk-skip-first-element-list - forces TOC on separate page
|
||||||
|
If 0, first sect is on page for chapter or article -->
|
||||||
|
<xsl:param name="chunk.first.sections" select="'1'"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- NOT IN LDP.DSL -->
|
||||||
|
<!-- Create chunks for top-level sections. If 0, chunks will only be
|
||||||
|
created for chapters/appendixes, and NOT for sectx elements -->
|
||||||
|
<xsl:param name="chunk.sections" select="'1'"/>
|
||||||
|
|
||||||
|
<!-- list-element-list - NO LONGER NEEDED - bug fix -->
|
||||||
|
|
||||||
|
<!-- Filename for the root chunk -->
|
||||||
|
<xsl:param name="root.filename" select="'index'"/>
|
||||||
|
|
||||||
|
<!-- shade-verbatim
|
||||||
|
I have created a function below that shades the verbatim sections.
|
||||||
|
logic would need to be added to check if this is set.
|
||||||
|
Norm has added parameters to his 1.44 stylesheets that support
|
||||||
|
shading verbatim sections. However, it looks like it requires
|
||||||
|
an attribute to a table to have verbatim shading. Needs to be
|
||||||
|
explored further. -->
|
||||||
|
|
||||||
|
<!-- When chunking, use id attribute as filename? 0 or 1 -->
|
||||||
|
<xsl:param name="use.id.as.filename" select="1"/>
|
||||||
|
|
||||||
|
<!-- graphic-extensions - NO LONGER NEEDED?? -->
|
||||||
|
|
||||||
|
<!-- default graphic filename extension -->
|
||||||
|
<xsl:param name="graphic.default.extension" select="'.gif'" type="string"/>
|
||||||
|
|
||||||
|
<!-- Should chapters be labeled? 0 or 1 -->
|
||||||
|
<xsl:param name="chapter.autolabel" select="1"/>
|
||||||
|
|
||||||
|
<!-- Should sections be labeled? 0 or 1 -->
|
||||||
|
<xsl:param name="section.autolabel" select="1"/>
|
||||||
|
|
||||||
|
<!-- Related to section labels, should those labels include the chapter
|
||||||
|
number in them (i.e., 1.1, 1.2, 1.3, 1.4 )-->
|
||||||
|
<xsl:param name="section.label.includes.component.label" select="1" type="boolean"/>
|
||||||
|
|
||||||
|
<!-- To what depth (in sections) should the TOC go? -->
|
||||||
|
<xsl:param name="toc.section.depth" select="2"/>
|
||||||
|
|
||||||
|
<!-- Custom 'emphasis' template to allow 'role="strong"' to
|
||||||
|
also produce a bold item. -->
|
||||||
|
<xsl:template match="emphasis">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="(@role='strong') or (@role='bold')">
|
||||||
|
<xsl:call-template name="inline.boldseq"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:call-template name="inline.italicseq"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- book-titlepage-recto-elements
|
||||||
|
article-titlepage-recto-elements
|
||||||
|
article-titlepage-recto-mode
|
||||||
|
article-title
|
||||||
|
|
||||||
|
- Customizing these elements (for instance, to list what is on the
|
||||||
|
title page) involves writing a layer for html/titlepage.templates.xml and the
|
||||||
|
other files html/titlepage.xsl and html/titlepage.templates.xsl - Norm
|
||||||
|
is doing something funky here and I haven't fully figured it out. -->
|
||||||
|
|
||||||
|
<!-- The remainder of ldp.dsl deals with changing the foreground and
|
||||||
|
background colors of verbatim elements although in reading through the
|
||||||
|
DSSSL it doesn't look like it actually changed the foreground colors.
|
||||||
|
The changing of the background shading can be done at two locations
|
||||||
|
(one numbered, one not) in the template below. -->
|
||||||
|
|
||||||
|
<!-- Custom template for programlisting, screen and synopsis to generate a gray
|
||||||
|
background to the item. -->
|
||||||
|
<xsl:template match="programlisting|screen|synopsis">
|
||||||
|
<xsl:param name="suppress-numbers" select="'0'"/>
|
||||||
|
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
|
||||||
|
<xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
|
||||||
|
|
||||||
|
<xsl:if test="@id">
|
||||||
|
<a href="{$id}"/>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$suppress-numbers = '0'
|
||||||
|
and @linenumbering = 'numbered'
|
||||||
|
and $use.extensions != '0'
|
||||||
|
and $linenumbering.extension != '0'">
|
||||||
|
<xsl:variable name="rtf">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:variable>
|
||||||
|
<!-- Change the color bacground color in the line below. -->
|
||||||
|
<table border="0" bgcolor="#E0E0E0" width="90%">
|
||||||
|
<tr><td>
|
||||||
|
<pre class="{name(.)}">
|
||||||
|
<xsl:call-template name="number.rtf.lines">
|
||||||
|
<xsl:with-param name="rtf" select="$rtf"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</pre>
|
||||||
|
</td></tr></table>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<!-- Change the color bacground color in the line below. -->
|
||||||
|
<table border="0" bgcolor="#E0E0E0" width="90%">
|
||||||
|
<tr><td>
|
||||||
|
<pre class="{name(.)}">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</pre>
|
||||||
|
</td></tr></table>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- NOT IN LDP.DSL. Custom template to allow Maintainer to be a role in
|
||||||
|
the Author element. It also checks for a "condition" attribute
|
||||||
|
to the <author> element. If it finds the condition attribute, it
|
||||||
|
copies VERBATIM the value of the attribute to be in front of the
|
||||||
|
word Author or Maintainer. This is done to allow maximum flexibility.
|
||||||
|
Note that an <xsl:text> element was necessary to put the space
|
||||||
|
between the condition and the word Author or Maintainer. -->
|
||||||
|
|
||||||
|
<xsl:template match="author" mode="titlepage.mode">
|
||||||
|
<h3 class="{name(.)}">
|
||||||
|
<!-- If there is a condition attribute, print it VERBATIM first -->
|
||||||
|
<xsl:if test="@condition"><i><xsl:value-of select="@condition"/></i>
|
||||||
|
<xsl:text> </xsl:text></xsl:if>
|
||||||
|
<!-- Test to see if there is a role. If maintainer, print that. If not,
|
||||||
|
assume it is an author. -->
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@role='maintainer'">
|
||||||
|
<i><xsl:value-of select="$maintainerlabel"/></i>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<i><xsl:value-of select="$authorlabel"/></i>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
<xsl:call-template name="person.name"/>
|
||||||
|
</h3>
|
||||||
|
<xsl:apply-templates mode="titlepage.mode" select="./contrib"/>
|
||||||
|
<xsl:apply-templates mode="titlepage.mode" select="./affiliation"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- NOT IN LDP.DSL. Format Q and A labels.
|
||||||
|
Added by dcm 2003-05-19. -->
|
||||||
|
|
||||||
|
<xsl:template match="question" mode="label.markup">
|
||||||
|
<xsl:text>Q</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="answer" mode="label.markup">
|
||||||
|
<xsl:text>A</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
version='1.0'
|
||||||
|
xmlns="http://www.w3.org/TR/xhtml1/transitional"
|
||||||
|
exclude-result-prefixes="#default">
|
||||||
|
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!-- This stylesheet calls Norman Walsh's 'docbook.xsl' stylesheet
|
||||||
|
and therefore generates a SINGLE HTML FILE as output. -->
|
||||||
|
|
||||||
|
<!-- Note the the *order* of the import statements below is important and
|
||||||
|
should not be changed. -->
|
||||||
|
|
||||||
|
<!-- Change this to the path to where you have installed Norman
|
||||||
|
Walsh's XSL stylesheets. -->
|
||||||
|
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
|
||||||
|
|
||||||
|
<!-- Imports the common LDP customization layer. -->
|
||||||
|
<xsl:import href="ldp-html-common.xsl"/>
|
||||||
|
|
||||||
|
<!-- If there was some reason to override 'ldp-html-common.xsl' or to
|
||||||
|
perform any other customizations that affect *only* the generation
|
||||||
|
of a single HTML file, those templates or parameters could be
|
||||||
|
entered here. -->
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
version='1.0'
|
||||||
|
xmlns="http://www.w3.org/TR/xhtml1/transitional"
|
||||||
|
exclude-result-prefixes="#default">
|
||||||
|
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<!-- This stylesheet will eventually include print customizations
|
||||||
|
from LDP.DSL. At the current time, it has not been developed.-->
|
||||||
|
|
||||||
|
<!-- Change this to the path to where you have installed Norman
|
||||||
|
Walsh's XSL stylesheets. -->
|
||||||
|
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
|
||||||
|
|
||||||
|
<!-- Number all sections in the style of 'CH.S1.S2 Section Title' where
|
||||||
|
CH is the chapter number, S1 is the section number and S2 is the
|
||||||
|
sub-section number. The lables are not limited to any particular
|
||||||
|
depth and can go as far as there are sections. -->
|
||||||
|
<xsl:param name="section.autolabel" select="1"></xsl:param>
|
||||||
|
<xsl:param name="section.label.includes.component.label" select="0"></xsl:param>
|
||||||
|
|
||||||
|
<!-- Turn off the default 'full justify' and go with 'left justify'
|
||||||
|
instead. This avoids the large gaps that can sometimes appear
|
||||||
|
between words in fully-justified documents. -->
|
||||||
|
<xsl:param name="alignment">start</xsl:param>
|
||||||
|
|
||||||
|
<!-- Shade Verbatim Sections such as programlisting and screen -->
|
||||||
|
<xsl:param name="shade.verbatim" select="1"/>
|
||||||
|
|
||||||
|
<!-- Create bookmarks in .PDF files -->
|
||||||
|
<xsl:param name="fop.extensions" select="0"/>
|
||||||
|
|
||||||
|
<!-- Use fop1 extensions, per
|
||||||
|
https://lists.oasis-open.org/archives/docbook-apps/201110/msg00080.html
|
||||||
|
-->
|
||||||
|
<xsl:param name="fop1.extensions" select="1"/>
|
||||||
|
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,371 @@
|
||||||
|
<!DOCTYPE style-sheet PUBLIC
|
||||||
|
"-//James Clark//DTD DSSSL Style Sheet//EN" [
|
||||||
|
<!ENTITY % html "IGNORE">
|
||||||
|
<![%html;[
|
||||||
|
<!ENTITY % print "IGNORE">
|
||||||
|
<!ENTITY docbook.dsl PUBLIC
|
||||||
|
"-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN"
|
||||||
|
CDATA dsssl>
|
||||||
|
]]>
|
||||||
|
<!ENTITY % print "INCLUDE">
|
||||||
|
<![%print;[
|
||||||
|
<!ENTITY docbook.dsl PUBLIC
|
||||||
|
"-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"
|
||||||
|
CDATA dsssl>
|
||||||
|
]]>
|
||||||
|
]>
|
||||||
|
|
||||||
|
<style-sheet>
|
||||||
|
|
||||||
|
;; ------------------------------------------------------------------------
|
||||||
|
;; ldp.dsl - LDP Customized DSSSL Stylesheet
|
||||||
|
;; v1.12, 2003-03-19
|
||||||
|
;; Copyright (C) 2000-2003
|
||||||
|
;;
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation; either version 2 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program; if not, write to the Free Software
|
||||||
|
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
;; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
<style-specification id="print" use="docbook">
|
||||||
|
<style-specification-body>
|
||||||
|
|
||||||
|
;; customize the print stylesheet
|
||||||
|
|
||||||
|
(declare-characteristic preserve-sdata?
|
||||||
|
;; this is necessary because right now jadetex does not understand
|
||||||
|
;; symbolic entities, whereas things work well with numeric entities.
|
||||||
|
"UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
|
||||||
|
#f)
|
||||||
|
|
||||||
|
(define %generate-article-toc%
|
||||||
|
;; Should a Table of Contents be produced for Articles?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define (toc-depth nd)
|
||||||
|
4)
|
||||||
|
|
||||||
|
(define %generate-article-titlepage-on-separate-page%
|
||||||
|
;; Should the article title page be on a separate page?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %section-autolabel%
|
||||||
|
;; Are sections enumerated?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %footnote-ulinks%
|
||||||
|
;; Generate footnotes for ULinks?
|
||||||
|
#f)
|
||||||
|
|
||||||
|
(define %bop-footnotes%
|
||||||
|
;; Make "bottom-of-page" footnotes?
|
||||||
|
#f)
|
||||||
|
|
||||||
|
(define %body-start-indent%
|
||||||
|
;; Default indent of body text
|
||||||
|
0pi)
|
||||||
|
|
||||||
|
(define %para-indent-firstpara%
|
||||||
|
;; First line start-indent for the first paragraph
|
||||||
|
0pt)
|
||||||
|
|
||||||
|
(define %para-indent%
|
||||||
|
;; First line start-indent for paragraphs (other than the first)
|
||||||
|
0pt)
|
||||||
|
|
||||||
|
(define %block-start-indent%
|
||||||
|
;; Extra start-indent for block-elements
|
||||||
|
0pt)
|
||||||
|
|
||||||
|
(define formal-object-float
|
||||||
|
;; Do formal objects float?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %hyphenation%
|
||||||
|
;; Allow automatic hyphenation?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %admon-graphics%
|
||||||
|
;; Use graphics in admonitions?
|
||||||
|
#f)
|
||||||
|
|
||||||
|
(define %default-quadding%
|
||||||
|
;; Full justification.
|
||||||
|
'justify)
|
||||||
|
|
||||||
|
(define (book-titlepage-verso-elements)
|
||||||
|
;;added publisher, releaseinfo to the default list
|
||||||
|
(list (normalize "title")
|
||||||
|
(normalize "subtitle")
|
||||||
|
(normalize "corpauthor")
|
||||||
|
(normalize "authorgroup")
|
||||||
|
(normalize "author")
|
||||||
|
(normalize "publisher")
|
||||||
|
(normalize "releaseinfo")
|
||||||
|
(normalize "editor")
|
||||||
|
(normalize "edition")
|
||||||
|
(normalize "pubdate")
|
||||||
|
(normalize "copyright")
|
||||||
|
(normalize "isbn")
|
||||||
|
(normalize "abstract")
|
||||||
|
(normalize "legalnotice")
|
||||||
|
(normalize "revhistory")))
|
||||||
|
|
||||||
|
</style-specification-body>
|
||||||
|
</style-specification>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
;; customize the html stylesheet; parts borrowed from
|
||||||
|
;; Cygnus at http://sourceware.cygnus.com/ (cygnus-both.dsl)
|
||||||
|
-->
|
||||||
|
|
||||||
|
<style-specification id="html" use="docbook">
|
||||||
|
<style-specification-body>
|
||||||
|
|
||||||
|
(declare-characteristic preserve-sdata?
|
||||||
|
;; this is necessary because right now jadetex does not understand
|
||||||
|
;; symbolic entities, whereas things work well with numeric entities.
|
||||||
|
"UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
|
||||||
|
#f)
|
||||||
|
|
||||||
|
(declare-flow-object-class element
|
||||||
|
;; for redhat
|
||||||
|
"UNREGISTERED::James Clark//Flow Object Class::element")
|
||||||
|
|
||||||
|
(define %html-pubid%
|
||||||
|
;; put the public identifier in each HTML file
|
||||||
|
"-//W3C//DTD HTML 4.0 Transitional//EN")
|
||||||
|
|
||||||
|
(define %generate-legalnotice-link%
|
||||||
|
;; put the legal notice in a separate file
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %admon-graphics-path%
|
||||||
|
;; use graphics in admonitions, set their
|
||||||
|
"../images/")
|
||||||
|
|
||||||
|
(define %admon-graphics%
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %funcsynopsis-decoration%
|
||||||
|
;; make funcsynopsis look pretty
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %html-ext%
|
||||||
|
;; when producing HTML files, use this extension
|
||||||
|
".html")
|
||||||
|
|
||||||
|
(define %generate-book-toc%
|
||||||
|
;; Should a Table of Contents be produced for books?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %generate-article-toc%
|
||||||
|
;; Should a Table of Contents be produced for articles?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %generate-part-toc%
|
||||||
|
;; Should a Table of Contents be produced for parts?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %generate-book-titlepage%
|
||||||
|
;; produce a title page for books
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %generate-article-titlepage%
|
||||||
|
;; produce a title page for articles
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define (chunk-skip-first-element-list)
|
||||||
|
;; forces the Table of Contents on separate page
|
||||||
|
'())
|
||||||
|
|
||||||
|
(define (list-element-list)
|
||||||
|
;; fixes bug in Table of Contents generation
|
||||||
|
'())
|
||||||
|
|
||||||
|
(define %root-filename%
|
||||||
|
;; The filename of the root HTML document (e.g, "index").
|
||||||
|
"index")
|
||||||
|
|
||||||
|
(define %shade-verbatim%
|
||||||
|
;; verbatim sections will be shaded if t(rue)
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %use-id-as-filename%
|
||||||
|
;; Use ID attributes as name for component HTML files?
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define %graphic-extensions%
|
||||||
|
;; graphic extensions allowed
|
||||||
|
'("gif" "png" "jpg" "jpeg" "tif" "tiff" "eps" "epsf" ))
|
||||||
|
|
||||||
|
(define %graphic-default-extension%
|
||||||
|
"gif")
|
||||||
|
|
||||||
|
(define %section-autolabel%
|
||||||
|
;; For enumerated sections (1.1, 1.1.1, 1.2, etc.)
|
||||||
|
#t)
|
||||||
|
|
||||||
|
(define (toc-depth nd)
|
||||||
|
;; more depth (2 levels) to toc; instead of flat hierarchy
|
||||||
|
2)
|
||||||
|
|
||||||
|
(element emphasis
|
||||||
|
;; make role=strong equate to bold for emphasis tag
|
||||||
|
(if (equal? (attribute-string "role") "strong")
|
||||||
|
(make element gi: "STRONG" (process-children))
|
||||||
|
(make element gi: "EM" (process-children))))
|
||||||
|
|
||||||
|
(define (book-titlepage-recto-elements)
|
||||||
|
;; elements on a book's titlepage
|
||||||
|
(list (normalize "title")
|
||||||
|
(normalize "subtitle")
|
||||||
|
(normalize "graphic")
|
||||||
|
(normalize "mediaobject")
|
||||||
|
(normalize "corpauthor")
|
||||||
|
(normalize "authorgroup")
|
||||||
|
(normalize "author")
|
||||||
|
(normalize "othercredit")
|
||||||
|
(normalize "contrib")
|
||||||
|
(normalize "edition")
|
||||||
|
(normalize "releaseinfo")
|
||||||
|
(normalize "publisher")
|
||||||
|
(normalize "editor")
|
||||||
|
(normalize "copyright")
|
||||||
|
(normalize "pubdate")
|
||||||
|
(normalize "revhistory")
|
||||||
|
(normalize "abstract")
|
||||||
|
(normalize "legalnotice")))
|
||||||
|
|
||||||
|
(define (article-titlepage-recto-elements)
|
||||||
|
;; elements on an article's titlepage
|
||||||
|
(list (normalize "title")
|
||||||
|
(normalize "subtitle")
|
||||||
|
(normalize "authorgroup")
|
||||||
|
(normalize "author")
|
||||||
|
(normalize "othercredit")
|
||||||
|
(normalize "releaseinfo")
|
||||||
|
(normalize "copyright")
|
||||||
|
(normalize "pubdate")
|
||||||
|
(normalize "revhistory")
|
||||||
|
(normalize "abstract")
|
||||||
|
(normalize "legalnotice")))
|
||||||
|
|
||||||
|
(define (process-contrib #!optional (sosofo (process-children)))
|
||||||
|
;; print out with othercredit information; for translators, etc.
|
||||||
|
(make sequence
|
||||||
|
(make element gi: "SPAN"
|
||||||
|
attributes: (list (list "CLASS" (gi)))
|
||||||
|
(process-children))))
|
||||||
|
|
||||||
|
(define (process-othercredit #!optional (sosofo (process-children)))
|
||||||
|
;; print out othercredit information; for translators, etc.
|
||||||
|
(let ((author-name (author-string))
|
||||||
|
(author-contrib (select-elements (children (current-node))
|
||||||
|
(normalize "contrib"))))
|
||||||
|
(make element gi: "P"
|
||||||
|
attributes: (list (list "CLASS" (gi)))
|
||||||
|
(make element gi: "B"
|
||||||
|
(literal author-name)
|
||||||
|
(literal " - "))
|
||||||
|
(process-node-list author-contrib))))
|
||||||
|
|
||||||
|
(mode article-titlepage-recto-mode
|
||||||
|
(element contrib (process-contrib))
|
||||||
|
(element othercredit (process-othercredit))
|
||||||
|
)
|
||||||
|
|
||||||
|
(mode book-titlepage-recto-mode
|
||||||
|
(element contrib (process-contrib))
|
||||||
|
(element othercredit (process-othercredit))
|
||||||
|
)
|
||||||
|
|
||||||
|
(define (article-title nd)
|
||||||
|
(let* ((artchild (children nd))
|
||||||
|
(artheader (select-elements artchild (normalize "artheader")))
|
||||||
|
(artinfo (select-elements artchild (normalize "articleinfo")))
|
||||||
|
(ahdr (if (node-list-empty? artheader)
|
||||||
|
artinfo
|
||||||
|
artheader))
|
||||||
|
(ahtitles (select-elements (children ahdr)
|
||||||
|
(normalize "title")))
|
||||||
|
(artitles (select-elements artchild (normalize "title")))
|
||||||
|
(titles (if (node-list-empty? artitles)
|
||||||
|
ahtitles
|
||||||
|
artitles)))
|
||||||
|
(if (node-list-empty? titles)
|
||||||
|
""
|
||||||
|
(node-list-first titles))))
|
||||||
|
|
||||||
|
(mode subtitle-mode
|
||||||
|
;; do not print subtitle on subsequent pages
|
||||||
|
(element subtitle (empty-sosofo)))
|
||||||
|
|
||||||
|
;; Redefinition of $verbatim-display$
|
||||||
|
;; Origin: dbverb.dsl
|
||||||
|
;; Different foreground and background colors for verbatim elements
|
||||||
|
;; Author: Philippe Martin (feloy@free.fr) 2001-04-07
|
||||||
|
|
||||||
|
(define ($verbatim-display$ indent line-numbers?)
|
||||||
|
(let ((verbatim-element (gi))
|
||||||
|
(content (make element gi: "PRE"
|
||||||
|
attributes: (list
|
||||||
|
(list "CLASS" (gi)))
|
||||||
|
(if (or indent line-numbers?)
|
||||||
|
($verbatim-line-by-line$ indent line-numbers?)
|
||||||
|
(process-children)))))
|
||||||
|
(if %shade-verbatim%
|
||||||
|
(make element gi: "TABLE"
|
||||||
|
attributes: (shade-verbatim-attr-element verbatim-element)
|
||||||
|
(make element gi: "TR"
|
||||||
|
(make element gi: "TD"
|
||||||
|
(make element gi: "FONT"
|
||||||
|
attributes: (list
|
||||||
|
(list "COLOR" (car (shade-verbatim-element-colors
|
||||||
|
verbatim-element))))
|
||||||
|
content))))
|
||||||
|
content)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; Customize this function
|
||||||
|
;; to change the foreground and background colors
|
||||||
|
;; of the different verbatim elements
|
||||||
|
;; Return (list "foreground color" "background color")
|
||||||
|
;;
|
||||||
|
(define (shade-verbatim-element-colors element)
|
||||||
|
(case element
|
||||||
|
(("SYNOPSIS") (list "#000000" "#6495ED"))
|
||||||
|
;; ...
|
||||||
|
;; Add your verbatim elements here
|
||||||
|
;; ...
|
||||||
|
(else (list "#000000" "#E0E0E0"))))
|
||||||
|
|
||||||
|
(define (shade-verbatim-attr-element element)
|
||||||
|
(list
|
||||||
|
(list "BORDER"
|
||||||
|
(cond
|
||||||
|
((equal? element (normalize "SCREEN")) "1")
|
||||||
|
(else "0")))
|
||||||
|
(list "BGCOLOR" (car (cdr (shade-verbatim-element-colors element))))
|
||||||
|
(list "WIDTH" ($table-width$))))
|
||||||
|
|
||||||
|
;; End of $verbatim-display$ redefinition
|
||||||
|
|
||||||
|
</style-specification-body>
|
||||||
|
</style-specification>
|
||||||
|
|
||||||
|
<external-specification id="docbook" document="docbook.dsl">
|
||||||
|
|
||||||
|
</style-sheet>
|
||||||
|
|
Loading…
Reference in New Issue