NAME

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.

DESCRIPTION

XML::Pastor::Schema::Object is an abstract ancestor of all XML::Pastor schema object classes. Schema object classes are those that are the construction blocks of a schema model (see XML::Pastor::Schema::Model). They also constitute the objects that contain the meta information about a W3C schema that are embedded as class data within the generated Perl classes by XML::Pastor.

This accessor is originally created by a call to mk_accessors from Class::Accessor. However, it is further overridden in the source code in order to take into consideration the definition of the object. The SET functionality works as usual, but the GET functionality works as follows: If a value is NOT already defined for this field, but if there is a definition of this object, then the value of the same field is returned from the definition of the object. (See "definition()").

definition()

This field corresponds to the perl reference (ref) to a resolved W3C reference to a global object. It is normally used for elements and attributes. This way, the local element definition is preserved while having a pointer to the actual global definition.

key()

my $key = $object->key(); # GET
$object->key($key); # SET

Returns the hash key that is to be use to hash this object within the model. This is used by the add() method of the schema model (see "add()" in XML::Pastor::Schema::Model). If no key has been previously set, it returns the name of the object.

This accessor is coded manually.

id()

my $id = $object->id(); # GET
$object->id($id); # SET

This is a W3C property.

A schema object can have an ID within the W3C schema. Currently, this property is not used by XML::Pastor.

When processing a schema within a 'redefine' block, all schema objects (including types and elements) are marked as redefinable. This way, any subsequent redefinition in the model does not cause an error.

name()

my $name = $object->name(); # GET
$object->name($name); # SET

This is a W3C property.

This field is the name of the schema object as defined within the W3C schema or as attributed by the parser. Normally, all global objects (type, element, group, attribute, attributeGroup) will have a named defined in the W3C schema. However, non-global objects (such as local elements) will not have a name that comes from the W3C schema. Such objects will be named by the parser.

nameIsAutoGenerated()

Normally, all global objects (type, element, group, attribute, attributeGroup) will have a named defined in the W3C schema. However, non-global objects (such as local elements) will not have a name that comes from the W3C schema. Such objects will be named by the parser. In this case (when the name is generated automatically), this field will be set to TRUE(1) by the parser on the corresponding sceham object.

ref()

my $ref = $object->ref(); # GET
$object->ref($ref); # SET

This is a W3C property.

Sometimes in a W3C schema, a local object (such as an element) makes a reference to a global object (such as a global element). In this case, the 'ref' field will contain the name of the referenced global object.

The value of this field comes directly from the W3C schema, and is put into this field by the schema parser.

type()

my $type = $object->type(); # GET
$object->type($type); # SET

This is a W3C property.

Sometimes in a W3C schema, an object (such as an attribute or an element) will refer to a type that is defined globally in the schema set. The value of this field comes directly from the W3C schema, and is put into this field by the schema parser.

This accessor is originally created by a call to mk_accessors from Class::Accessor. However, it is further overridden in the source code in order to take into consideration the definition of the object. The SET functionality works as usual, but the GET functionality works as follows: If a value is NOT already defined for this field, but if there is a definition of this object, then the value of the same field is returned from the definition of the object. (See "definition()").

OTHER METHODS

setFields()

$object->setFields(%fields);

OBJECT METHOD.

This method is used to set multiple fields of a schema object all at once. From an interface point of view, it is like the new() method, but instead of constructing a new object, it works on an existing object.

Example :

$object->setFields(
name=> country,
scope=>global
);

This is used heavily by the parser in order to set multiple fields that are obtained by parsing attributes from the schema nodes.

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(at)ulusoy(dot)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.

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.