The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

SYNOPSIS

  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;
  }

METHODS

new

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.

type

prints the type declaration

NOTE

Please note that this distribution does not support all combinations of basetypes (xs:string, xs:decimal, ...) and other restrictions (xs:minLength, xs:maxLength, ...) yet.