[Xml-compile] Crash on new
Mark Overmeer
mark at overmeer.net
Fri Dec 2 08:44:29 GMT 2011
* Gary Kennedy (gary at apnic.net) [111202 00:50]:
> if($stop)
> { # ^S = EXCEPTIONS_BEING_CAUGHT, within eval or try
> ---> $^S or exit($opts->{errno} || 0);
This line is required to make try {}; blocks work: fundamental. By removing it,
you just kill the exception mechanism.
> The line that is triggering the report is 196 in XML::Compile::Translate
> v1.22. (It's trying to compile the READER for xsd:schema)
> Where $fullname + $path are "{http://www.w3.org/2001/XMLSchema}schema";
The schema type is not recognized, because XML::Compile has not been
initialized on that moment. This is caused by your import trick: import
runs on the moment that the compilation of that single pm file has been
successful, before the next module gets compiled. So: many components of
your program are still half-way or not available at the time. You should
not use import for other things than processing module parameters.
You may move your setup logic into an INIT block, which runs after all
code is available. But when your module is OO, you should initialize
in new().
In rare cases, I need:
sub new(@)
{ _initialize unless $initialized++;
...
}
In most cases, it is sufficient to add some code outside subs:
_initialize;
sub new() {}
Or maybe this:
my @config;
sub import(@) { shift; @config = @_ }
_initialize(@config);
--
I hope this helps,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the Xml-compile
mailing list