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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
BEGIN {print "1..3\n";}
END {print "not ok 1\n" unless $loaded;}
use XML::XQL;
use XML::XQL::DOM;
use XML::XQL::Debug;
$loaded = 1;
print "ok 1\n";
my $test = 1;
sub assert_ok
{
my $ok = shift;
print "not " unless $ok;
++$test;
print "ok $test\n";
$ok;
}
sub assert_output
{
my $str = shift;
$^W=0;
my $data = join('',<DATA>);
#print "{{$data}}\n{{$str}}\n";
assert_ok ($str eq $data);
}
#Test 2
$dom = new XML::DOM::Parser;
my $str = <<END;
<a>
<a>
<b>
<b>
a.a.b.b
</b>
<b>
a.a.b.b2
</b>
</b>
<b>
<b>
a.a.b2.b
</b>
<b>
a.a.b2.b2
</b>
</b>
</a>
</a>
END
my $doc = $dom->parse ($str);
assert_ok ($doc);
@result = XML::XQL::solve ('//b//b', $doc);
$result = XML::XQL::Debug::str (\@result);
#print $result;
assert_output ($result);
__DATA__
<array>
<item index='0'>
<obj type='XML::DOM::Element'>
<b>
a.a.b.b
</b>
</obj>
</item>
<item index='1'>
<obj type='XML::DOM::Element'>
<b>
a.a.b.b2
</b>
</obj>
</item>
<item index='2'>
<obj type='XML::DOM::Element'>
<b>
a.a.b2.b
</b>
</obj>
</item>
<item index='3'>
<obj type='XML::DOM::Element'>
<b>
a.a.b2.b2
</b>
</obj>
</item>
</array>
|