From: Dobrica Pavlinusic Date: Thu, 14 Nov 2013 15:07:34 +0000 (+0100) Subject: format output using XSLT X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=cfc5214caacaeedc7b954f866fd900b8bcafca0f;p=koha-bibliografija format output using XSLT --- diff --git a/html.pl b/html.pl index 16e1e7e..2ba0d2c 100755 --- a/html.pl +++ b/html.pl @@ -12,9 +12,13 @@ use locale; use lib '/srv/koha_ffzg'; use C4::Context; +use XML::LibXML; +use XML::LibXSLT; my $dbh = C4::Context->dbh; +my $xslfilename = 'compact.xsl'; + my $authors; my $sth_select_authors = $dbh->prepare(q{ @@ -71,6 +75,29 @@ sub html_end { return qq|\nprepare(q{ +select marcxml from biblioitems where biblionumber = ? +}); + +sub biblioitem_html { + my $biblionumber = shift; + + $sth_marcxml->execute( $biblionumber ); + my $xmlrecord = $sth_marcxml->fetchrow_arrayref->[0]; + + my $parser = XML::LibXML->new(); + $parser->recover_silently(0); # don't die when you find &, >, etc + my $source = $parser->parse_string($xmlrecord); + my $style_doc = $parser->parse_file($xslfilename); + + my $xslt = XML::LibXSLT->new(); + my $parsed = $xslt->parse_stylesheet($style_doc); + my $transformed = $parsed->transform($source); + return $parsed->output_string( $transformed ); +} + + mkdir 'html' unless -d 'html'; open(my $index, '>:encoding(utf-8)', 'html/index.html'); @@ -93,7 +120,7 @@ foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) { foreach my $category ( sort keys %{ $authors->{ $row->{authid} } } ) { print $fh qq|

$category

\n\n|; }