NAME

TypeLibrary::FromXSD::Element - Create a single type decleration from a simpleType xsd element

VERSION

version 0.05

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

ATTRIBUTES

  • name

  • base

  • orig_base

  • enum

  • restrictions

for two attributes check functions exist:

  • has_enum

  • has_restrictions

METHODS

BUILDARGS

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.

AUTHOR

Renee Baecker <github@renee-baecker.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)