2 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Apache config
# <LocationMatch "^/~eserte/test/mesh/.*\.html$">
# PerlRequire /home/e/eserte/devel/Mesh.pm
# SetHandler perl-script
# PerlHandler Mesh::handler
# </LocationMatch>
package Mesh;
use strict;
use Apache::Constants;
use XML::LibXML;
sub handler {
my $r = shift;
my $f = $r->filename;
my $p = XML::LibXML->new;
my $doc = $p->parse_file($f) or die $!;
my $root = $doc->documentElement;
$root->setNamespaceDeclURI(undef,undef);
my($body) = $root->findnodes("/html/body");
my $header = $p->parse_xml_chunk(<<EOF);
<div>This is the header</div>
EOF
my $footer = $p->parse_xml_chunk(<<EOF);
<div>This is the footer</div>
EOF
if ($body->firstChild) {
$body->insertBefore($header, $body->firstChild);
$body->insertAfter($footer, undef);
} else {
$body->insertAfter($header);
$body->insertAfter($footer);
}
$r->send_http_header;
$r->print($doc->serialize);
Apache::Constants::OK();
}
1;
__END__
2 Einträge, 1 Seite |