NAME

XML::Schema::Type::Simple - base class for simple XML Schema datatypes

SYNOPSIS

    package XML::Schema::Type::whatever;
    use base qw( XML::Schema::Type::Simple );
    use vars qw( @FACETS );

    @FACETS = (
	minLength  => 10,
	maxLength  => 30,
	otherFacet => { 
	    value  => $n, 
	    fixed  => 1, 
	    annotation => "a comment",
	}, 
    );

    package main;

    my $type = XML::Schema::Type::whatever->new()
        || die XML::Schema::Type::whatever->error();

    my $item = $type->instance('some instance value')
        || die $type->error();

    # NOTE: some issues still to resolve on the precise 
    # nature and structure of instances (currently hash ref).
    print $item->{ value };

DESCRIPTION

The XML::Schema::Type::Simple module is a base class for objects that represent XML Schema simple types.

TODO

  • At the moment it's cumbersome to have to manually instantiate a type object and then call instance() on it. new() should probably become class() and instance() should become new(). Calling new() as a class method should automatically generate a prototype class object via class() and call new() against that (and also cache the prototype in a package variable for future invocations).

    my $pkg   = 'XML::Schema::Type::string';
    my $obj1  = $pkg->new();
    my $class = $pkg->class();
    my $obj2  = $class->new();

    The only remaining issue is then which class we should bless the type instance into, if any? We don't want to bless it into the *::Type::* class because it's not a type, it's an instance. One possiblity is to degrade the type system to work only at the class/package level, i.e. types would be analogous to Perl packages. Although this might make more sense in the long run, at this point in time I suspect that there are more benefits to be had from allowing types to be living, breathing objects which can be cloned and specialised. We _could_ do this via Perl packages, but I'm wary about building lots of new Perl packages and evaling them at runtime to allow user-definable types to be created on-the-fly. Another possibility is to bless it into a corresponding *::Instance::* package. A third, and the current favourite, is to not bless it at all. Leave it as a hash and then let the caller bless it into an Element or Attribute.

AUTHOR

Andy Wardley <abw@kfs.org>

VERSION

This is version $Revision: 1.2 $ of the XML::Schema::Type::Simple, distributed with version 0.1 of the XML::Schema module set.

COPYRIGHT

Copyright (C) 2001 Canon Research Centre Europe Ltd. All Rights Reserved.

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

SEE ALSO

See also XML::Schema and XML::Schema::Type.