← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:02:24 2013

Filename/usr/lib/perl5/XML/LibXSLT.pm
StatementsExecuted 1312 statements in 69.8ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114.8ms14.8msXML::LibXSLT::::_parse_stylesheet XML::LibXSLT::_parse_stylesheet (xsub)
25111.25ms2.25msXML::LibXSLT::StylesheetWrapper::::_init_callbacksXML::LibXSLT::StylesheetWrapper::_init_callbacks
25111.04ms50.4msXML::LibXSLT::StylesheetWrapper::::transformXML::LibXSLT::StylesheetWrapper::transform
2511517µs1.04msXML::LibXSLT::StylesheetWrapper::::_cleanup_callbacksXML::LibXSLT::StylesheetWrapper::_cleanup_callbacks
5021368µs368µsXML::LibXSLT::StylesheetWrapper::::match_callbackXML::LibXSLT::StylesheetWrapper::match_callback
2511262µs1.72msXML::LibXSLT::StylesheetWrapper::::output_stringXML::LibXSLT::StylesheetWrapper::output_string
111190µs190µsXML::LibXSLT::::bootstrap XML::LibXSLT::bootstrap (xsub)
2511159µs159µsXML::LibXSLT::StylesheetWrapper::::open_callbackXML::LibXSLT::StylesheetWrapper::open_callback
2511153µs153µsXML::LibXSLT::StylesheetWrapper::::read_callbackXML::LibXSLT::StylesheetWrapper::read_callback
2511144µs144µsXML::LibXSLT::StylesheetWrapper::::close_callbackXML::LibXSLT::StylesheetWrapper::close_callback
2621117µs117µsXML::LibXSLT::::lib_init_callbacks XML::LibXSLT::lib_init_callbacks (xsub)
11155µs15.0msXML::LibXSLT::::parse_stylesheet XML::LibXSLT::parse_stylesheet
11148µs93µsXML::LibXSLT::::_init_callbacks XML::LibXSLT::_init_callbacks
11135µs603µsXML::LibXSLT::::BEGIN@23 XML::LibXSLT::BEGIN@23
11124µs31µsXML::LibXSLT::::BEGIN@11 XML::LibXSLT::BEGIN@11
11120µs20µsXML::LibXSLT::::new XML::LibXSLT::new
11120µs427µsXML::LibXSLT::::BEGIN@16 XML::LibXSLT::BEGIN@16
11119µs44µsXML::LibXSLT::::_cleanup_callbacks XML::LibXSLT::_cleanup_callbacks
11118µs23µsXML::LibXSLT::Security::::BEGIN@503 XML::LibXSLT::Security::BEGIN@503
11117µs17µsXML::LibXSLT::::BEGIN@17 XML::LibXSLT::BEGIN@17
11117µs23µsXML::LibXSLT::StylesheetWrapper::::BEGIN@309XML::LibXSLT::StylesheetWrapper::BEGIN@309
11116µs16µsXML::LibXSLT::::BEGIN@20 XML::LibXSLT::BEGIN@20
11114µs14µsXML::LibXSLT::::BEGIN@18 XML::LibXSLT::BEGIN@18
11114µs69µsXML::LibXSLT::::BEGIN@24 XML::LibXSLT::BEGIN@24
11114µs124µsXML::LibXSLT::::BEGIN@12 XML::LibXSLT::BEGIN@12
11114µs106µsXML::LibXSLT::StylesheetWrapper::::BEGIN@313XML::LibXSLT::StylesheetWrapper::BEGIN@313
11113µs13µsXML::LibXSLT::::BEGIN@19 XML::LibXSLT::BEGIN@19
11112µs35µsXML::LibXSLT::::BEGIN@79 XML::LibXSLT::BEGIN@79
11112µs269µsXML::LibXSLT::StylesheetWrapper::::BEGIN@312XML::LibXSLT::StylesheetWrapper::BEGIN@312
22111µs11µsXML::LibXSLT::::match_callback XML::LibXSLT::match_callback
11111µs59µsXML::LibXSLT::Security::::BEGIN@504 XML::LibXSLT::Security::BEGIN@504
11111µs84µsXML::LibXSLT::StylesheetWrapper::::BEGIN@310XML::LibXSLT::StylesheetWrapper::BEGIN@310
1119µs51µsXML::LibXSLT::Security::::BEGIN@506 XML::LibXSLT::Security::BEGIN@506
1116µs6µsXML::LibXSLT::::open_callback XML::LibXSLT::open_callback
1115µs5µsXML::LibXSLT::::read_callback XML::LibXSLT::read_callback
1114µs4µsXML::LibXSLT::::close_callback XML::LibXSLT::close_callback
1111µs1µsXML::LibXSLT::::REQUIRE_XML_LIBXML_ABI_VERSION XML::LibXSLT::REQUIRE_XML_LIBXML_ABI_VERSION
0000s0sXML::LibXSLT::Security::::_security_check XML::LibXSLT::Security::_security_check
0000s0sXML::LibXSLT::Security::::cleanup_callbacks XML::LibXSLT::Security::cleanup_callbacks
0000s0sXML::LibXSLT::Security::::init_callbacks XML::LibXSLT::Security::init_callbacks
0000s0sXML::LibXSLT::Security::::new XML::LibXSLT::Security::new
0000s0sXML::LibXSLT::Security::::register_callback XML::LibXSLT::Security::register_callback
0000s0sXML::LibXSLT::Security::::unregister_callback XML::LibXSLT::Security::unregister_callback
0000s0sXML::LibXSLT::StylesheetWrapper::::callbacksXML::LibXSLT::StylesheetWrapper::callbacks
0000s0sXML::LibXSLT::StylesheetWrapper::::input_callbacksXML::LibXSLT::StylesheetWrapper::input_callbacks
0000s0sXML::LibXSLT::StylesheetWrapper::::media_typeXML::LibXSLT::StylesheetWrapper::media_type
0000s0sXML::LibXSLT::StylesheetWrapper::::output_as_bytesXML::LibXSLT::StylesheetWrapper::output_as_bytes
0000s0sXML::LibXSLT::StylesheetWrapper::::output_as_charsXML::LibXSLT::StylesheetWrapper::output_as_chars
0000s0sXML::LibXSLT::StylesheetWrapper::::output_encodingXML::LibXSLT::StylesheetWrapper::output_encoding
0000s0sXML::LibXSLT::StylesheetWrapper::::output_fhXML::LibXSLT::StylesheetWrapper::output_fh
0000s0sXML::LibXSLT::StylesheetWrapper::::output_fileXML::LibXSLT::StylesheetWrapper::output_file
0000s0sXML::LibXSLT::StylesheetWrapper::::security_callbacksXML::LibXSLT::StylesheetWrapper::security_callbacks
0000s0sXML::LibXSLT::StylesheetWrapper::::transform_fileXML::LibXSLT::StylesheetWrapper::transform_file
0000s0sXML::LibXSLT::::callbacks XML::LibXSLT::callbacks
0000s0sXML::LibXSLT::::input_callbacks XML::LibXSLT::input_callbacks
0000s0sXML::LibXSLT::::parse_stylesheet_file XML::LibXSLT::parse_stylesheet_file
0000s0sXML::LibXSLT::::perl_dispatcher XML::LibXSLT::perl_dispatcher
0000s0sXML::LibXSLT::::register_xslt_module XML::LibXSLT::register_xslt_module
0000s0sXML::LibXSLT::::security_callbacks XML::LibXSLT::security_callbacks
0000s0sXML::LibXSLT::::xpath_to_string XML::LibXSLT::xpath_to_string
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: LibXSLT.pm 228 2009-10-07 12:25:23Z pajas $
2#
3# This is free software, you may use it and distribute it under the same terms as
4# Perl itself.
5#
6# Copyright 2001-2009 AxKit.com Ltd.
7#
8#
9package XML::LibXSLT;
10
11339µs237µs
# spent 31µs (24+7) within XML::LibXSLT::BEGIN@11 which was called: # once (24µs+7µs) by C4::XSLT::BEGIN@35 at line 11
use strict;
# spent 31µs making 1 call to XML::LibXSLT::BEGIN@11 # spent 6µs making 1 call to strict::import
12359µs2235µs
# spent 124µs (14+111) within XML::LibXSLT::BEGIN@12 which was called: # once (14µs+111µs) by C4::XSLT::BEGIN@35 at line 12
use vars qw($VERSION @ISA $USE_LIBXML_DATA_TYPES $MatchCB $ReadCB $OpenCB $CloseCB);
# spent 124µs making 1 call to XML::LibXSLT::BEGIN@12 # spent 111µs making 1 call to vars::import
13
1413µs
# spent 1µs within XML::LibXSLT::REQUIRE_XML_LIBXML_ABI_VERSION which was called: # once (1µs+0s) by XML::LibXML::VERSION at line 41 of XML/LibXML.pm
sub REQUIRE_XML_LIBXML_ABI_VERSION { 2 }
15
16360µs3834µs
# spent 427µs (20+407) within XML::LibXSLT::BEGIN@16 which was called: # once (20µs+407µs) by C4::XSLT::BEGIN@35 at line 16
use XML::LibXML 1.70;
# spent 427µs making 1 call to XML::LibXSLT::BEGIN@16 # spent 346µs making 1 call to XML::LibXML::import # spent 61µs making 1 call to XML::LibXML::VERSION
17352µs117µs
# spent 17µs within XML::LibXSLT::BEGIN@17 which was called: # once (17µs+0s) by C4::XSLT::BEGIN@35 at line 17
use XML::LibXML::Literal;
# spent 17µs making 1 call to XML::LibXSLT::BEGIN@17
18348µs114µs
# spent 14µs within XML::LibXSLT::BEGIN@18 which was called: # once (14µs+0s) by C4::XSLT::BEGIN@35 at line 18
use XML::LibXML::Boolean;
# spent 14µs making 1 call to XML::LibXSLT::BEGIN@18
19352µs113µs
# spent 13µs within XML::LibXSLT::BEGIN@19 which was called: # once (13µs+0s) by C4::XSLT::BEGIN@35 at line 19
use XML::LibXML::Number;
# spent 13µs making 1 call to XML::LibXSLT::BEGIN@19
20342µs116µs
# spent 16µs within XML::LibXSLT::BEGIN@20 which was called: # once (16µs+0s) by C4::XSLT::BEGIN@35 at line 20
use XML::LibXML::NodeList;
# spent 16µs making 1 call to XML::LibXSLT::BEGIN@20
21
22
23
# spent 603µs (35+567) within XML::LibXSLT::BEGIN@23 which was called: # once (35µs+567µs) by C4::XSLT::BEGIN@35 at line 44
BEGIN {
243124µs2123µs
# spent 69µs (14+55) within XML::LibXSLT::BEGIN@24 which was called: # once (14µs+55µs) by C4::XSLT::BEGIN@35 at line 24
use Carp;
# spent 69µs making 1 call to XML::LibXSLT::BEGIN@24 # spent 55µs making 1 call to Exporter::import
25
261900nsrequire Exporter;
27
281600ns$VERSION = "1.70";
29
301800nsrequire DynaLoader;
31
32112µs@ISA = qw(DynaLoader);
33
34# avoid possible shared library name conflict on Win32
35# not using this trick on 5.10.0 (suffering from DynaLoader bug)
3612µslocal $DynaLoader::dl_dlext = "xs.$DynaLoader::dl_dlext" if (($^O eq 'MSWin32') && ($] ne '5.010000'));
37
3816µs1563µsbootstrap XML::LibXSLT $VERSION;
# spent 563µs making 1 call to DynaLoader::bootstrap
39
40# the following magic lets XML::LibXSLT internals know
41# where to register XML::LibXML proxy nodes
4213µs14µsINIT_THREAD_SUPPORT() if XML::LibXML::threads_shared_enabled();
# spent 4µs making 1 call to XML::LibXML::threads_shared_enabled
4313µs$USE_LIBXML_DATA_TYPES = 0;
441224µs1603µs}
# spent 603µs making 1 call to XML::LibXSLT::BEGIN@23
45
46
47
# spent 20µs within XML::LibXSLT::new which was called: # once (20µs+0s) by C4::XSLT::XSLTParse4Display at line 229 of /usr/share/koha/lib/C4/XSLT.pm
sub new {
4811µs my $class = shift;
4912µs my %options = @_;
50113µs my $self = bless \%options, $class;
5115µs return $self;
52}
53
54# ido - perl dispatcher
55sub perl_dispatcher {
56 my $func = shift;
57 my @params = @_;
58 my @perlParams;
59
60 my $i = 0;
61 while (@params) {
62 my $type = shift(@params);
63 if ($type eq 'XML::LibXML::Literal' or
64 $type eq 'XML::LibXML::Number' or
65 $type eq 'XML::LibXML::Boolean')
66 {
67 my $val = shift(@params);
68 unshift(@perlParams, $USE_LIBXML_DATA_TYPES ? $type->new($val) : $val);
69 }
70 elsif ($type eq 'XML::LibXML::NodeList') {
71 my $node_count = shift(@params);
72 my @nodes = splice(@params, 0, $node_count);
73 # warn($_->getName) for @nodes;
74 unshift(@perlParams, $type->new(@nodes));
75 }
76 }
77
78 $func = "main::$func" unless ref($func) || $func =~ /(.+)::/;
7931.16ms258µs
# spent 35µs (12+23) within XML::LibXSLT::BEGIN@79 which was called: # once (12µs+23µs) by C4::XSLT::BEGIN@35 at line 79
no strict 'refs';
# spent 35µs making 1 call to XML::LibXSLT::BEGIN@79 # spent 23µs making 1 call to strict::unimport
80 my $res = $func->(@perlParams);
81 return $res;
82}
83
84
85sub xpath_to_string {
86 my @results;
87 while (@_) {
88 my $value = shift(@_); $value = '' unless defined $value;
89 push @results, $value;
90 if (@results % 2) {
91 # key
92 $results[-1] =~ s/:/_/g; # XSLT doesn't like names with colons
93 }
94 else {
95 if ($value =~ s/'/', "'", '/g) {
96 $results[-1] = "concat('$value')";
97 }
98 else {
99 $results[-1] = "'$results[-1]'";
100 }
101 }
102 }
103 return @results;
104}
105
106#-------------------------------------------------------------------------#
107# callback functions #
108#-------------------------------------------------------------------------#
109
110sub security_callbacks {
111 my $self = shift;
112 my $scbclass = shift;
113
114 if ( defined $scbclass ) {
115 $self->{XML_LIBXSLT_SECPREFS} = $scbclass;
116 }
117 return $self->{XML_LIBXSLT_SECPREFS};
118}
119
120sub input_callbacks {
121 my $self = shift;
122 my $icbclass = shift;
123
124 if ( defined $icbclass ) {
125 $self->{XML_LIBXSLT_CALLBACK_STACK} = $icbclass;
126 }
127 return $self->{XML_LIBXSLT_CALLBACK_STACK};
128}
129
130
# spent 11µs within XML::LibXSLT::match_callback which was called 2 times, avg 6µs/call: # once (6µs+0s) by XML::LibXSLT::_cleanup_callbacks at line 237 # once (5µs+0s) by XML::LibXSLT::_init_callbacks at line 221
sub match_callback {
13122µs my $self = shift;
13222µs if ( ref $self ) {
1332900ns if ( scalar @_ ) {
134 $self->{XML_LIBXSLT_MATCH_CB} = shift;
135 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
136 }
137211µs return $self->{XML_LIBXSLT_MATCH_CB};
138 }
139 else {
140 $MatchCB = shift if scalar @_;
141 return $MatchCB;
142 }
143}
144
145
# spent 5µs within XML::LibXSLT::read_callback which was called: # once (5µs+0s) by XML::LibXSLT::_init_callbacks at line 223
sub read_callback {
1461600ns my $self = shift;
1471700ns if ( ref $self ) {
1481600ns if ( scalar @_ ) {
149 $self->{XML_LIBXSLT_READ_CB} = shift;
150 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
151 }
15214µs return $self->{XML_LIBXSLT_READ_CB};
153 }
154 else {
155 $ReadCB = shift if scalar @_;
156 return $ReadCB;
157 }
158}
159
160
# spent 4µs within XML::LibXSLT::close_callback which was called: # once (4µs+0s) by XML::LibXSLT::_init_callbacks at line 224
sub close_callback {
1611500ns my $self = shift;
1621700ns if ( ref $self ) {
1631400ns if ( scalar @_ ) {
164 $self->{XML_LIBXSLT_CLOSE_CB} = shift;
165 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
166 }
16716µs return $self->{XML_LIBXSLT_CLOSE_CB};
168 }
169 else {
170 $CloseCB = shift if scalar @_;
171 return $CloseCB;
172 }
173}
174
175
# spent 6µs within XML::LibXSLT::open_callback which was called: # once (6µs+0s) by XML::LibXSLT::_init_callbacks at line 222
sub open_callback {
1761600ns my $self = shift;
17711µs if ( ref $self ) {
1781700ns if ( scalar @_ ) {
179 $self->{XML_LIBXSLT_OPEN_CB} = shift;
180 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
181 }
18215µs return $self->{XML_LIBXSLT_OPEN_CB};
183 }
184 else {
185 $OpenCB = shift if scalar @_;
186 return $OpenCB;
187 }
188}
189
190sub callbacks {
191 my $self = shift;
192 if ( ref $self ) {
193 if (@_) {
194 my ($match, $open, $read, $close) = @_;
195 @{$self}{qw(XML_LIBXSLT_MATCH_CB XML_LIBXSLT_OPEN_CB XML_LIBXSLT_READ_CB XML_LIBXSLT_CLOSE_CB)} = ($match, $open, $read, $close);
196 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
197 }
198 else {
199 return @{$self}{qw(XML_LIBXSLT_MATCH_CB XML_LIBXSLT_OPEN_CB XML_LIBXSLT_READ_CB XML_LIBXSLT_CLOSE_CB)};
200 }
201 }
202 else {
203 if (@_) {
204 ( $MatchCB, $OpenCB, $ReadCB, $CloseCB ) = @_;
205 }
206 else {
207 return ( $MatchCB, $OpenCB, $ReadCB, $CloseCB );
208 }
209 }
210}
211
212
# spent 93µs (48+46) within XML::LibXSLT::_init_callbacks which was called: # once (48µs+46µs) by XML::LibXSLT::parse_stylesheet at line 246
sub _init_callbacks{
2131500ns my $self = shift;
21411µs my $icb = $self->{XML_LIBXSLT_CALLBACK_STACK};
215
2161700ns unless ( defined $icb ) {
21713µs14µs $self->{XML_LIBXSLT_CALLBACK_STACK} = XML::LibXML::InputCallback->new();
# spent 4µs making 1 call to XML::LibXML::InputCallback::new
2181600ns $icb = $self->{XML_LIBXSLT_CALLBACK_STACK};
219 }
220
22113µs15µs my $mcb = $self->match_callback();
# spent 5µs making 1 call to XML::LibXSLT::match_callback
22214µs16µs my $ocb = $self->open_callback();
# spent 6µs making 1 call to XML::LibXSLT::open_callback
22314µs15µs my $rcb = $self->read_callback();
# spent 5µs making 1 call to XML::LibXSLT::read_callback
22413µs14µs my $ccb = $self->close_callback();
# spent 4µs making 1 call to XML::LibXSLT::close_callback
225
22611µs if ( defined $mcb and defined $ocb and defined $rcb and defined $ccb ) {
227 $icb->register_callbacks( [$mcb, $ocb, $rcb, $ccb] );
228 }
229
230122µs115µs $self->lib_init_callbacks();
# spent 15µs making 1 call to XML::LibXSLT::lib_init_callbacks
23116µs17µs $icb->init_callbacks();
# spent 7µs making 1 call to XML::LibXML::InputCallback::init_callbacks
232}
233
234
# spent 44µs (19+25) within XML::LibXSLT::_cleanup_callbacks which was called: # once (19µs+25µs) by XML::LibXSLT::parse_stylesheet at line 251
sub _cleanup_callbacks {
23511µs my $self = shift;
23615µs119µs $self->{XML_LIBXSLT_CALLBACK_STACK}->cleanup_callbacks();
# spent 19µs making 1 call to XML::LibXML::InputCallback::cleanup_callbacks
23714µs16µs my $mcb = $self->match_callback();
# spent 6µs making 1 call to XML::LibXSLT::match_callback
23816µs if ( defined $mcb ) {
239 $self->{XML_LIBXSLT_CALLBACK_STACK}->unregister_callbacks( [$mcb] );
240 }
241}
242
243
# spent 15.0ms (55µs+14.9) within XML::LibXSLT::parse_stylesheet which was called: # once (55µs+14.9ms) by C4::XSLT::XSLTParse4Display at line 238 of /usr/share/koha/lib/C4/XSLT.pm
sub parse_stylesheet {
2441600ns my $self = shift;
245
24614µs193µs $self->_init_callbacks();
# spent 93µs making 1 call to XML::LibXSLT::_init_callbacks
247
2481300ns my $stylesheet;
249214.8ms314.8ms eval { $stylesheet = $self->_parse_stylesheet(@_); };
# spent 14.8ms making 1 call to XML::LibXSLT::_parse_stylesheet # spent 27µs making 2 calls to XML::LibXML::InputCallback::_callback_match, avg 13µs/call
250
25115µs144µs $self->_cleanup_callbacks();
# spent 44µs making 1 call to XML::LibXSLT::_cleanup_callbacks
252
25311µs my $err = $@;
2541400ns if ($err) {
255 croak $err;
256 }
257
25819µs my $rv = {
259 XML_LIBXSLT_STYLESHEET => $stylesheet,
260 XML_LIBXSLT_CALLBACK_STACK => $self->{XML_LIBXSLT_CALLBACK_STACK},
261 XML_LIBXSLT_MATCH_CB => $self->{XML_LIBXSLT_MATCH_CB},
262 XML_LIBXSLT_OPEN_CB => $self->{XML_LIBXSLT_OPEN_CB},
263 XML_LIBXSLT_READ_CB => $self->{XML_LIBXSLT_READ_CB},
264 XML_LIBXSLT_CLOSE_CB => $self->{XML_LIBXSLT_CLOSE_CB},
265 XML_LIBXSLT_SECPREFS => $self->{XML_LIBXSLT_SECPREFS},
266 };
267
268118µs return bless $rv, "XML::LibXSLT::StylesheetWrapper";
269}
270
271sub parse_stylesheet_file {
272 my $self = shift;
273
274 $self->_init_callbacks();
275
276 my $stylesheet;
277 eval { $stylesheet = $self->_parse_stylesheet_file(@_); };
278
279 $self->_cleanup_callbacks();
280
281 my $err = $@;
282 if ($err) {
283 croak $err;
284 }
285
286 my $rv = {
287 XML_LIBXSLT_STYLESHEET => $stylesheet,
288 XML_LIBXSLT_CALLBACK_STACK => $self->{XML_LIBXSLT_CALLBACK_STACK},
289 XML_LIBXSLT_MATCH_CB => $self->{XML_LIBXSLT_MATCH_CB},
290 XML_LIBXSLT_OPEN_CB => $self->{XML_LIBXSLT_OPEN_CB},
291 XML_LIBXSLT_READ_CB => $self->{XML_LIBXSLT_READ_CB},
292 XML_LIBXSLT_CLOSE_CB => $self->{XML_LIBXSLT_CLOSE_CB},
293 XML_LIBXSLT_SECPREFS => $self->{XML_LIBXSLT_SECPREFS},
294 };
295
296 return bless $rv, "XML::LibXSLT::StylesheetWrapper";
297}
298
299sub register_xslt_module {
300 my $self = shift;
301 my $module = shift;
302 # Not implemented
303}
304
3051200ns1;
306
307package XML::LibXSLT::StylesheetWrapper;
308
309334µs229µs
# spent 23µs (17+6) within XML::LibXSLT::StylesheetWrapper::BEGIN@309 which was called: # once (17µs+6µs) by C4::XSLT::BEGIN@35 at line 309
use strict;
# spent 23µs making 1 call to XML::LibXSLT::StylesheetWrapper::BEGIN@309 # spent 6µs making 1 call to strict::import
310333µs2157µs
# spent 84µs (11+73) within XML::LibXSLT::StylesheetWrapper::BEGIN@310 which was called: # once (11µs+73µs) by C4::XSLT::BEGIN@35 at line 310
use vars qw($MatchCB $ReadCB $OpenCB $CloseCB);
# spent 84µs making 1 call to XML::LibXSLT::StylesheetWrapper::BEGIN@310 # spent 73µs making 1 call to vars::import
311
312336µs2526µs
# spent 269µs (12+257) within XML::LibXSLT::StylesheetWrapper::BEGIN@312 which was called: # once (12µs+257µs) by C4::XSLT::BEGIN@35 at line 312
use XML::LibXML;
# spent 269µs making 1 call to XML::LibXSLT::StylesheetWrapper::BEGIN@312 # spent 257µs making 1 call to XML::LibXML::import
3133982µs2199µs
# spent 106µs (14+93) within XML::LibXSLT::StylesheetWrapper::BEGIN@313 which was called: # once (14µs+93µs) by C4::XSLT::BEGIN@35 at line 313
use Carp;
# spent 106µs making 1 call to XML::LibXSLT::StylesheetWrapper::BEGIN@313 # spent 93µs making 1 call to Exporter::import
314
315sub security_callbacks {
316 my $self = shift;
317 my $scbclass = shift;
318
319 if ( defined $scbclass ) {
320 $self->{XML_LIBXSLT_SECPREFS} = $scbclass;
321 }
322 return $self->{XML_LIBXSLT_SECPREFS};
323}
324
325sub input_callbacks {
326 my $self = shift;
327 my $icbclass = shift;
328
329 if ( defined $icbclass ) {
330 $self->{XML_LIBXSLT_CALLBACK_STACK} = $icbclass;
331 }
332 return $self->{XML_LIBXSLT_CALLBACK_STACK};
333}
334
335
# spent 368µs within XML::LibXSLT::StylesheetWrapper::match_callback which was called 50 times, avg 7µs/call: # 25 times (188µs+0s) by XML::LibXSLT::StylesheetWrapper::_cleanup_callbacks at line 446, avg 8µs/call # 25 times (180µs+0s) by XML::LibXSLT::StylesheetWrapper::_init_callbacks at line 426, avg 7µs/call
sub match_callback {
3365076µs my $self = shift;
3375062µs if ( ref $self ) {
3385030µs if ( scalar @_ ) {
339 $self->{XML_LIBXSLT_MATCH_CB} = shift;
340 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
341 }
34250292µs return $self->{XML_LIBXSLT_MATCH_CB};
343 }
344 else {
345 $MatchCB = shift if scalar @_;
346 return $MatchCB;
347 }
348}
349
350
# spent 153µs within XML::LibXSLT::StylesheetWrapper::read_callback which was called 25 times, avg 6µs/call: # 25 times (153µs+0s) by XML::LibXSLT::StylesheetWrapper::_init_callbacks at line 428, avg 6µs/call
sub read_callback {
3512519µs my $self = shift;
3522527µs if ( ref $self ) {
3532520µs if ( scalar @_ ) {
354 $self->{XML_LIBXSLT_READ_CB} = shift;
355 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
356 }
35725142µs return $self->{XML_LIBXSLT_READ_CB};
358 }
359 else {
360 $ReadCB = shift if scalar @_;
361 return $ReadCB;
362 }
363}
364
365
# spent 144µs within XML::LibXSLT::StylesheetWrapper::close_callback which was called 25 times, avg 6µs/call: # 25 times (144µs+0s) by XML::LibXSLT::StylesheetWrapper::_init_callbacks at line 429, avg 6µs/call
sub close_callback {
3662520µs my $self = shift;
3672525µs if ( ref $self ) {
3682518µs if ( scalar @_ ) {
369 $self->{XML_LIBXSLT_CLOSE_CB} = shift;
370 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
371 }
37225111µs return $self->{XML_LIBXSLT_CLOSE_CB};
373 }
374 else {
375 $CloseCB = shift if scalar @_;
376 return $CloseCB;
377 }
378}
379
380
# spent 159µs within XML::LibXSLT::StylesheetWrapper::open_callback which was called 25 times, avg 6µs/call: # 25 times (159µs+0s) by XML::LibXSLT::StylesheetWrapper::_init_callbacks at line 427, avg 6µs/call
sub open_callback {
3812519µs my $self = shift;
3822525µs if ( ref $self ) {
3832520µs if ( scalar @_ ) {
384 $self->{XML_LIBXSLT_OPEN_CB} = shift;
385 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
386 }
38725128µs return $self->{XML_LIBXSLT_OPEN_CB};
388 }
389 else {
390 $OpenCB = shift if scalar @_;
391 return $OpenCB;
392 }
393}
394
395sub callbacks {
396 my $self = shift;
397 if ( ref $self ) {
398 if (@_) {
399 my ($match, $open, $read, $close) = @_;
400 @{$self}{qw(XML_LIBXSLT_MATCH_CB XML_LIBXSLT_OPEN_CB XML_LIBXSLT_READ_CB XML_LIBXSLT_CLOSE_CB)} = ($match, $open, $read, $close);
401 $self->{XML_LIBXSLT_CALLBACK_STACK} = undef;
402 }
403 else {
404 return @{$self}{qw(XML_LIBXSLT_MATCH_CB XML_LIBXSLT_OPEN_CB XML_LIBXSLT_READ_CB XML_LIBXSLT_CLOSE_CB)};
405 }
406 }
407 else {
408 if (@_) {
409 ( $MatchCB, $OpenCB, $ReadCB, $CloseCB ) = @_;
410 }
411 else {
412 return ( $MatchCB, $OpenCB, $ReadCB, $CloseCB );
413 }
414 }
415}
416
417
# spent 2.25ms (1.25+1.00) within XML::LibXSLT::StylesheetWrapper::_init_callbacks which was called 25 times, avg 90µs/call: # 25 times (1.25ms+1.00ms) by XML::LibXSLT::StylesheetWrapper::transform at line 461, avg 90µs/call
sub _init_callbacks {
4182518µs my $self = shift;
4192545µs my $icb = $self->{XML_LIBXSLT_CALLBACK_STACK};
420
4212515µs unless ( defined $icb ) {
422 $self->{XML_LIBXSLT_CALLBACK_STACK} = XML::LibXML::InputCallback->new();
423 $icb = $self->{XML_LIBXSLT_CALLBACK_STACK};
424 }
425
42625115µs25180µs my $mcb = $self->match_callback();
# spent 180µs making 25 calls to XML::LibXSLT::StylesheetWrapper::match_callback, avg 7µs/call
42725103µs25159µs my $ocb = $self->open_callback();
# spent 159µs making 25 calls to XML::LibXSLT::StylesheetWrapper::open_callback, avg 6µs/call
4282594µs25153µs my $rcb = $self->read_callback();
# spent 153µs making 25 calls to XML::LibXSLT::StylesheetWrapper::read_callback, avg 6µs/call
42925138µs25144µs my $ccb = $self->close_callback();
# spent 144µs making 25 calls to XML::LibXSLT::StylesheetWrapper::close_callback, avg 6µs/call
430
4312522µs if ( defined $mcb and defined $ocb and defined $rcb and defined $ccb ) {
432 $icb->register_callbacks( [$mcb, $ocb, $rcb, $ccb] );
433 }
43425327µs25102µs $self->XML::LibXSLT::lib_init_callbacks();
# spent 102µs making 25 calls to XML::LibXSLT::lib_init_callbacks, avg 4µs/call
4352574µs25266µs $icb->init_callbacks();
# spent 266µs making 25 calls to XML::LibXML::InputCallback::init_callbacks, avg 11µs/call
436
4372532µs my $scb = $self->{XML_LIBXSLT_SECPREFS};
43825254µs if ( $scb ) {
439 $scb->init_callbacks();
440 }
441}
442
443
# spent 1.04ms (517µs+521µs) within XML::LibXSLT::StylesheetWrapper::_cleanup_callbacks which was called 25 times, avg 42µs/call: # 25 times (517µs+521µs) by XML::LibXSLT::StylesheetWrapper::transform at line 463, avg 42µs/call
sub _cleanup_callbacks {
4442538µs my $self = shift;
44525126µs25334µs $self->{XML_LIBXSLT_CALLBACK_STACK}->cleanup_callbacks();
# spent 334µs making 25 calls to XML::LibXML::InputCallback::cleanup_callbacks, avg 13µs/call
4462584µs25188µs my $mcb = $self->match_callback();
# spent 188µs making 25 calls to XML::LibXSLT::StylesheetWrapper::match_callback, avg 8µs/call
4472520µs if ( defined $mcb ) {
448 $self->{XML_LIBXSLT_CALLBACK_STACK}->unregister_callbacks( [$mcb] );
449 }
450
4512527µs my $scb = $self->{XML_LIBXSLT_SECPREFS};
4522598µs if ( $scb ) {
453 $scb->cleanup_callbacks();
454 }
455}
456
457
# spent 50.4ms (1.04+49.3) within XML::LibXSLT::StylesheetWrapper::transform which was called 25 times, avg 2.02ms/call: # 25 times (1.04ms+49.3ms) by C4::XSLT::XSLTParse4Display at line 240 of /usr/share/koha/lib/C4/XSLT.pm, avg 2.02ms/call
sub transform {
4582524µs my $self = shift;
4592515µs my $doc;
460
46125202µs252.25ms $self->_init_callbacks();
# spent 2.25ms making 25 calls to XML::LibXSLT::StylesheetWrapper::_init_callbacks, avg 90µs/call
4625046.5ms2546.1ms eval { $doc = $self->{XML_LIBXSLT_STYLESHEET}->transform($self,@_); };
# spent 46.1ms making 25 calls to XML::LibXSLT::Stylesheet::transform, avg 1.84ms/call
46325151µs251.04ms $self->_cleanup_callbacks();
# spent 1.04ms making 25 calls to XML::LibXSLT::StylesheetWrapper::_cleanup_callbacks, avg 42µs/call
464
4652527µs my $err = $@;
4662513µs if ($err) {
467 croak $err;
468 }
469
47025107µs return $doc;
471}
472
473sub transform_file {
474 my $self = shift;
475 my $doc;
476
477 $self->_init_callbacks();
478 eval { $doc = $self->{XML_LIBXSLT_STYLESHEET}->transform_file($self,@_); };
479 $self->_cleanup_callbacks();
480
481 my $err = $@;
482 if ($err) {
483 croak $err;
484 }
485
486 return $doc;
487}
488
489251.74ms251.46ms
# spent 1.72ms (262µs+1.46) within XML::LibXSLT::StylesheetWrapper::output_string which was called 25 times, avg 69µs/call: # 25 times (262µs+1.46ms) by C4::XSLT::XSLTParse4Display at line 241 of /usr/share/koha/lib/C4/XSLT.pm, avg 69µs/call
sub output_string { shift->{XML_LIBXSLT_STYLESHEET}->_output_string($_[0],0) }
# spent 1.46ms making 25 calls to XML::LibXSLT::Stylesheet::_output_string, avg 58µs/call
490sub output_as_bytes { shift->{XML_LIBXSLT_STYLESHEET}->_output_string($_[0],1) }
491sub output_as_chars { shift->{XML_LIBXSLT_STYLESHEET}->_output_string($_[0],2) }
492sub output_fh { shift->{XML_LIBXSLT_STYLESHEET}->output_fh(@_) }
493sub output_file { shift->{XML_LIBXSLT_STYLESHEET}->output_file(@_) }
494sub media_type { shift->{XML_LIBXSLT_STYLESHEET}->media_type(@_) }
495sub output_encoding { shift->{XML_LIBXSLT_STYLESHEET}->output_encoding(@_) }
496
4971100ns1;
498
499# XML::LibXSLT::Security Interface #
500#-------------------------------------------------------------------------#
501package XML::LibXSLT::Security;
502
503330µs228µs
# spent 23µs (18+5) within XML::LibXSLT::Security::BEGIN@503 which was called: # once (18µs+5µs) by C4::XSLT::BEGIN@35 at line 503
use strict;
# spent 23µs making 1 call to XML::LibXSLT::Security::BEGIN@503 # spent 5µs making 1 call to strict::import
504339µs2106µs
# spent 59µs (11+48) within XML::LibXSLT::Security::BEGIN@504 which was called: # once (11µs+48µs) by C4::XSLT::BEGIN@35 at line 504
use Carp;
# spent 59µs making 1 call to XML::LibXSLT::Security::BEGIN@504 # spent 48µs making 1 call to Exporter::import
505
5063367µs292µs
# spent 51µs (9+42) within XML::LibXSLT::Security::BEGIN@506 which was called: # once (9µs+42µs) by C4::XSLT::BEGIN@35 at line 506
use vars qw(%OPTION_MAP %_GLOBAL_CALLBACKS);
# spent 51µs making 1 call to XML::LibXSLT::Security::BEGIN@506 # spent 42µs making 1 call to vars::import
507
508# Maps the option names used in the perl interface to the numeric values
509# used by libxslt.
51015µsmy %OPTION_MAP = (
511 read_file => 1,
512 write_file => 2,
513 create_dir => 3,
514 read_net => 4,
515 write_net => 5,
516);
517
5181400ns%_GLOBAL_CALLBACKS = ();
519
520
521#-------------------------------------------------------------------------#
522# global callback #
523#-------------------------------------------------------------------------#
524sub _security_check {
525 my $option = shift;
526 my $retval = 1;
527
528 if ($option == 3) {
529 $retval = 0; # Default create_dir to no access
530 }
531
532 if (exists $_GLOBAL_CALLBACKS{$option}) {
533 $retval = $_GLOBAL_CALLBACKS{$option}->(@_);
534 }
535
536 return $retval;
537}
538
539#-------------------------------------------------------------------------#
540# member functions and methods #
541#-------------------------------------------------------------------------#
542
543sub new {
544 my $class = shift;
545 return bless {'_CALLBACKS' => {}}, $class;
546}
547
548# Add a callback for the given security option (read_file, write_file,
549# create_dir, read_net, write_net).
550#
551# To register a callback that handle network read requests:
552# $scb->register_callback( read_net => \&callback );
553sub register_callback {
554 my $self = shift;
555 my $option = shift;
556 my $callback = shift;
557
558 unless ( exists $OPTION_MAP{$option} ) {
559 croak "Invalid security option '$option'. Must be one of: " .
560 join(', ', keys %OPTION_MAP) . ".";
561 }
562
563 if ( ref $callback eq 'CODE' ) {
564 $self->{_CALLBACKS}{ $OPTION_MAP{$option} } = $callback;
565 }
566 else {
567 croak "Invalid argument. The callback must be a reference to a subroutine";
568 }
569}
570
571# Removes the callback for the given security option. Causes the given option
572# to use the default security handler (which always allows the action).
573sub unregister_callback {
574 my $self = shift;
575 my $option = shift;
576
577 unless ( exists $OPTION_MAP{$option} ) {
578 croak "Invalid security option '$option'. Must be one of: " .
579 join(', ', keys %OPTION_MAP) . ".";
580 }
581
582 delete $self->{_CALLBACKS}{ $OPTION_MAP{$option} };
583}
584
585
586# make it so libxslt can use the callbacks
587sub init_callbacks {
588 my $self = shift;
589
590 %_GLOBAL_CALLBACKS = %{ $self->{_CALLBACKS} };
591}
592
593# reset libxslt callbacks
594sub cleanup_callbacks {
595 my $self = shift;
596
597 %_GLOBAL_CALLBACKS = ();
598}
599
60016µs1;
601
602__END__
 
# spent 14.8ms (14.8+27µs) within XML::LibXSLT::_parse_stylesheet which was called: # once (14.8ms+27µs) by XML::LibXSLT::parse_stylesheet at line 249
sub XML::LibXSLT::_parse_stylesheet; # xsub
# spent 190µs within XML::LibXSLT::bootstrap which was called: # once (190µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm
sub XML::LibXSLT::bootstrap; # xsub
# spent 117µs within XML::LibXSLT::lib_init_callbacks which was called 26 times, avg 5µs/call: # 25 times (102µs+0s) by XML::LibXSLT::StylesheetWrapper::_init_callbacks at line 434, avg 4µs/call # once (15µs+0s) by XML::LibXSLT::_init_callbacks at line 230
sub XML::LibXSLT::lib_init_callbacks; # xsub