use TypeLibrary::FromXSD::Element; use XML::LibXML; my $xsd = 'test.xsd'; my $tree = XML::LibXML->new->parse_file( $xsd )->getDocumentElement; my @nodes = $tree->getElementsByTagName( 'xs:simpleType' ); for my $xsd_node ( @nodes ) { my $element = TypeLibrary::FromXSD::Element->new( $xsd_node ); # to provide additional validation methods # my $element = TypeLibrary::FromXSD::Element->new( $xsd_node, validate => { date => 'validate_date' } ); print $element->type; }
Create a Element object, in contrast to other classes, this constructor wants a single parameter - a simpleType node.
This class gets all needed attributes and subnodes to create the type declaration.
prints the type declaration
Please note that this distribution does not support all combinations of basetypes (xs:string, xs:decimal, ...) and other restrictions (xs:minLength, xs:maxLength, ...) yet.
To install TypeLibrary::FromXSD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TypeLibrary::FromXSD
CPAN shell
perl -MCPAN -e shell install TypeLibrary::FromXSD
For more information on module installation, please visit the detailed CPAN module installation guide.