XML-XPathScript

 view release on metacpan or  search on metacpan

lib/XML/XPathScript/Stylesheet/DocBook2LaTeX.pm  view on Meta::CPAN

				  $self)) {
		$t->{pre}="\\begin{abstract}\n";
		$t->{post}="\\end{abstract}\n";
	} else {
		$t->{pre}=$t->{post}="";
	};

	return 1;
};

$t->{legalnotice}->{testcode}=sub {
	my ($self, $t)=@_;
	my $legalname = (langofnode($self) =~ m/^fr/i) ?
	  "Informations légales" :
		"Legal information";
	$t->{pre}="{\\def\\abstractname{$legalname}\\begin{abstract}\n";
	$t->{post}="\\end{abstract}}\n";
	return 1;
};

########################################################################
####
####                  Tables and graphics
####

# This is the hardest part: hairy semantics, special cases everywhere
# in sight, and the locality properties of XML are molested quite
# deeply in the resulting TeX. A pleasure.

# The reference for DocBook tables:
#      http://www.oasis-open.org/specs/a502.htm

# Warning, <informaltable>s are tables, but <table>s are table floats!
#    informaltable ::= (graphic+|mediaobject+|tgroup+)

# Informal tables and tables share almost all their code, and besides
# the differences between the two typesetting styles are intermixed
# in the TeX output. Therefore we let the tgroup template do all the
# grunt work.

$t->{informaltable}->{pre}=$t->{informaltable}->{post}="";

$t->{table}->{testcode}=sub {
	my ($self,$t)=@_;
	$t->{pre}=$t->{post}="";
	return $_doNotProcessTitles;
};

push(@footnote_blockers, "tgroup");
$t->{tgroup}->{testcode}=sub {
	my ($self, $t)=@_;

	my $numcols=findvalue('@cols',$self);

	my $title;
	if (findvalue('name(..)',$self) eq "table") {
		$title=apply_templates_under("../title",$self);
	};
	# So "defined($title)" is a valid test for "this is a formal table".

	my @styles=split m/,/,utf8tolatin1(findvalue('@tgroupstyle',$self));

	my @TeXspecs=map {&$typeset_tablecolumnpattern($_->{colspec},
												   "colspec",$self);
				  } _table_getcolspecs_onelevel($self);

	$TeXspecs[$#TeXspecs] =~ s/\|$//;

	$t->{pre}=join("",map {"\\".$_."{"} @styles)."\n";

	if ($fancytables) {
		if (defined $title) {
			# Yet another longtable bugware... (Why did I choose this package
			# in the first place ?)
			$t->{pre}.=<<"ADDCONTENTSLINE";
\\addtocounter{table}{1}
\\addcontentsline{lot}{table}{\\protect\\numberline{\\thetable}{$title}}
\\addtocounter{table}{-1}
ADDCONTENTSLINE
		} else {
			$t->{pre}.=<<"NOINCRTABLECOUNTER";
\\addtocounter{table}{-1}
NOINCRTABLECOUNTER
		};

		$t->{pre}.="\\begin{longtable}";
		$t->{pre}.="[H]" if (!defined $title);
	} else {
		$t->{pre}.="\\begin{table}" if (defined $title);
		$t->{pre}.="\\begin{center}
\\begin{tabular}";
	};

	$t->{pre}.="{|".join("",@TeXspecs)."|}\n";

	if ($fancytables) {
		$t->{post}="\\end{longtable}\n";
	} else {
		$t->{post}="\\end{tabular}
\\end{center}
";
		$t->{post}.="\\caption{$title}
\\end{table}\n" if (defined $title);
	};

	$t->{post}.=join("",map {"}"} @styles);

	my @tablenodes;
	foreach my $nodetype (qw(thead tbody tfoot)) {
		my ($node)=findnodes($nodetype,$self);
		push @tablenodes,$node;
	};

	if (! grep {defined $_} @tablenodes) {
		warn_at $self, "Nothing in table?!";
		return -1;
	};

	my @tableTeXs;
	eval {
		foreach my $node (@tablenodes) {



( run in 1.847 second using v1.01-cache-2.11-cpan-71847e10f99 )