File: dom_extent.t

package info (click to toggle)
libxml-dom-perl 1.37-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 604 kB
  • ctags: 510
  • sloc: perl: 4,166; xml: 4,117; makefile: 34
file content (50 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (6)
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
48
49
50
BEGIN {print "1..1\n";}
END {print "not ok 1\n" unless $loaded;}
use XML::DOM;
$loaded = 1;
print "ok 1\n";

# this test is temporary disabled because
# i think i have found a bug in expat that
# calls the ExternEnt handler instead of Entity for
# external parameter entities
exit;

my $test = 1;
sub assert_ok
{
    my $ok = shift;
    print "not " unless $ok;
    ++$test;
    print "ok $test\n";
    $ok;
}

# <!ENTITY % globalInfo SYSTEM "t/dom_extent.ent">
my $xml =<<EOF;
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book SYSTEM "t/dom_extent.dtd" [
 <!ENTITY % globalInfo SYSTEM "t/dom_extent.ent">
 %globalInfo;
 
]>
<book>
</book>
EOF

#
# Tell XML::Parser to parse the external entities (ParseParamEnt => 1)
# Tell XML::DOM::Parser to 'hide' the contents of the external entities
# so you see '%globalInfo;' when printing.
my $parser = new XML::DOM::Parser( 
				   ParseParamEnt => 1,
				   ExpandParamEnt => 0,
				   ErrorContext => 5);

my $dom = $parser->parse ($xml);
my $domstr = $dom->toString;

# Compare output with original file
assert_ok ($domstr eq $xml);

print "$domstr\n$xml\n";