View | Details | Raw Unified | Return to bug 24052
Collapse All | Expand All

(-)a/C4/Breeding.pm (-2 / +2 lines)
Lines 30-36 use C4::ImportBatch; Link Here
30
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
31
use C4::Languages;
31
use C4::Languages;
32
use Koha::Database;
32
use Koha::Database;
33
use Koha::XSLT_Handler;
33
use Koha::XSLT::Base;
34
34
35
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
35
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
36
36
Lines 163-169 sub Z3950Search { Link Here
163
                    _translate_query( $server, $squery )));
163
                    _translate_query( $server, $squery )));
164
        $s++;
164
        $s++;
165
    }
165
    }
166
    my $xslh = Koha::XSLT_Handler->new;
166
    my $xslh = Koha::XSLT::Base->new;
167
167
168
    my $nremaining = $s;
168
    my $nremaining = $s;
169
    while ( $nremaining-- ) {
169
    while ( $nremaining-- ) {
(-)a/C4/Record.pm (-2 / +2 lines)
Lines 34-40 use Template; Link Here
34
use Text::CSV::Encoded; #marc2csv
34
use Text::CSV::Encoded; #marc2csv
35
use Koha::Items;
35
use Koha::Items;
36
use Koha::SimpleMARC qw(read_field);
36
use Koha::SimpleMARC qw(read_field);
37
use Koha::XSLT_Handler;
37
use Koha::XSLT::Base;
38
use Koha::CsvProfiles;
38
use Koha::CsvProfiles;
39
use Koha::AuthorisedValues;
39
use Koha::AuthorisedValues;
40
use Carp;
40
use Carp;
Lines 291-297 sub marc2dcxml { Link Here
291
            carp "\t". $warn;
291
            carp "\t". $warn;
292
        };
292
        };
293
    } elsif ( $record =~ /^MARC::Record/ ) { # if OK makes xslt transformation
293
    } elsif ( $record =~ /^MARC::Record/ ) { # if OK makes xslt transformation
294
        my $xslt_engine = Koha::XSLT_Handler->new;
294
        my $xslt_engine = Koha::XSLT::Base->new;
295
        if ( $format =~ /^(dc|oaidc|srwdc|rdfdc)$/i ) {
295
        if ( $format =~ /^(dc|oaidc|srwdc|rdfdc)$/i ) {
296
            $output = $xslt_engine->transform( $marcxml, $xsl );
296
            $output = $xslt_engine->transform( $marcxml, $xsl );
297
        } else {
297
        } else {
(-)a/C4/XSLT.pm (-2 / +2 lines)
Lines 31-37 use C4::Circulation; Link Here
31
use C4::Reserves;
31
use C4::Reserves;
32
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
33
use Koha::ItemTypes;
33
use Koha::ItemTypes;
34
use Koha::XSLT_Handler;
34
use Koha::XSLT::Base;
35
use Koha::Libraries;
35
use Koha::Libraries;
36
36
37
use Encode;
37
use Encode;
Lines 49-55 BEGIN { Link Here
49
    @EXPORT = qw(
49
    @EXPORT = qw(
50
        &XSLTParse4Display
50
        &XSLTParse4Display
51
    );
51
    );
52
    $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } );
52
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
53
}
53
}
54
54
55
=head1 NAME
55
=head1 NAME
(-)a/Koha/OAI/Server/Record.pm (-1 / +1 lines)
Lines 47-53 sub new { Link Here
47
        my $args = {
47
        my $args = {
48
            OPACBaseURL => "'" . C4::Context->preference('OPACBaseURL') . "'"
48
            OPACBaseURL => "'" . C4::Context->preference('OPACBaseURL') . "'"
49
        };
49
        };
50
        # call Koha::XSLT_Handler now
50
        # call Koha::XSLT::Base now
51
        $record_dom = $repository->{xslt_engine}->transform({
51
        $record_dom = $repository->{xslt_engine}->transform({
52
            xml        => $marcxml,
52
            xml        => $marcxml,
53
            file       => $repository->stylesheet($format),
53
            file       => $repository->stylesheet($format),
(-)a/Koha/OAI/Server/Repository.pm (-2 / +2 lines)
Lines 36-42 use YAML::Syck qw( LoadFile ); Link Here
36
use CGI qw/:standard -oldstyle_urls/;
36
use CGI qw/:standard -oldstyle_urls/;
37
use C4::Context;
37
use C4::Context;
38
use C4::Biblio;
38
use C4::Biblio;
39
use Koha::XSLT_Handler;
39
use Koha::XSLT::Base;
40
40
41
=head1 NAME
41
=head1 NAME
42
42
Lines 104-110 sub new { Link Here
104
    $self->{ koha_identifier      } = C4::Context->preference("OAI-PMH:archiveID");
104
    $self->{ koha_identifier      } = C4::Context->preference("OAI-PMH:archiveID");
105
    $self->{ koha_max_count       } = C4::Context->preference("OAI-PMH:MaxCount");
105
    $self->{ koha_max_count       } = C4::Context->preference("OAI-PMH:MaxCount");
106
    $self->{ koha_metadata_format } = ['oai_dc', 'marc21', 'marcxml'];
106
    $self->{ koha_metadata_format } = ['oai_dc', 'marc21', 'marcxml'];
107
    $self->{ xslt_engine          } = Koha::XSLT_Handler->new;
107
    $self->{ xslt_engine          } = Koha::XSLT::Base->new;
108
108
109
    # Load configuration file if defined in OAI-PMH:ConfFile syspref
109
    # Load configuration file if defined in OAI-PMH:ConfFile syspref
110
    if ( my $file = C4::Context->preference("OAI-PMH:ConfFile") ) {
110
    if ( my $file = C4::Context->preference("OAI-PMH:ConfFile") ) {
(-)a/Koha/XSLT_Handler.pm (-12 lines)
Lines 1-12 Link Here
1
package Koha::XSLT_Handler;
2
# This is just a stub; will be removed later on
3
use Modern::Perl;
4
use base qw(Koha::XSLT::Base);
5
use constant XSLTH_ERR_1    => 'XSLTH_ERR_NO_FILE';
6
use constant XSLTH_ERR_2    => 'XSLTH_ERR_FILE_NOT_FOUND';
7
use constant XSLTH_ERR_3    => 'XSLTH_ERR_LOADING';
8
use constant XSLTH_ERR_4    => 'XSLTH_ERR_PARSING_CODE';
9
use constant XSLTH_ERR_5    => 'XSLTH_ERR_PARSING_DATA';
10
use constant XSLTH_ERR_6    => 'XSLTH_ERR_TRANSFORMING';
11
use constant XSLTH_ERR_7    => 'XSLTH_NO_STRING_PASSED';
12
1;
(-)a/opac/unapi (-2 / +2 lines)
Lines 39-45 an XML format such as OAI DC, RSS2, MARCXML, or MODS. Link Here
39
use CGI qw ( -utf8 );
39
use CGI qw ( -utf8 );
40
use C4::Context;
40
use C4::Context;
41
use C4::Biblio;
41
use C4::Biblio;
42
use Koha::XSLT_Handler;
42
use Koha::XSLT::Base;
43
43
44
my $cgi = CGI->new();
44
my $cgi = CGI->new();
45
binmode(STDOUT, ":encoding(UTF-8)"); #output as utf8
45
binmode(STDOUT, ":encoding(UTF-8)"); #output as utf8
Lines 141-147 if (not defined $format) { Link Here
141
            print $cgi->header( -status => '406 invalid format requested' );
141
            print $cgi->header( -status => '406 invalid format requested' );
142
            exit 0;
142
            exit 0;
143
        }
143
        }
144
        my $xslt_engine = Koha::XSLT_Handler->new;
144
        my $xslt_engine = Koha::XSLT::Base->new;
145
        $content = $xslt_engine->transform({
145
        $content = $xslt_engine->transform({
146
            xml => $marcxml,
146
            xml => $marcxml,
147
            file => $xslt_file,
147
            file => $xslt_file,
(-)a/t/db_dependent/Breeding.t (-3 / +3 lines)
Lines 34-40 use t::lib::Mocks qw( mock_preference ); Link Here
34
use C4::Context;
34
use C4::Context;
35
use C4::Breeding;
35
use C4::Breeding;
36
use Koha::Database;
36
use Koha::Database;
37
use Koha::XSLT_Handler;
37
use Koha::XSLT::Base;
38
38
39
my $schema = Koha::Database->new->schema;
39
my $schema = Koha::Database->new->schema;
40
$schema->storage->txn_begin;
40
$schema->storage->txn_begin;
Lines 208-214 sub test_do_xslt { Link Here
208
    );
208
    );
209
    my $file= $FindBin::Bin.'/XSLT_Handler/test01.xsl';
209
    my $file= $FindBin::Bin.'/XSLT_Handler/test01.xsl';
210
    my $server= { add_xslt => $file };
210
    my $server= { add_xslt => $file };
211
    my $engine=Koha::XSLT_Handler->new;
211
    my $engine=Koha::XSLT::Base->new;
212
212
213
    #ready for the main test
213
    #ready for the main test
214
    my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
214
    my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
Lines 219-225 sub test_do_xslt { Link Here
219
    #forcing an error on the xslt side
219
    #forcing an error on the xslt side
220
    $server->{add_xslt} = 'notafile.xsl';
220
    $server->{add_xslt} = 'notafile.xsl';
221
    @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
221
    @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
222
    is( $res[1], Koha::XSLT_Handler::XSLTH_ERR_2, 'Error code found' );
222
    is( $res[1], Koha::XSLT::Base::XSLTH_ERR_2, 'Error code found' );
223
    #We still expect the original record back
223
    #We still expect the original record back
224
    is( ref $res[0], 'MARC::Record', 'Still got back MARC record' );
224
    is( ref $res[0], 'MARC::Record', 'Still got back MARC record' );
225
    is ( $res[0]->subfield('245','a'), 'Just a title',
225
    is ( $res[0]->subfield('245','a'), 'Just a title',
(-)a/t/db_dependent/XSLT_Handler.t (-12 / +11 lines)
Lines 24-39 use File::Slurp; Link Here
24
use Test::More tests => 35;
24
use Test::More tests => 35;
25
use Test::Warn;
25
use Test::Warn;
26
26
27
use Koha::XSLT_Handler;
27
use Koha::XSLT::Base;
28
28
29
my $engine=Koha::XSLT_Handler->new;
29
my $engine=Koha::XSLT::Base->new;
30
is( ref $engine, 'Koha::XSLT_Handler', 'Testing creation of handler object' );
30
is( ref $engine, 'Koha::XSLT::Base', 'Testing creation of handler object' );
31
31
32
$engine->transform('');
32
$engine->transform('');
33
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_1, 'Engine returns error on no file' );
33
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_1, 'Engine returns error on no file' );
34
34
35
$engine->transform( '', 'thisfileshouldnotexist.%$#@' );
35
$engine->transform( '', 'thisfileshouldnotexist.%$#@' );
36
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_2, 'Engine returns error on bad file' );
36
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_2, 'Engine returns error on bad file' );
37
is( $engine->refresh( 'asdjhaskjh'), 0, 'Test on invalid refresh' );
37
is( $engine->refresh( 'asdjhaskjh'), 0, 'Test on invalid refresh' );
38
38
39
#check first test xsl
39
#check first test xsl
Lines 48-75 my $output; Link Here
48
48
49
# Undefined text tests
49
# Undefined text tests
50
$output = $engine->transform( undef, $xsltfile_1 );
50
$output = $engine->transform( undef, $xsltfile_1 );
51
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_7, 'Engine returns error on undefined text' );
51
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_7, 'Engine returns error on undefined text' );
52
52
53
# Empty string tests
53
# Empty string tests
54
$output = $engine->transform( '', $xsltfile_1 );
54
$output = $engine->transform( '', $xsltfile_1 );
55
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on empty string' );
55
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on empty string' );
56
56
57
# Non-XML tests
57
# Non-XML tests
58
$engine->print_warns(1);
58
$engine->print_warns(1);
59
warning_like { $output = $engine->transform( 'abcdef', $xsltfile_1 ) }
59
warning_like { $output = $engine->transform( 'abcdef', $xsltfile_1 ) }
60
    qr{parser error : Start tag expected, '<' not found},
60
    qr{parser error : Start tag expected, '<' not found},
61
    "Non-XML warning correctly displayed";
61
    "Non-XML warning correctly displayed";
62
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on non-xml' );
62
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on non-xml' );
63
63
64
# Malformed XML tests
64
# Malformed XML tests
65
warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) }
65
warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) }
66
    qr{parser error : Opening and ending tag mismatch: a line 1 and b},
66
    qr{parser error : Opening and ending tag mismatch: a line 1 and b},
67
    "Malformed XML warning correctly displayed";
67
    "Malformed XML warning correctly displayed";
68
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on malformed xml' );
68
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on malformed xml' );
69
69
70
#Test not returning source on failure when asked for
70
#Test not returning source on failure when asked for
71
#Include passing do_not_return via constructor on second engine
71
#Include passing do_not_return via constructor on second engine
72
my $secondengine=Koha::XSLT_Handler->new( {
72
my $secondengine=Koha::XSLT::Base->new( {
73
    do_not_return_source => 'very_true',
73
    do_not_return_source => 'very_true',
74
    some_unknown_attrib  => 'just_for_fun',
74
    some_unknown_attrib  => 'just_for_fun',
75
});
75
});
Lines 142-148 $xsltfile_2= $path.$xsltfile_2; Link Here
142
142
143
$engine->print_warns(0);
143
$engine->print_warns(0);
144
$output = $engine->transform( $xml_2, $xsltfile_2 );
144
$output = $engine->transform( $xml_2, $xsltfile_2 );
145
is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_4, 'Engine returned error for parsing bad xsl' );
145
is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_4, 'Engine returned error for parsing bad xsl' );
146
146
147
#The third test xsl is okay again; main use is clearing two items from cache
147
#The third test xsl is okay again; main use is clearing two items from cache
148
my $xsltfile_3 = 'test03.xsl';
148
my $xsltfile_3 = 'test03.xsl';
149
- 

Return to bug 24052