For details read Perl NOC. After June 25

Alex J. G. Burzyński >
MooseX-Types-XMLSchema-0.06 >
MooseX::Types::XMLSchema

Module Version: 0.06
- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- TYPES
- xs:string
- xs:integer
- xs:positiveInteger
- xs:nonPositiveInteger
- xs:negativeInteger
- xs:nonNegativeInteger
- xs:long
- xs:unsignedLong
- xs:int
- xs:unsignedInt
- xs:short
- xs:unsignedShort
- xs:byte
- xs:unsignedByte
- xs:boolean
- xs:float
- xs:double
- xs:decimal
- xs:duration
- xs:dateTime
- xs:time
- xs:date
- xs:gYearMonth
- xs:gYear
- xs:gMonthDay
- xs:gDay
- xs:gMonth
- xs:base64Binary
- xs:anyURI

- SEE ALSO
- AUTHOR
- COPYRIGHT AND LICENSE

MooseX::Types::XMLSchema - XMLSchema compatible Moose types library

version 0.06

package My::Class; use Moose; use MooseX::Types::XMLSchema qw( :all ); has 'string' => ( is => 'rw', isa => 'xs:string' ); has 'boolean' => ( is => 'rw', isa => 'xs:boolean' ); has 'byte' => ( is => 'rw', isa => 'xs:byte' ); has 'short' => ( is => 'rw', isa => 'xs:short' ); has 'int' => ( is => 'rw', isa => 'xs:int' ); has 'long' => ( is => 'rw', isa => 'xs:long', coerce => 1 ); has 'integer' => ( is => 'rw', isa => 'xs:integer', coerce => 1 ); has 'float' => ( is => 'rw', isa => 'xs:float', coerce => 1 ); has 'double' => ( is => 'rw', isa => 'xs:double', coerce => 1 ); has 'decimal' => ( is => 'rw', isa => 'xs:decimal', coerce => 1 ); has 'duration' => ( is => 'rw', isa => 'xs:duration', coerce => 1 ); has 'datetime' => ( is => 'rw', isa => 'xs:dateTime', coerce => 1 ); has 'time' => ( is => 'rw', isa => 'xs:time', coerce => 1 ); has 'date' => ( is => 'rw', isa => 'xs:date', coerce => 1 ); has 'gYearMonth' => ( is => 'rw', isa => 'xs:gYearMonth', coerce => 1 ); has 'gYear' => ( is => 'rw', isa => 'xs:gYear', coerce => 1 ); has 'gMonthDay' => ( is => 'rw', isa => 'xs:gMonthDay', coerce => 1 ); has 'gDay' => ( is => 'rw', isa => 'xs:gDay', coerce => 1 ); has 'gMonth' => ( is => 'rw', isa => 'xs:gMonth', coerce => 1 ); has 'base64Binary' => ( is => 'rw', isa => 'xs:base64Binary', coerce => 1 ); has 'anyURI' => ( is => 'rw', isa => 'xs:anyURI', coerce => 1 ); has 'nonPositiveInteger' => ( is => 'rw', isa => 'xs:nonPositiveInteger', coerce => 1 ); has 'positiveInteger' => ( is => 'rw', isa => 'xs:positiveInteger', coerce => 1 ); has 'nonNegativeInteger' => ( is => 'rw', isa => 'xs:nonNegativeInteger', coerce => 1 ); has 'negativeInteger' => ( is => 'rw', isa => 'xs:negativeInteger', coerce => 1 ); has 'unsignedByte' => ( is => 'rw', isa => 'xs:unsignedByte' ); has 'unsignedShort' => ( is => 'rw', isa => 'xs:unsignedShort' ); has 'unsignedInt' => ( is => 'rw', isa => 'xs:unsignedInt' ); has 'unsignedLong' => ( is => 'rw', isa => 'xs:unsignedLong', coerce => 1 );

Then, elsewhere:

my $object = My::Class->new( string => 'string', decimal => Math::BigFloat->new(20.12), duration => DateTime->now - DateTime->(year => 1990), base64Binary => IO::File->new($0), );

This class provides a number of XMLSchema compatible types for your Moose classes.

has 'string' => ( is => 'rw', isa => 'xs:string' );

A wrapper around built-in Str.

has 'integer' => ( is => 'rw', isa => 'xs:integer', coerce => 1 );

A Math::BigInt object. Set to coerce from Int/Str.

This is defined in XSchema to be an arbitrary size integer.

has 'positiveInteger' => ( is => 'rw', isa => 'xs:positiveInteger', coerce => 1, );

A Math::BigInt object. Set to coerce from Int/Str.

This is defined in XSchema to be an arbitrary size integer greater than zero.

has 'nonPositiveInteger' => ( is => 'rw', isa => 'xs:nonPositiveInteger', coerce => 1, );

A Math::BigInt object. Set to coerce from Int/Str.

This is defined in XSchema to be an arbitrary size integer less than or equal to zero.

has 'negativeInteger' => ( is => 'rw', isa => 'xs:negativeInteger', coerce => 1, );

A Math::BigInt object. Set to coerce from Int/Str.

This is defined in XSchema to be an arbitrary size integer less than zero.

has 'nonPositiveInteger' => ( is => 'rw', isa => 'xs:nonNegativeInteger', coerce => 1, );

A Math::BigInt object. Set to coerce from Int/Str.

This is defined in XSchema to be an arbitrary size integer greater than or equal to zero.

has 'long' => ( is => 'rw', isa => 'xs:long', coerce => 1, );

A 64-bit Integer. Represented as a Math::Bigint object, but limited to the 64-bit (signed) range. Set to coerce from Int/Str.

has 'unsignedLong' => ( is => 'rw', isa => 'xs:unsignedLong', coerce => 1, );

A 64-bit Integer. Represented as a Math::Bigint object, but limited to the 64-bit (unsigned) range. Set to coerce from Int/Str.

has 'int' => ( is => 'rw', isa => 'xs:int' );

A 32-bit integer. Represented natively.

has 'unsignedInt' => ( is => 'rw', isa => 'xs:unsignedInt' );

A 32-bit integer. Represented natively.

has 'short' => ( is => 'rw', isa => 'xs:short' );

A 16-bit integer. Represented natively.

has 'unsignedShort' => ( is => 'rw', isa => 'xs:unsignedShort' );

A 16-bit integer. Represented natively.

has 'byte' => ( is => 'rw', isa => 'xs:byte' );

An 8-bit integer. Represented natively.

has 'unsignedByte' => ( is => 'rw', isa => 'xs:unsignedByte' );

An 8-bit integer. Represented natively.

has 'boolean' => ( is => 'rw', isa => 'xs:boolean' );

A wrapper around built-in Bool.

has 'float' => ( is => 'rw', isa => 'xs:float', coerce => 1, );

A single-precision 32-bit Float. Represented as a Math::BigFloat object, but limited to the 32-bit range. Set to coerce from Num/Str.

has 'double' => ( is => 'rw', isa => 'xs:double', coerce => 1, );

A double-precision 64-bit Float. Represented as a Math::BigFloat object, but limited to the 64-bit range. Set to coerce from Num/Str.

has 'decimal' => ( is => 'rw', isa => 'xs:decimal', coerce => 1, );

Any base-10 fixed-point number. Represented as a Math::BigFloat object. Set to coerce from Num/Str.

has 'duration' => ( is => 'rw', isa => 'xs:duration', coerce => 1, );

A wrapper around Str. If you enable coerce you can pass a DateTime::Duration object.

has 'datetime' => ( is => 'rw', isa => 'xs:dateTime', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object.

has 'time' => ( is => 'rw', isa => 'xs:time', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object.

has 'date' => ( is => 'rw', isa => 'xs:date', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object.

has 'gYearMonth' => ( is => 'rw', isa => 'xs:gYearMonth', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object or a ArrayRef of two integers.

has 'gYear' => ( is => 'rw', isa => 'xs:gYear', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object.

has 'gMonthDay' => ( is => 'rw', isa => 'xs:gMonthDay', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object or a ArrayRef of two integers.

has 'gDay' => ( is => 'rw', isa => 'xs:gDay', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object or Int eg. 24.

has 'gMonth' => ( is => 'rw', isa => 'xs:gMonth', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a DateTime object or Int eg. 10.

has 'base64Binary' => ( is => 'rw', isa => 'xs:base64Binary', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a IO::Handle object - the content of the file will be encoded to UTF-8 before encoding with base64.

has 'anyURI' => ( is => 'rw', isa => 'xs:anyURI', coerce => 1 );

A wrapper around Str. If you enable coerce you can pass a URI object.

- Enable attributes coercion automatically with

Alex J. G. Burzyński <ajgb@cpan.org>

This software is copyright (c) 2012 by Alex J. G. Burzyński <ajgb@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: