Subject: | Can't call method "derive" on an undefined value |
Finding of type fails on the "<xsd:restriction
base="xsd:nonNegativeInteger"/>" line on my schema file.
$ /usr/local/bin/perl -MDevel::Cover=-silent,1 validate.pl
Can't call method "derive" on an undefined value at
/home/y/lib/perl5/site_perl/5.8/XML/Validator/Schema/SimpleTypeNode.pm
line 82.
I was able to trace it back to the find sub in
XML/Validator/Schema/Library.pm
sub find {
[snip]
$arg{name} =~ s!^[^:]*:!!;
[snip]
Apparently this doesn't actually change the value for the name key
under some circumstances (something to do with the name coming from XS?).
One possible way to fix this:
my $name = $arg{name};
$name =~ s!^[^:]*:!!;
$arg{name} = $name;
I suspect this work because we aren't trying to update the value that
came fromt he parser.
I can only reproduce this behavior when the following three conditions
are true:
- run perl 5.8
- run with Devel::Cover
- use parser provided by XML-SAX-ExpatXS
using perl 5.10, not using Devel::Cover, or using different parser all
make the code run successfully, and I don't have a clue as to why its
this combination of 3 conditions that trigger this ....
perl, v5.8.6 built for i686-linux-64int
Devel-Cover-0.68
XML-SAX-0.96
XML-SAX-ExpatXS-1.31
XML-Validator-Schema-1.10
same for perl, v5.8.5 built for i386-freebsd-thread-multi
eg
$ /usr/local/bin/perl validate.pl
validator=XML::Filter::BufferText=HASH(0x9e01758)
test program: validate.pl
--------------------------
#!/usr/local/bin/perl -w
use strict;
use Data::Dumper;
use XML::SAX::ParserFactory;
use XML::Validator::Schema;
# main
{
my $validator = XML::Validator::Schema->new (
file => "algo.xsd",
);
print "validator=$validator\n";
}
--------------------------
test schema (algo.xsd)
---------------------------------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="idType">
<xsd:restriction base="xsd:nonNegativeInteger"/>
</xsd:simpleType>
<xsd:complexType name="algoType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="algo_id" type="idType"/>
</xsd:complexType>
</xsd:schema>
---------------------------------------