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

NAME

XML::Pastor::Type - Ancestor of XML::Pastor::ComplexType and XML::Pastor::SimpleType.

WARNING

This module is used internally by XML::Pastor. You do not normally know much about this module to actually use XML::Pastor. It is documented here for completeness and for XML::Pastor developers. Do not count on the interface of this module. It may change in any of the subsequent releases. You have been warned.

ISA

This class descends from Class::Data::Inheritable.

DESCRIPTION

XML::Pastor::Type is an abstract ancestor of XML::Pastor::ComplexType and XML::Pastor::SimpleType and therefore indirectly of all simple and complex classes generated by XML::Pastor which is a Perl code generator from W3C XSD schemas. For an introduction, please refer to the documentation of XML::Pastor.

XML::Pastor::SimpleType defines a class data accessor called "XmlSchemaType()" with the help of Class::Data::Inheritable. This accessor is normally used by many other methods to access the W3C schema meta information related to the class at hand. But at this stage, "XmlSchemaType()" does not contain any information.

The generated subclasses set "XmlSchemaType()" to information specific to the W3C schema type. It is then used for the XML binding and validation methods.

METHODS

CONSTRUCTORS

new()

  $class->new(%fields)

CONSTRUCTOR.

The new() constructor method instantiates a new XML::Pastor::Type object. It is inheritable, and indeed inherited, by the generated decsendant classes. Normally, you do not call the new method on XML::Pastor::Type. You rather call it on your generated subclasses.

Any -named- fields that are passed as parameters are initialized to those values within the newly created object.

.

CLASS DATA ACCESSORS

XmlSchemaType()

  my $type = $class->XmlSchemaType()

CLASS METHOD, but may also be called directly on an OBJECT.

XML::Pastor::Type defines (thanks to Class::Data::Inheritable) a class data acessor XmlSchemaType which returns undef.

This data accessor is set by each generated simple class to the meta information coming from your W3C Schema. This data is of class XML::Pastor::Schema::ComplexType or XML::Pastor::Schema::SimpleType.

You don't really need to know much about XmlSchemaType. It's used internally by Pastor's XML binding and validation methods as meta information about the generated class.

OTHER METHODS

is_xml_valid()

  $bool = $object->is_xml_valid();

OBJECT METHOD.

'is_xml_valid' is similar to "xml_validate" except that it will not die on failure. Instead, it will just return FALSE (0).

The implementation of this method is very simple. Currently, it just calls "xml_validate" in an eval block and will return FALSE (0) if "xml_validate" dies. Otherwise, it will just return the same value as "xml_validate".

In case of failure, the contents of the special variable $@ will be left untouched in case you would like to access the error message that resulted from the death of "xml_validate".

.

xml_validate()

        $object->xml_validate();        # Will die on failure

OBJECT METHOD.

When overriden by the descendants, 'xml_validate' validates a Pastor XML object (of a generated class) with respect to the META information that had originally be extracted from your original W3C XSD Schema.

On sucess, xml_validate returns TRUE (1). On failure, it will die on you on validation errors.

At this stage, xml_validate simply returns the vaue returned by "xml_validate_further" which should perform extra checks. For XML::Pastor::Type this always returns TRUE, but some builtin types actually perform some extra validation during this call.

xml_validate is normally overriden by descendant classes suchs as XML::Pastor::SimpleType and XML::Pastor::ComplexType.

xml_validate_further()

        $object->xml_validate_further();        # Never called directly.

OBJECT METHOD.

'xml_validate_further' should perform extra validation on a Pastor XML object (of a generated class).

It is called by "xml_validate" after performing rutine validations.

This method should return TRUE(1) on success, and die on failure with an error message.

For XML::Pastor::Type, this method simple returns TRUE(1).

This method may be, and is indeed, overriden by subclasses. Several builtin classes like like XML::Pastor::Builtin::date and XML::Pastor::Builtin::dateTime override this method.

BUGS & CAVEATS

There no known bugs at this time, but this doesn't mean there are aren't any. Note that, although some testing was done prior to releasing the module, this should still be considered alpha code. So use it at your own risk.

Note that there may be other bugs or limitations that the author is not aware of.

AUTHOR

Ayhan Ulusoy <dev@ulusoy.name>

COPYRIGHT

  Copyright (C) 2006-2007 Ayhan Ulusoy. 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::Pastor, XML::Pastor::ComplexType, XML::Pastor::SimpleType

If you are curious about the implementation, see XML::Pastor::Schema::Parser, XML::Pastor::Schema::Model, XML::Pastor::Generator.

If you really want to dig in, see XML::Pastor::Schema::Attribute, XML::Pastor::Schema::AttributeGroup, XML::Pastor::Schema::ComplexType, XML::Pastor::Schema::Element, XML::Pastor::Schema::Group, XML::Pastor::Schema::List, XML::Pastor::Schema::SimpleType, XML::Pastor::Schema::Type, XML::Pastor::Schema::Object