DublinCore::Element - Class for representing a Dublin Core element


DublinCore-Record documentation Contained in the DublinCore-Record distribution.

Index


Code Index:

NAME

Top

DublinCore::Element - Class for representing a Dublin Core element

SYNOPSIS

Top

    my $element = DublinCore::Element->new( \%info );
    print "content:   ", $element->content(), "\n";
    print "qualifier: ", $element->qualifier(), "\n";
    print "language:  ", $element->language(), "\n";
    print "scheme:    ", $element->scheme(), "\n";

DESCRIPTION

Top

DublinCore::Record methods such as element(), elements(), title(), etc return DublinCore::Element objects as their result. These can be queried further to extract an elements content, qualifier, language, and schema. For a definition of these attributes please see RFC 2731 and http://www.dublincore.org.

METHODS

Top

new()

The constructor. Take a hashref of input arguments.

content()

Gets and sets the content of the element.

    ## extract the element
    my $title = $record->element( 'title' );
    print $title->content();

    ## or you can chain them together
    print $record->element( 'title' )->content();

qualifier()

Gets and sets the qualifier used by the element.

language()

Gets and sets the language of the content in element.

scheme()

Gets and sets the scheme used by the element.

name()

Gets and sets the element name (title, creator, date, etc).

is_empty()

Gets and sets the "empty" status of an element. This is useful when using DublinCore::Record's element() method.

To see if the record has an creator elements:

    if( $record->element( 'creator' )->is_empty ) {
        # no creators
    }




set()

This function overrides the default set() behavior in order to remove the is_empty flag.

SEE ALSO

Top

* DublinCore::Record

AUTHOR

Top

* Ed Summers <ehs@pobox.com>
* Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE

Top


DublinCore-Record documentation Contained in the DublinCore-Record distribution.
package DublinCore::Element;

use base qw( Class::Accessor );

use strict;
use warnings;

our $VERSION = '0.03';

__PACKAGE__->mk_accessors( qw( name qualifier content language scheme is_empty ) );

sub new {
    my $class = shift;
    my $self  = $class->SUPER::new( @_ );

    bless $self, $class;

    $self->is_empty( 1 );

    return $self;
}

sub set {
    my $self = shift;
    $self->SUPER::set( 'is_empty' => 0 ) if $self->is_empty;
    $self->SUPER::set( @_ );
}

1;