@@ -, +, @@ target and check if you see a error 'XSLT file not found'. --- C4/Breeding.pm | 2 +- C4/Record.pm | 5 ++-- .../prog/en/includes/xslt-handler.inc | 16 +++++++++++++ .../prog/en/modules/cataloguing/z3950_search.tt | 4 ++-- .../bootstrap/en/includes/xslt-handler.inc | 16 +++++++++++++ t/db_dependent/Breeding.t | 27 +++++++--------------- 6 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc --- a/C4/Breeding.pm +++ a/C4/Breeding.pm @@ -316,7 +316,7 @@ sub _do_xslt_proc { if( !$xslh->err ) { return MARC::Record->new_from_xml($xml, 'UTF-8'); } else { - return ( $marc, 'xslt_err' ); #original record in case of errors + return ( $marc, $xslh->err ); #original record in case of errors } } --- a/C4/Record.pm +++ a/C4/Record.pm @@ -300,10 +300,9 @@ sub marc2dcxml { croak "The format argument ($format) not accepted.\n" . "Please pass a valid format (oaidc, srwdc, or rdfdc)\n"; } - my $err = $xslt_engine->err; # error number - my $errstr = $xslt_engine->errstr; # error message + my $err = $xslt_engine->err; # error code if ( $err ) { - croak "Error when processing $errstr Error number: $err\n"; + croak "Error $err while processing\n"; } else { return $output; } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc @@ -0,0 +1,16 @@ +[% SWITCH code %] + [% CASE 'XSLTH_ERR_NO_FILE' %] + No XSLT file passed. + [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %] + XSLT file not found. + [% CASE 'XSLTH_ERR_LOADING' %] + Error while loading stylesheet. + [% CASE 'XSLTH_ERR_PARSING_CODE' %] + Error while parsing stylesheet. + [% CASE 'XSLTH_ERR_PARSING_DATA' %] + Error while parsing input. + [% CASE 'XSLTH_ERR_TRANSFORMING' %] + Error while transforming input. + [% CASE 'XSLTH_NO_STRING_PASSED' %] + No string to transform. +[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt @@ -82,7 +82,7 @@ [% FOREACH errcon IN errconn %] [% IF ( errcon.error == '10000' ) %]
  • Connection failed to [% errcon.server %]
  • [% ELSIF ( errcon.error == '10007' ) %]
  • Connection timeout to [% errcon.server %]
  • - [% ELSIF ( errcon.error == 'xslt_err' ) %]
  • [% errcon.server %]: Warning: XSLT error on search result [% errcon.seq %]
  • + [% ELSIF errcon.error.match( '^XSLTH' ) %]
  • [% errcon.server %] record [% errcon.seq %]: [% PROCESS 'xslt-handler.inc' code=errcon.error %]
  • [% ELSE %]
  • [% errcon.server %] record [% errcon.seq %]: [% errcon.error %]
  • [% END %] [% END %] @@ -245,4 +245,4 @@ [% INCLUDE 'z3950_search.inc' %] [% END %] -[% INCLUDE 'intranet-bottom.inc' popup_window=1 %] +[% INCLUDE 'intranet-bottom.inc' popup_window=1 %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc @@ -0,0 +1,16 @@ +[% SWITCH code %] + [% CASE 'XSLTH_ERR_NO_FILE' %] + No XSLT file passed. + [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %] + XSLT file not found. + [% CASE 'XSLTH_ERR_LOADING' %] + Error while loading stylesheet. + [% CASE 'XSLTH_ERR_PARSING_CODE' %] + Error while parsing stylesheet. + [% CASE 'XSLTH_ERR_PARSING_DATA' %] + Error while parsing input. + [% CASE 'XSLTH_ERR_TRANSFORMING' %] + Error while transforming input. + [% CASE 'XSLTH_NO_STRING_PASSED' %] + No string to transform. +[% END %] --- a/t/db_dependent/Breeding.t +++ a/t/db_dependent/Breeding.t @@ -46,7 +46,7 @@ subtest '_create_connection' => sub { }; #Group 3: testing _do_xslt_proc (part of Z3950Search) subtest '_do_xslt_proc' => sub { - plan tests => 7; + plan tests => 6; test_do_xslt(); }; @@ -162,27 +162,16 @@ sub test_do_xslt { #ready for the main test my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); - is( $res[1] && $res[1] eq 'xslt_err', undef, - 'Check error code of _do_xslt_proc'); - if( !$res[1] ) { - is( ref $res[0] eq 'MARC::Record', 1, 'Got back MARC record'); - my $sub = $res[0]->subfield('990','a')//''; - is( $sub eq 'I saw you', 1, 'Found 990a in the record'); - } else { - ok( 1, 'Skipped one test'); - ok( 1, 'Skipped another one'); - } + is( $res[1], undef, 'No error returned' ); + is( ref $res[0], 'MARC::Record', 'Got back MARC record'); + is( $res[0]->subfield('990','a'), 'I saw you', 'Found 990a in the record'); #forcing an error on the xslt side $server->{add_xslt} = 'notafile.xsl'; - warning_like - { @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ) } - qr/^XSLT file not found./, - '_do_xslt_proc warns it XSLT_handler problem'; - is( $res[1] && $res[1] eq 'xslt_err', 1, - 'Check error code again'); + @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); + is( $res[1], Koha::XSLT_Handler::XSLTH_ERR_2, 'Error code found' ); #We still expect the original record back - is( ref $res[0] eq 'MARC::Record', 1, 'Still got back MARC record'); - is ( $res[0]->subfield('245','a') eq 'Just a title', 1, + is( ref $res[0], 'MARC::Record', 'Still got back MARC record' ); + is ( $res[0]->subfield('245','a'), 'Just a title', 'At least the title is the same :)' ); } --