line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*-
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
651
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use utf8;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
21
|
use Fcntl ();
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
6
|
1
|
|
|
1
|
|
1623075
|
use URI ();
|
|
1
|
|
|
|
|
6363
|
|
|
1
|
|
|
|
|
69
|
|
7
|
1
|
|
|
1
|
|
1024
|
use LWP::Simple ();
|
|
1
|
|
|
|
|
437667
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
416
|
use XML::DOM ();
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use XML::EP::Processor::XSLTParser ();
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package XML::EP::Processor::XSLT;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new {
|
14
|
|
|
|
|
|
|
my $proto = shift;
|
15
|
|
|
|
|
|
|
my $self = (@_ == 1) ? \%{ shift() } : { @_ };
|
16
|
|
|
|
|
|
|
bless($self, (ref($proto) || $proto));
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub Process {
|
21
|
|
|
|
|
|
|
my($self, $req, $xml) = @_;
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
die "Missing href attribute in stylesheet declaration"
|
24
|
|
|
|
|
|
|
unless $self->{'pidata'} =~ /\bhref=\"(.*?)\"/;
|
25
|
|
|
|
|
|
|
my $url = $1;
|
26
|
|
|
|
|
|
|
my $base = $req->Request()->Uri();
|
27
|
|
|
|
|
|
|
$url = URI::URL->new($url, $base)->abs();
|
28
|
|
|
|
|
|
|
my $content = LWP::Simple::get($url)
|
29
|
|
|
|
|
|
|
|| die "Failed to access stylesheet $url.\n";
|
30
|
|
|
|
|
|
|
my $parser = XML::DOM::Parser->new();
|
31
|
|
|
|
|
|
|
my $stylesheet = $parser->parse($content);
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $xslt = XML::EP::Processor::XSLTParser->new('xmlDocument' => $xml,
|
34
|
|
|
|
|
|
|
'xslDocument' => $stylesheet);
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $result = $xslt->process_project();
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# The XSLT parser returns a document fragment. We have to replace
|
39
|
|
|
|
|
|
|
# the old document contents with the document fragments.
|
40
|
|
|
|
|
|
|
while (my $child = $xml->getFirstChild()) {
|
41
|
|
|
|
|
|
|
$xml->removeChild($child);
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
my $child = $result->getFirstChild();
|
44
|
|
|
|
|
|
|
while ($child) {
|
45
|
|
|
|
|
|
|
my $c = $child;
|
46
|
|
|
|
|
|
|
$child = $c->getNextSibling();
|
47
|
|
|
|
|
|
|
next if $c->getNodeType() == XML::DOM::TEXT_NODE; # Skip blanks
|
48
|
|
|
|
|
|
|
$result->removeChild($c);
|
49
|
|
|
|
|
|
|
$xml->appendChild($c);
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
$xml;
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1;
|