The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


WebService::GData::Node::AbstractEntity - Abstract proxy class representing several xml nodes.


   #your package should inherit from AbstractEntity.

   package WebService::GData::Node::AuthorEntity;
   use base 'WebService::GData::Node::AbstractEntity';
   use WebService::GData::Node::Author();
   use WebService::GData::Node::Uri();
   use WebService::GData::Node::Name();

   our $VERSION = 0.01_01;

   sub __init {
            my ($this,$params) = @_;
        #the entity is the root node used
            $this->_entity(new WebService::GData::Node::Author());
            #and its children:
            $this->{_name}   = new WebService::GData::Node::Name($params->{name});
            $this->{_uri}    = new WebService::GData::Node::Uri ($params->{uri});

    my $author   = new WebService::GData::Node::AuthorEntity();
       $author->name('john doe');


inherits from WebService::GData

This package is an abstract class used as a proxy to represent several nodes in one entity. A node containing text node and attributes will require to access the data in such a manner:

   my $name   = new WebService::GData::Node::Name(text=>'john doe');

If it does make sense at the node level and in an xml context, it does sound a bit unnatural when using nodes with children:

            my $author = new WebService::GData::Node::Author();
            my $name   = new WebService::GData::Node::Name(text=>'john doe');
            $author->name->text;#john doe

In an xml context, attributes vs text node do make sense but less in a object oriented context that abstract the underlying xml structure:

            my $author = new WebService::GData::Node::AuthorEntity(name=>'john doe');
               $author->name;#john doe

This class serves as a proxy to redispatch the call for name to name->text or an attribute and therefore limit the xml node/object entity mismatch. It is obviously a helper factory in combining multiple common nodes together in one entity. This class should be inherited to offer a concrete entity representation. The main container node should be store via the _entity method. All other children should be stored in the instance by prefixing the tag name with an underscore. All access to attributes or text node representation will be redispatched via __set and __get methods by following the above convention.

See also WebService::GData::Node.


Below is a list of implemented entities.

    AuthorEntity                #map author > name,uri
    PointEntity                 #map georss:where > gml:Point > gml:pos 
    Media::GroupEntity          #map all the nodes used in the media:group tag 


  • Complex hierarchical node representation can be hard to implement.

  • Node using both text node and attributes can not be mapped properly. Providing an alias that makes more sense than text is the only available solution.

  • Does it really solves the/any problem?


If you do me the favor to _use_ this module and find a bug, please email me i will try to do my best to fix it (patches welcome)!


shiriru <shirirulestheworld[arobas]>


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