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 94 95 96 97
|
#!/usr/bin/perl
# This example was contribute by Wesley Schwengle, MintLab NL 2015-08-22
# It has the same license as XML::Compile::WSDL11, where it is included
# in the bin/ directory of the distribution.
use warnings;
use strict;
use XML::Compile::Schema;
use Getopt::Long;
use Pod::Usage;
my %opt = (
help => 0,
);
GetOptions(
\%opt, qw(
help
xsd=s@
element=s@
print_index
list_namespace
xml
)
) or pod2usage(1);
pod2usage(0) if ($opt{help});
unless (defined $opt{xsd}) {
warn "Missing option: xsd";
pod2usage(1);
}
my $schema = XML::Compile::Schema->new($opt{xsd});
if ($opt{element}) {
my $type = $opt{xml} ? 'XML' : 'PERL';
foreach (@{$opt{element}}) {
print "\n" . $schema->template($type, $_, skip_header => 1) . "\n";
}
}
elsif ($opt{print_index}) {
$schema->printIndex;
}
elsif ($opt{list_namespace}) {
print join("\n", $schema->namespaces()->list, '');
}
else {
print join("\n", $schema->elements(), '');
}
1;
__END__
=head1 NAME
xsd-explain.pl - Explain XSD files
=head1 SYNOPSIS
xsd-explain.pl OPTIONS
List all the elements
xsd-explain.pl \
--xsd buildservice.xsd \
--xsd dev.java.net.array.xsd
=head1 OPTIONS
=over
=item * xsd
The path to the XSD you want to check, required. Multiples are allowed.
=item * element
The element you want to know more about, optional. Multiples are allowed.
=item * xml
If you have supplied an element, you can choose a Perl or an XML data structure.
When not enabled we display a perl data structure
=item * print_index
Prints the index of the schema
=item * list_namespace
List the namespaces
=back
|