You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2001/11/03 03:54:12 UTC
cvs commit: xml-xerces/perl/t DOM_Document.t DOM_Node.t IDOMCount.t IDOMPrint.t IDOM_Document.t IDOM_Entity.t IDOM_NamedNodeMap.t IDOM_Node.t IDOM_NodeList.t letter.xml
jasons 01/11/02 18:54:12
Added: perl/t DOM_Document.t DOM_Node.t IDOMCount.t IDOMPrint.t
IDOM_Document.t IDOM_Entity.t IDOM_NamedNodeMap.t
IDOM_Node.t IDOM_NodeList.t letter.xml
Log:
new tests
Revision Changes Path
1.1 xml-xerces/perl/t/DOM_Document.t
Index: DOM_Document.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# DOM_Document.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..35126\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result is_object);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="utf-8"?>
<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>];
my $DOM1 = new XML::Xerces::DOMParser;
my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
$DOM1->setErrorHandler($ERROR_HANDLER);
$DOM1->parse(XML::Xerces::MemBufInputSource->new($document));
my $DOM2 = new XML::Xerces::DOMParser;
$DOM2->setErrorHandler($ERROR_HANDLER);
$DOM2->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'));
my $doc1 = $DOM1->getDocument();
my $doc2 = $DOM2->getDocument();
my $root1 = $doc1->getDocumentElement();
my @persons1 = $doc1->getElementsByTagName('person');
my @names1 = $doc1->getElementsByTagName('name');
my $root2 = $doc2->getDocumentElement();
my @persons2 = $doc2->getElementsByTagName('person');
my @names2 = $doc1->getElementsByTagName('name');
# importing a child from a different document
my $copy;
eval {
$copy = $doc1->importNode($persons1[0],0);
$root1->appendChild($copy);
};
result(!$@ &&
scalar @persons1 < scalar ($root1->getElementsByTagName('person'))
);
eval {
$copy = $doc1->importNode($persons1[0]->getAttributeNode('Role'),0);
};
result(!$@
&& is_object($copy)
&& $copy->isa('XML::Xerces::DOM_Attr')
);
# check that creating an element with an illegal charater
eval {
my $el = $doc1->createElement('?');
};
result($@ &&
$@->{code} == $XML::Xerces::DOM_DOMException::INVALID_CHARACTER_ERR
);
# check that an element can't start with a digit
eval {
my $el = $doc1->createElement('9');
};
result($@ &&
$@->{code} == $XML::Xerces::DOM_DOMException::INVALID_CHARACTER_ERR
);
# check that an element can have a digit if a valid character comes first
eval {
my $el = $doc1->createElement('_1');
};
result(!$@);
# check that an element can start with an underscore
eval {
my $el = $doc1->createElement('_');
};
result(!$@);
# check that an element can start with an colon
eval {
my $el = $doc1->createElement(':');
};
result(!$@);
eval {
$DOM1->parse('t/letter.xml');
};
if ($@) {
if (ref($@)) {
if ($@->isa('XML::Xerces::XMLException')) {
die "Couldn't open letter.xml: ", $@->getMessage();
} elsif ($@->isa('XML::Xerces::DOM_DOMException')) {
die "Couldn't open letter.xml: msg=<$...@->{msg}>, code=$@->{code}";
}
}
}
$doc1 = $DOM1->getDocument();
my ($digit_node) = $doc1->getElementsByTagName('digit');
my @digits;
foreach my $range_node ($digit_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@digits,$low..$high);
}
foreach my $single_node ($digit_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@digits,$value);
}
@digits = map {chr($_)} @digits;
# $XML::Xerces::DEBUG_UTF8_IN = 1;
# $XML::Xerces::DEBUG_UTF8_OUT = 1;
foreach my $char (@digits) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($extender_node) = $doc1->getElementsByTagName('extender');
my @extenders;
foreach my $range_node ($extender_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@extenders,$low..$high);
}
foreach my $single_node ($extender_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@extenders,$value);
}
@extenders = map {chr($_)} @extenders;
foreach my $char (@extenders) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($combining_char_node) = $doc1->getElementsByTagName('combiningchar');
my @combining_chars;
foreach my $range_node ($combining_char_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@combining_chars,$low..$high);
}
foreach my $single_node ($combining_char_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@combining_chars,$value);
}
@combining_chars = map {chr($_)} @combining_chars;
foreach my $char (@combining_chars) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($letter_node) = $doc1->getElementsByTagName('letter');
my @letters;
foreach my $range_node ($letter_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@letters,$low..$high);
}
foreach my $single_node ($letter_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@letters,$value);
}
@letters = map {chr($_)} @letters;
foreach my $char (@letters) {
eval {
my $el = $doc1->createElement("$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($ideograph_node) = $doc1->getElementsByTagName('ideographic');
my @ideographs;
foreach my $range_node ($ideograph_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@ideographs,$low..$high);
}
foreach my $single_node ($ideograph_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@ideographs,$value);
}
@ideographs = map {chr($_)} @ideographs;
# $XML::Xerces::DEBUG_UTF8_IN = 1;
# $XML::Xerces::DEBUG_UTF8_OUT = 1;
foreach my $char (@ideographs) {
eval {
my $el = $doc1->createElement("$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
1.1 xml-xerces/perl/t/DOM_Node.t
Index: DOM_Node.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# DOM_Node.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..2\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result is_object);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="utf-8"?>
<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>];
my $DOM1 = new XML::Xerces::DOMParser;
my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
$DOM1->setErrorHandler($ERROR_HANDLER);
$DOM1->parse(XML::Xerces::MemBufInputSource->new($document));
my $DOM2 = new XML::Xerces::DOMParser;
$DOM2->setErrorHandler($ERROR_HANDLER);
$DOM2->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'));
my $doc1 = $DOM1->getDocument();
my $doc2 = $DOM2->getDocument();
my $root1 = $doc1->getDocumentElement();
my @persons1 = $doc1->getElementsByTagName('person');
my @names1 = $doc1->getElementsByTagName('name');
my $root2 = $doc2->getDocumentElement();
my @persons2 = $doc2->getElementsByTagName('person');
my @names2 = $doc1->getElementsByTagName('name');
# importing a child from a different document
eval {
my $copy = $doc1->importNode($persons1[0],0);
$root1->appendChild($copy);
};
result(!$@ &&
scalar @persons1 < scalar ($root1->getElementsByTagName('person')));
1.1 xml-xerces/perl/t/IDOMCount.t
Index: IDOMCount.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOMCount.t
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..2\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result $SAMPLE_DIR);
use vars qw($i $loaded $file);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
my $document = q[<?xml version="1.0" encoding="utf-8"?>
<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>];
$file = '.idomprint.xml';
open(OUT,">$file") or die "Couldn't open $file from writing";
print OUT $document;
close(OUT);
my $output = `$Config{perlpath} -Mblib $SAMPLE_DIR/IDOMCount.pl $file 2>/dev/null`;
# print STDERR "Out <$output>\n";
$output =~ /(\d+) elems/;
result($1 == 10);
END {unlink $file;}
1.1 xml-xerces/perl/t/IDOMPrint.t
Index: IDOMPrint.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOMPrint.t
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..2\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result $SAMPLE_DIR);
use vars qw($i $loaded $file);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
my $document = q[<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>
];
$file = '.idomprint.xml';
open(OUT,">$file") or die "Couldn't open $file from writing";
print OUT $document;
close(OUT);
my $output = `$Config{perlpath} -Mblib $SAMPLE_DIR/IDOMPrint.pl $file 2>/dev/null`;
result($document eq $output);
END {unlink $file;}
1.1 xml-xerces/perl/t/IDOM_Document.t
Index: IDOM_Document.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOM_Document.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..35124\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
use utf8;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result is_object);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="utf-8"?>
<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>];
my $IDOM1 = new XML::Xerces::IDOMParser;
my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
$IDOM1->setErrorHandler($ERROR_HANDLER);
$IDOM1->parse(XML::Xerces::MemBufInputSource->new($document));
my $IDOM2 = new XML::Xerces::IDOMParser;
$IDOM2->setErrorHandler($ERROR_HANDLER);
$IDOM2->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'));
my $doc1 = $IDOM1->getDocument();
my $doc2 = $IDOM2->getDocument();
my $root1 = $doc1->getDocumentElement();
my @persons1 = $doc1->getElementsByTagName('person');
my @names1 = $doc1->getElementsByTagName('name');
my $root2 = $doc2->getDocumentElement();
my @persons2 = $doc2->getElementsByTagName('person');
my @names2 = $doc1->getElementsByTagName('name');
# importing a child from a different document
eval {
my $copy = $doc1->importNode($persons1[0],0);
$root1->appendChild($copy);
};
result(!$@ &&
scalar @persons1 < scalar ($root1->getElementsByTagName('person'))
);
# check that creating an element with an illegal charater
eval {
my $el = $doc1->createElement('?');
};
result($@
&& $@->{code} == $XML::Xerces::IDOM_DOMException::INVALID_CHARACTER_ERR
);
# check that an element can't start with a digit
eval {
my $el = $doc1->createElement('9');
};
result($@
&& $@->{code} == $XML::Xerces::IDOM_DOMException::INVALID_CHARACTER_ERR
);
# check that an element can have a digit if a valid character comes first
eval {
$IDOM1->parse('t/letter.xml');
};
if ($@) {
if (ref($@)) {
if ($@->isa('XML::Xerces::XMLException')) {
die "Couldn't open letter.xml: ", $@->getMessage();
} elsif ($@->isa('XML::Xerces::IDOM_DOMException')) {
die "Couldn't open letter.xml: msg=<$...@->{msg}>, code=$@->{code}";
}
}
}
$doc1 = $IDOM1->getDocument();
my ($digit_node) = $doc1->getElementsByTagName('digit');
my @digits;
foreach my $range_node ($digit_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@digits,$low..$high);
}
foreach my $single_node ($digit_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@digits,$value);
}
@digits = map {chr($_)} @digits;
foreach my $char (@digits) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($extender_node) = $doc1->getElementsByTagName('extender');
my @extenders;
foreach my $range_node ($extender_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@extenders,$low..$high);
}
foreach my $single_node ($extender_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@extenders,$value);
}
@extenders = map {chr($_)} @extenders;
foreach my $char (@extenders) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($combining_char_node) = $doc1->getElementsByTagName('combiningchar');
my @combining_chars;
foreach my $range_node ($combining_char_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@combining_chars,$low..$high);
}
foreach my $single_node ($combining_char_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@combining_chars,$value);
}
@combining_chars = map {chr($_)} @combining_chars;
foreach my $char (@combining_chars) {
eval {
my $el = $doc1->createElement("_$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($letter_node) = $doc1->getElementsByTagName('letter');
my @letters;
foreach my $range_node ($letter_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@letters,$low..$high);
}
foreach my $single_node ($letter_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@letters,$value);
}
@letters = map {chr($_)} @letters;
# $XML::Xerces::DEBUG_UTF8_IN = 1;
# $XML::Xerces::DEBUG_UTF8_OUT = 1;
foreach my $char (@letters) {
eval {
my $el = $doc1->createElement("$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
my ($ideograph_node) = $doc1->getElementsByTagName('ideographic');
my @ideographs;
foreach my $range_node ($ideograph_node->getElementsByTagName('range')) {
my $low = hex($range_node->getAttribute('low'));
my $high = hex($range_node->getAttribute('high'));
push(@ideographs,$low..$high);
}
foreach my $single_node ($ideograph_node->getElementsByTagName('single')) {
my $value = hex($single_node->getAttribute('value'));
push(@ideographs,$value);
}
@ideographs = map {chr($_)} @ideographs;
# $XML::Xerces::DEBUG_UTF8_IN = 1;
# $XML::Xerces::DEBUG_UTF8_OUT = 1;
foreach my $char (@ideographs) {
eval {
my $el = $doc1->createElement("$char");
};
if ($@) {
if (ref $@) {
print STDERR "Error code: $@->{code}\n";
} else {
print STDERR $@;
}
}
result(!$@) || printf("char: <0x%.4X>\n",ord($char));
}
$XML::Xerces::DEBUG_UTF8_IN = 0;
$XML::Xerces::DEBUG_UTF8_OUT = 0;
# check that an element can start with an underscore
eval {
my $el = $doc1->createElement('_');
};
result(!$@);
# check that an element can start with an colon
eval {
my $el = $doc1->createElement(':');
};
result(!$@);
1.1 xml-xerces/perl/t/IDOM_Entity.t
Index: IDOM_Entity.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOM_Entity.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..3\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
use XML::Xerces;
use lib 't';
use TestUtils qw(result $IDOM);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
my $document = <<'EOT';
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE foo [
<!ENTITY data2 "DATA">
<!ENTITY data "DATA">
<!ENTITY bar "BAR">
<!ELEMENT foo ANY>
]>
<foo>This is a test &data; of entities</foo>
EOT
$IDOM->setCreateEntityReferenceNodes(1);
$IDOM->setValidationScheme($XML::Xerces::IDOMParser::Val_Never);
my $is = XML::Xerces::MemBufInputSource->new($document);
$IDOM->parse($is);
my $doc = $IDOM->getDocument();
my $doctype = $doc->getDoctype();
# get the single <element> node
my %ents = $doctype->getEntities();
result(exists $ents{data} && $ents{data} eq 'DATA');
result(exists $ents{bar} && $ents{bar} eq 'BAR', my $fail=1);
1.1 xml-xerces/perl/t/IDOM_NamedNodeMap.t
Index: IDOM_NamedNodeMap.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOM_NamedNodeMap.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..14\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
use XML::Xerces;
use lib 't';
use TestUtils qw(result is_object $IDOM);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
my $document = <<EOT;
<list>
<element one='1' two='2' three='3'/>
</list>
EOT
$IDOM->parse(XML::Xerces::MemBufInputSource->new($document));
my $doc = $IDOM->getDocument();
# get the single <element> node
my ($element) = $doc->getElementsByTagName('element');
my %attrs = $element->getAttributes();
result(scalar keys %attrs == 3 &&
$attrs{one} == 1 &&
$attrs{two} == 2 &&
$attrs{three} == 3);
# test that we can still get a IDOM_NodeList object
# and test getLength()
my $idom_node_map = $element->getAttributes();
result(is_object($idom_node_map)
&& $idom_node_map->isa('XML::Xerces::IDOM_NamedNodeMap')
&& $idom_node_map->getLength() == scalar keys %attrs
);
# test item()
for (my $i=0;$i<scalar keys %attrs ;$i++) {
my $node = $idom_node_map->item($i);
result($attrs{$node->getNodeName} == $node->getNodeValue);
}
# test getNamedItem()
foreach (keys %attrs) {
result($idom_node_map->getNamedItem($_)->getNodeValue eq $attrs{$_});
}
# test setNamedItem()
my $four = $doc->createAttribute('four');
$four->setNodeValue('4');
$idom_node_map->setNamedItem($four);
result($idom_node_map->getNamedItem('four')->getNodeValue eq $four->getNodeValue);
# test removeNamedItem()
$idom_node_map->removeNamedItem('four');
result($idom_node_map->getLength() == scalar keys %attrs);
#
# Test the DOM Level 2 methods
#
my $uri = 'http://www.foo.bar/';
$document = <<EOT;
<list xmlns:qs="$uri">
<element qs:one='1' qs:two='2' qs:three='3' one='27'/>
</list>
EOT
$IDOM->setDoNamespaces(1);
$IDOM->parse(XML::Xerces::MemBufInputSource->new($document));
$doc = $IDOM->getDocument();
# get the single <element> node
($element) = $doc->getElementsByTagName('element');
%attrs = $element->getAttributes();
$idom_node_map = $element->getAttributes();
# test getNamedItemNS()
my $oneNS = $idom_node_map->getNamedItemNS($uri,'one');
my $one = $idom_node_map->getNamedItem('one');
result($one->getNodeValue eq '27'
&& $oneNS->getNodeValue eq '1'
);
# test setNamedItem()
$four = $doc->createAttributeNS($uri,'four');
$four->setNodeValue('4');
$idom_node_map->setNamedItemNS($four);
result($idom_node_map->getNamedItemNS($uri,'four')->getNodeValue eq $four->getNodeValue);
# test removeNamedItem()
$idom_node_map->removeNamedItemNS($uri,'four');
result($idom_node_map->getLength() == scalar keys %attrs);
1.1 xml-xerces/perl/t/IDOM_Node.t
Index: IDOM_Node.t
===================================================================
# Before `make install' is performed this script should be runnable
# with `make test'. After `make install' it should work as `perl
# IDOM_Node.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..2\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
use XML::Xerces;
use Config;
use lib 't';
use TestUtils qw(result is_object);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="utf-8"?>
<contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>mpogue@us.ibm.com</email>
</person>
<person Role="developer">
<name>Tom Watson</name>
<email>rtwatson@us.ibm.com</email>
</person>
<person Role="tech writer">
<name>Susan Hardenbrook</name>
<email>susanhar@us.ibm.com</email>
</person>
</contributors>];
my $IDOM1 = new XML::Xerces::IDOMParser;
my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
$IDOM1->setErrorHandler($ERROR_HANDLER);
$IDOM1->parse(XML::Xerces::MemBufInputSource->new($document));
my $IDOM2 = new XML::Xerces::IDOMParser;
$IDOM2->setErrorHandler($ERROR_HANDLER);
$IDOM2->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'));
my $doc1 = $IDOM1->getDocument();
my $doc2 = $IDOM2->getDocument();
my $root1 = $doc1->getDocumentElement();
my @persons1 = $doc1->getElementsByTagName('person');
my @names1 = $doc1->getElementsByTagName('name');
my $root2 = $doc2->getDocumentElement();
my @persons2 = $doc2->getElementsByTagName('person');
my @names2 = $doc1->getElementsByTagName('name');
# importing a child from a different document
eval {
my $copy = $doc1->importNode($persons1[0],0);
$root1->appendChild($copy);
};
result(!$@ &&
scalar @persons1 < scalar ($root1->getElementsByTagName('person')));
1.1 xml-xerces/perl/t/IDOM_NodeList.t
Index: IDOM_NodeList.t
===================================================================
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl IDOM_NodeList.t'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..10\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
use Cwd;
# use blib;
use XML::Xerces;
use lib 't';
use TestUtils qw(result $IDOM $PERSONAL_FILE_NAME is_object);
use vars qw($i $loaded);
use strict;
$loaded = 1;
$i = 1;
result($loaded);
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
$IDOM->parse( new XML::Xerces::LocalFileInputSource($PERSONAL_FILE_NAME) );
my $doc = $IDOM->getDocument();
# test automatic conversion to perl list
my @node_list = $doc->getElementsByTagName('person');
result(scalar @node_list == 6);
# test that we can still get a IDOM_NodeList object
my $idom_node_list = $doc->getElementsByTagName('person');
result(is_object($idom_node_list) &&
$idom_node_list->isa('XML::Xerces::IDOM_NodeList'));
result($idom_node_list->getLength() == scalar @node_list);
for (my $i=0;$i<scalar @node_list;$i++) {
result($node_list[$i] == $idom_node_list->item($i));
}
1.1 xml-xerces/perl/t/letter.xml
Index: letter.xml
===================================================================
<?xml version="1.0"?>
<utf>
<letter>
<range low="0x0041" high="0x005A"/>
<range low="0x0061" high="0x007A"/>
<range low="0x00C0" high="0x00D6"/>
<range low="0x00D8" high="0x00F6"/>
<range low="0x00F8" high="0x00FF"/>
<range low="0x0100" high="0x0131"/>
<range low="0x0134" high="0x013E"/>
<range low="0x0141" high="0x0148"/>
<range low="0x014A" high="0x017E"/>
<range low="0x0180" high="0x01C3"/>
<range low="0x01CD" high="0x01F0"/>
<range low="0x01F4" high="0x01F5"/>
<range low="0x01FA" high="0x0217"/>
<range low="0x0250" high="0x02A8"/>
<range low="0x02BB" high="0x02C1"/>
<single value="0x0386"/>
<range low="0x0388" high="0x038A"/>
<single value="0x038C"/>
<range low="0x038E" high="0x03A1"/>
<range low="0x03A3" high="0x03CE"/>
<range low="0x03D0" high="0x03D6"/>
<single value="0x03DA"/>
<single value="0x03DC"/>
<single value="0x03DE"/>
<single value="0x03E0"/>
<range low="0x03E2" high="0x03F3"/>
<range low="0x0401" high="0x040C"/>
<range low="0x040E" high="0x044F"/>
<range low="0x0451" high="0x045C"/>
<range low="0x045E" high="0x0481"/>
<range low="0x0490" high="0x04C4"/>
<range low="0x04C7" high="0x04C8"/>
<range low="0x04CB" high="0x04CC"/>
<range low="0x04D0" high="0x04EB"/>
<range low="0x04EE" high="0x04F5"/>
<range low="0x04F8" high="0x04F9"/>
<range low="0x0531" high="0x0556"/>
<single value="0x0559"/>
<range low="0x0561" high="0x0586"/>
<range low="0x05D0" high="0x05EA"/>
<range low="0x05F0" high="0x05F2"/>
<range low="0x0621" high="0x063A"/>
<range low="0x0641" high="0x064A"/>
<range low="0x0671" high="0x06B7"/>
<range low="0x06BA" high="0x06BE"/>
<range low="0x06C0" high="0x06CE"/>
<range low="0x06D0" high="0x06D3"/>
<single value="0x06D5"/>
<range low="0x06E5" high="0x06E6"/>
<range low="0x0905" high="0x0939"/>
<single value="0x093D"/>
<range low="0x0958" high="0x0961"/>
<range low="0x0985" high="0x098C"/>
<range low="0x098F" high="0x0990"/>
<range low="0x0993" high="0x09A8"/>
<range low="0x09AA" high="0x09B0"/>
<single value="0x09B2"/>
<range low="0x09B6" high="0x09B9"/>
<range low="0x09DC" high="0x09DD"/>
<range low="0x09DF" high="0x09E1"/>
<range low="0x09F0" high="0x09F1"/>
<range low="0x0A05" high="0x0A0A"/>
<range low="0x0A0F" high="0x0A10"/>
<range low="0x0A13" high="0x0A28"/>
<range low="0x0A2A" high="0x0A30"/>
<range low="0x0A32" high="0x0A33"/>
<range low="0x0A35" high="0x0A36"/>
<range low="0x0A38" high="0x0A39"/>
<range low="0x0A59" high="0x0A5C"/>
<single value="0x0A5E"/>
<range low="0x0A72" high="0x0A74"/>
<range low="0x0A85" high="0x0A8B"/>
<single value="0x0A8D"/>
<range low="0x0A8F" high="0x0A91"/>
<range low="0x0A93" high="0x0AA8"/>
<range low="0x0AAA" high="0x0AB0"/>
<range low="0x0AB2" high="0x0AB3"/>
<range low="0x0AB5" high="0x0AB9"/>
<single value="0x0ABD"/>
<single value="0x0AE0"/>
<range low="0x0B05" high="0x0B0C"/>
<range low="0x0B0F" high="0x0B10"/>
<range low="0x0B13" high="0x0B28"/>
<range low="0x0B2A" high="0x0B30"/>
<range low="0x0B32" high="0x0B33"/>
<range low="0x0B36" high="0x0B39"/>
<single value="0x0B3D"/>
<range low="0x0B5C" high="0x0B5D"/>
<range low="0x0B5F" high="0x0B61"/>
<range low="0x0B85" high="0x0B8A"/>
<range low="0x0B8E" high="0x0B90"/>
<range low="0x0B92" high="0x0B95"/>
<range low="0x0B99" high="0x0B9A"/>
<single value="0x0B9C"/>
<range low="0x0B9E" high="0x0B9F"/>
<range low="0x0BA3" high="0x0BA4"/>
<range low="0x0BA8" high="0x0BAA"/>
<range low="0x0BAE" high="0x0BB5"/>
<range low="0x0BB7" high="0x0BB9"/>
<range low="0x0C05" high="0x0C0C"/>
<range low="0x0C0E" high="0x0C10"/>
<range low="0x0C12" high="0x0C28"/>
<range low="0x0C2A" high="0x0C33"/>
<range low="0x0C35" high="0x0C39"/>
<range low="0x0C60" high="0x0C61"/>
<range low="0x0C85" high="0x0C8C"/>
<range low="0x0C8E" high="0x0C90"/>
<range low="0x0C92" high="0x0CA8"/>
<range low="0x0CAA" high="0x0CB3"/>
<range low="0x0CB5" high="0x0CB9"/>
<single value="0x0CDE"/>
<range low="0x0CE0" high="0x0CE1"/>
<range low="0x0D05" high="0x0D0C"/>
<range low="0x0D0E" high="0x0D10"/>
<range low="0x0D12" high="0x0D28"/>
<range low="0x0D2A" high="0x0D39"/>
<range low="0x0D60" high="0x0D61"/>
<range low="0x0E01" high="0x0E2E"/>
<single value="0x0E30"/>
<range low="0x0E32" high="0x0E33"/>
<range low="0x0E40" high="0x0E45"/>
<range low="0x0E81" high="0x0E82"/>
<single value="0x0E84"/>
<range low="0x0E87" high="0x0E88"/>
<single value="0x0E8A"/>
<single value="0x0E8D"/>
<range low="0x0E94" high="0x0E97"/>
<range low="0x0E99" high="0x0E9F"/>
<range low="0x0EA1" high="0x0EA3"/>
<single value="0x0EA5"/>
<single value="0x0EA7"/>
<range low="0x0EAA" high="0x0EAB"/>
<range low="0x0EAD" high="0x0EAE"/>
<single value="0x0EB0"/>
<range low="0x0EB2" high="0x0EB3"/>
<single value="0x0EBD"/>
<range low="0x0EC0" high="0x0EC4"/>
<range low="0x0F40" high="0x0F47"/>
<range low="0x0F49" high="0x0F69"/>
<range low="0x10A0" high="0x10C5"/>
<range low="0x10D0" high="0x10F6"/>
<single value="0x1100"/>
<range low="0x1102" high="0x1103"/>
<range low="0x1105" high="0x1107"/>
<single value="0x1109"/>
<range low="0x110B" high="0x110C"/>
<range low="0x110E" high="0x1112"/>
<single value="0x113C"/>
<single value="0x113E"/>
<single value="0x1140"/>
<single value="0x114C"/>
<single value="0x114E"/>
<single value="0x1150"/>
<range low="0x1154" high="0x1155"/>
<single value="0x1159"/>
<range low="0x115F" high="0x1161"/>
<single value="0x1163"/>
<single value="0x1165"/>
<single value="0x1167"/>
<single value="0x1169"/>
<range low="0x116D" high="0x116E"/>
<range low="0x1172" high="0x1173"/>
<single value="0x1175"/>
<single value="0x119E"/>
<single value="0x11A8"/>
<single value="0x11AB"/>
<range low="0x11AE" high="0x11AF"/>
<range low="0x11B7" high="0x11B8"/>
<single value="0x11BA"/>
<range low="0x11BC" high="0x11C2"/>
<single value="0x11EB"/>
<single value="0x11F0"/>
<single value="0x11F9"/>
<range low="0x1E00" high="0x1E9B"/>
<range low="0x1EA0" high="0x1EF9"/>
<range low="0x1F00" high="0x1F15"/>
<range low="0x1F18" high="0x1F1D"/>
<range low="0x1F20" high="0x1F45"/>
<range low="0x1F48" high="0x1F4D"/>
<range low="0x1F50" high="0x1F57"/>
<single value="0x1F59"/>
<single value="0x1F5B"/>
<single value="0x1F5D"/>
<range low="0x1F5F" high="0x1F7D"/>
<range low="0x1F80" high="0x1FB4"/>
<range low="0x1FB6" high="0x1FBC"/>
<single value="0x1FBE"/>
<range low="0x1FC2" high="0x1FC4"/>
<range low="0x1FC6" high="0x1FCC"/>
<range low="0x1FD0" high="0x1FD3"/>
<range low="0x1FD6" high="0x1FDB"/>
<range low="0x1FE0" high="0x1FEC"/>
<range low="0x1FF2" high="0x1FF4"/>
<range low="0x1FF6" high="0x1FFC"/>
<single value="0x2126"/>
<range low="0x212A" high="0x212B"/>
<single value="0x212E"/>
<range low="0x2180" high="0x2182"/>
<range low="0x3041" high="0x3094"/>
<range low="0x30A1" high="0x30FA"/>
<range low="0x3105" high="0x312C"/>
<range low="0xAC00" high="0xD7A3"/>
</letter>
<ideographic>
<range low="0x4E00" high="0x9FA5"/>
<single value="0x3007"/>
<range low="0x3021" high="0x3029"/>
</ideographic>
<combiningchar>
<range low="0x0300" high="0x0345"/>
<range low="0x0360" high="0x0361"/>
<range low="0x0483" high="0x0486"/>
<range low="0x0591" high="0x05A1"/>
<range low="0x05A3" high="0x05B9"/>
<range low="0x05BB" high="0x05BD"/>
<single value="0x05BF"/>
<range low="0x05C1" high="0x05C2"/>
<single value="0x05C4"/>
<range low="0x064B" high="0x0652"/>
<single value="0x0670"/>
<range low="0x06D6" high="0x06DC"/>
<range low="0x06DD" high="0x06DF"/>
<range low="0x06E0" high="0x06E4"/>
<range low="0x06E7" high="0x06E8"/>
<range low="0x06EA" high="0x06ED"/>
<range low="0x0901" high="0x0903"/>
<single value="0x093C"/>
<range low="0x093E" high="0x094C"/>
<single value="0x094D"/>
<range low="0x0951" high="0x0954"/>
<range low="0x0962" high="0x0963"/>
<range low="0x0981" high="0x0983"/>
<single value="0x09BC"/>
<single value="0x09BE"/>
<single value="0x09BF"/>
<range low="0x09C0" high="0x09C4"/>
<range low="0x09C7" high="0x09C8"/>
<range low="0x09CB" high="0x09CD"/>
<single value="0x09D7"/>
<range low="0x09E2" high="0x09E3"/>
<single value="0x0A02"/>
<single value="0x0A3C"/>
<single value="0x0A3E"/>
<single value="0x0A3F"/>
<range low="0x0A40" high="0x0A42"/>
<range low="0x0A47" high="0x0A48"/>
<range low="0x0A4B" high="0x0A4D"/>
<range low="0x0A70" high="0x0A71"/>
<range low="0x0A81" high="0x0A83"/>
<single value="0x0ABC"/>
<range low="0x0ABE" high="0x0AC5"/>
<range low="0x0AC7" high="0x0AC9"/>
<range low="0x0ACB" high="0x0ACD"/>
<range low="0x0B01" high="0x0B03"/>
<single value="0x0B3C"/>
<range low="0x0B3E" high="0x0B43"/>
<range low="0x0B47" high="0x0B48"/>
<range low="0x0B4B" high="0x0B4D"/>
<range low="0x0B56" high="0x0B57"/>
<range low="0x0B82" high="0x0B83"/>
<range low="0x0BBE" high="0x0BC2"/>
<range low="0x0BC6" high="0x0BC8"/>
<range low="0x0BCA" high="0x0BCD"/>
<single value="0x0BD7"/>
<range low="0x0C01" high="0x0C03"/>
<range low="0x0C3E" high="0x0C44"/>
<range low="0x0C46" high="0x0C48"/>
<range low="0x0C4A" high="0x0C4D"/>
<range low="0x0C55" high="0x0C56"/>
<range low="0x0C82" high="0x0C83"/>
<range low="0x0CBE" high="0x0CC4"/>
<range low="0x0CC6" high="0x0CC8"/>
<range low="0x0CCA" high="0x0CCD"/>
<range low="0x0CD5" high="0x0CD6"/>
<range low="0x0D02" high="0x0D03"/>
<range low="0x0D3E" high="0x0D43"/>
<range low="0x0D46" high="0x0D48"/>
<range low="0x0D4A" high="0x0D4D"/>
<single value="0x0D57"/>
<single value="0x0E31"/>
<range low="0x0E34" high="0x0E3A"/>
<range low="0x0E47" high="0x0E4E"/>
<single value="0x0EB1"/>
<range low="0x0EB4" high="0x0EB9"/>
<range low="0x0EBB" high="0x0EBC"/>
<range low="0x0EC8" high="0x0ECD"/>
<range low="0x0F18" high="0x0F19"/>
<single value="0x0F35"/>
<single value="0x0F37"/>
<single value="0x0F39"/>
<single value="0x0F3E"/>
<single value="0x0F3F"/>
<range low="0x0F71" high="0x0F84"/>
<range low="0x0F86" high="0x0F8B"/>
<range low="0x0F90" high="0x0F95"/>
<single value="0x0F97"/>
<range low="0x0F99" high="0x0FAD"/>
<range low="0x0FB1" high="0x0FB7"/>
<single value="0x0FB9"/>
<range low="0x20D0" high="0x20DC"/>
<single value="0x20E1"/>
<range low="0x302A" high="0x302F"/>
<single value="0x3099"/>
<single value="0x309A"/>
</combiningchar>
<digit>
<range low="0x0030" high="0x0039"/>
<range low="0x0660" high="0x0669"/>
<range low="0x06F0" high="0x06F9"/>
<range low="0x0966" high="0x096F"/>
<range low="0x09E6" high="0x09EF"/>
<range low="0x0A66" high="0x0A6F"/>
<range low="0x0AE6" high="0x0AEF"/>
<range low="0x0B66" high="0x0B6F"/>
<range low="0x0BE7" high="0x0BEF"/>
<range low="0x0C66" high="0x0C6F"/>
<range low="0x0CE6" high="0x0CEF"/>
<range low="0x0D66" high="0x0D6F"/>
<range low="0x0E50" high="0x0E59"/>
<range low="0x0ED0" high="0x0ED9"/>
<range low="0x0F20" high="0x0F29"/>
</digit>
<extender>
<single value="0x00B7"/>
<single value="0x02D0"/>
<single value="0x02D1"/>
<single value="0x0387"/>
<single value="0x0640"/>
<single value="0x0E46"/>
<single value="0x0EC6"/>
<single value="0x3005"/>
<range low="0x3031" high="0x3035"/>
<range low="0x309D" high="0x309E"/>
<range low="0x30FC" high="0x30FE"/>
</extender>
</utf>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org