TypeLibrary::FromXSD::Element - Create a single type decleration from a simpleType xsd element
version 0.05
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; }
name
base
orig_base
enum
restrictions
for two attributes check functions exist:
has_enum
has_restrictions
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.
Renee Baecker <github@renee-baecker.de>
This software is Copyright (c) 2013 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
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.