line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::LibXSLT::Cache; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$XML::LibXSLT::Cache::VERSION = '0.12'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
869
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Style sheet cache for XML::LibXSLT |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use base qw(XML::LibXML::Cache::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
712
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my $options = @_ > 1 ? { @_ } : $_[0]; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $self = $class->SUPER::new; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $xslt = $options->{xslt}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if (!$xslt) { |
20
|
|
|
|
|
|
|
require XML::LibXSLT; |
21
|
|
|
|
|
|
|
$xslt = XML::LibXSLT->new; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->{xslt} = $xslt; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$xslt->input_callbacks($XML::LibXML::Cache::Base::input_callbacks); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub parse_stylesheet_file { |
32
|
|
|
|
|
|
|
my ($self, $filename) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $self->_cache_lookup($filename, sub { |
35
|
|
|
|
|
|
|
my $filename = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return $self->{xslt}->parse_stylesheet_file($filename); |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
XML::LibXSLT::Cache - Style sheet cache for XML::LibXSLT |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.12 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $cache = XML::LibXSLT::Cache->new; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $stylesheet = $cache->parse_stylesheet_file('file.xsl'); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
XML::LibXSLT::Cache is a cache for L style sheets loaded from |
64
|
|
|
|
|
|
|
files. It is useful to speed up loading of XSLT style sheets in persistent web |
65
|
|
|
|
|
|
|
applications. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This module caches the style sheet object after the first load and returns the |
68
|
|
|
|
|
|
|
cached version on subsequent loads. Style sheets are reloaded whenever the |
69
|
|
|
|
|
|
|
style sheet file changes. Changes to other files referenced during parsing also |
70
|
|
|
|
|
|
|
cause a reload, for example when using xsl:import and xsl:include. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 new |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $cache = XML::LibXSLT::Cache->new(%opts); |
77
|
|
|
|
|
|
|
my $cache = XML::LibXSLT::Cache->new(\%opts); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Creates a new cache. Valid options are: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item xslt |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The L object that should be used to load stylsheets if you |
86
|
|
|
|
|
|
|
want to reuse an existing object. If this options is missing a new |
87
|
|
|
|
|
|
|
XML::LibXSLT object will be created. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 parse_stylesheet_file |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $stylesheet = $cache->parse_stylesheet_file($filename); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Works like L. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Nick Wellnhofer |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Nick Wellnhofer. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
106
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |