bash-4.3$ perl scritps/mypastorize.pl ../dati/schemi/schemaeac.xsd ../lib/ SAN::EAC
Pastor : Processing schema : '../dati/schemi/schemaeac.xsd' ...
Pastor : Fetching schema : 'file:///home/from_bsd/ferz/gittery/Promemoria/dati/schemi/schemaeac.xsd' ...
Pastor : Parsing schema ...
Pastor : Parsing ended
Pastor : Processing schema : 'http://www.w3.org/XML/2008/06/xlink.xsd' ...
Pastor : Fetching schema : 'http://www.w3.org/XML/2008/06/xlink.xsd' ...
Pastor : Parsing schema ...
Pastor : Parsing ended
Pastor : Processing schema : 'http://www.w3.org/2001/xml.xsd' ...
Pastor : Fetching schema : 'http://www.w3.org/2001/xml.xsd' ...
Pastor : Parsing schema ...
Pastor : Parsing ended
Pastor : Unexpected element 'div' in schema!
<documentation >
<div >
<h1 />
<div class="bodytext" >
<p />
<p >
<a href="http://www.w3.org/XML/1998/namespace.html" />
<a href="http://www.w3.org/TR/REC-xml" />
</p>
<p />
<p >
<a href="#usage" />
<a href="#nsversioning" />
</p>
</div>
</div>
</documentation>
--- mypastorize.pl ---
#!/usr/bin/env perl
use strict;
use warnings;
use Modern::Perl;
if (@ARGV < 1) {
say "Usage: ";
say " " . $0 . " path/schema.xsd";
say " " . $0 . " path/schema.xsd destination_path";
say " " . $0 . " path/schema.xsd destination_path class_prefix";
say "Default:";
say " destination_path = /tmp/lib/perl";
say " class_prefix = MyApp::Data";
exit(1);
}
use XML::Pastor;
my $pastor = XML::Pastor->new();
# Generate MULTIPLE modules, one module for each class, and put them under destination.
my $schema = $ARGV[0];
my $destination = $ARGV[1] || '/tmp/lib/perl';
my $class_prefix = $ARGV[2] || 'MyApp::Data::';
`mkdir -p $destination` unless (-e $destination);
eval {
$pastor->generate(
mode =>'offline',
style => 'multiple',
schema=>$schema,
class_prefix=>$class_prefix,
destination=>$destination,
verbose=>9,
);
};
if ($@) {
say $@;
}
exit;