| 1 |
NAME |
| 2 |
DublinCore::Record - Container for Dublin Core metadata elements |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use DublinCore::Record; |
| 6 |
|
| 7 |
my $record = DublinCore::Record->new(); |
| 8 |
|
| 9 |
# later ... |
| 10 |
|
| 11 |
# print the title |
| 12 |
print $record->element( 'title' )->content; |
| 13 |
|
| 14 |
## list context will retrieve all of a particular element |
| 15 |
foreach my $element ( $record->element( 'Creator' ) ) { |
| 16 |
print "creator: ", $element->content(), "\n"; |
| 17 |
} |
| 18 |
|
| 19 |
## qualified dublin core |
| 20 |
my $creation = $record->element( 'Date.created' )->content(); |
| 21 |
|
| 22 |
DESCRIPTION |
| 23 |
DublinCore::Record is an abstract class for manipulating DublinCore |
| 24 |
metadata. The Dublin Core is a small set of metadata elements for |
| 25 |
describing information resources. For more information on embedding |
| 26 |
DublinCore in HTML see RFC 2731 <http://www.ietf.org/rfc/rfc2731> or |
| 27 |
<http://www.dublincore.org/documents/dces/> |
| 28 |
|
| 29 |
METHODS |
| 30 |
new() |
| 31 |
The constructor. Takes no arguments. |
| 32 |
|
| 33 |
$record = DublinCore::Record->new(); |
| 34 |
|
| 35 |
add( @elements ) |
| 36 |
Adds valid DublinCore::Element objects to the record. |
| 37 |
|
| 38 |
remove( @elements ) |
| 39 |
Removes valid DublinCore::Element object from the record. |
| 40 |
|
| 41 |
element() |
| 42 |
This method will return a relevant DublinCore::Element object. When |
| 43 |
called in a scalar context element() will return the first relevant |
| 44 |
element found, and when called in a list context it will return all the |
| 45 |
relevant elements (since Dublin Core elements are repeatable). |
| 46 |
|
| 47 |
## retrieve first title element |
| 48 |
my $element = $record->element( 'Title' ); |
| 49 |
my $title = $element->content(); |
| 50 |
|
| 51 |
## shorthand object chaining to extract element content |
| 52 |
my $title = $record->element( 'Title' )->content(); |
| 53 |
|
| 54 |
## retrieve all creator elements |
| 55 |
@creators = $record->element( 'Creator' ); |
| 56 |
|
| 57 |
You can also retrieve qualified elements in a similar fashion. |
| 58 |
|
| 59 |
my $date = $record->element( 'Date.created' )->content(); |
| 60 |
|
| 61 |
In order to fascilitate chaining element() will return an empty |
| 62 |
DublinCore::Element object when the requested element does not exist. |
| 63 |
You can check if you're getting an empty empty back by using the |
| 64 |
is_empty() method. |
| 65 |
|
| 66 |
if( $record->element( 'title' )->is_empty ) { |
| 67 |
# no title |
| 68 |
} |
| 69 |
|
| 70 |
elements() |
| 71 |
Returns all the Dublin Core elements found as DublinCore::Element |
| 72 |
objects which you can then manipulate further. |
| 73 |
|
| 74 |
foreach my $element ( $record->elements() ) { |
| 75 |
print "name=", $element->name(), "\n"; |
| 76 |
print "content=", $element->content(), "\n"; |
| 77 |
} |
| 78 |
|
| 79 |
title() |
| 80 |
Returns a DublinCore::Element object for the title element. You can then |
| 81 |
retrieve content, qualifier, scheme, lang attributes like so. |
| 82 |
|
| 83 |
my $title = $record->title(); |
| 84 |
print "content: ", $title->content(), "\n"; |
| 85 |
print "qualifier: ", $title->qualifier(), "\n"; |
| 86 |
print "scheme: ", $title->scheme(), "\n"; |
| 87 |
print "language: ", $title->language(), "\n"; |
| 88 |
|
| 89 |
Since there can be multiple instances of a particular element type |
| 90 |
(title, creator, subject, etc) you can retrieve multiple title elements |
| 91 |
by calling title() in a list context. |
| 92 |
|
| 93 |
my @titles = $record->title(); |
| 94 |
foreach my $title ( @titles ) { |
| 95 |
print "title: ", $title->content(), "\n"; |
| 96 |
} |
| 97 |
|
| 98 |
creator() |
| 99 |
Retrieve creator information in the same manner as title(). |
| 100 |
|
| 101 |
subject() |
| 102 |
Retrieve subject information in the same manner as title(). |
| 103 |
|
| 104 |
description() |
| 105 |
Retrieve description information in the same manner as title(). |
| 106 |
|
| 107 |
publisher() |
| 108 |
Retrieve publisher information in the same manner as title(). |
| 109 |
|
| 110 |
contributor() |
| 111 |
Retrieve contributor information in the same manner as title(). |
| 112 |
|
| 113 |
date() |
| 114 |
Retrieve date information in the same manner as title(). |
| 115 |
|
| 116 |
type() |
| 117 |
Retrieve type information in the same manner as title(). |
| 118 |
|
| 119 |
format() |
| 120 |
Retrieve format information in the same manner as title(). |
| 121 |
|
| 122 |
identifier() |
| 123 |
Retrieve identifier information in the same manner as title(). |
| 124 |
|
| 125 |
source() |
| 126 |
Retrieve source information in the same manner as title(). |
| 127 |
|
| 128 |
language() |
| 129 |
Retrieve language information in the same manner as title(). |
| 130 |
|
| 131 |
relation() |
| 132 |
Retrieve relation information in the same manner as title(). |
| 133 |
|
| 134 |
coverage() |
| 135 |
Retrieve coverage information in the same manner as title(). |
| 136 |
|
| 137 |
rights() |
| 138 |
Retrieve rights information in the same manner as title(). |
| 139 |
|
| 140 |
SEE ALSO |
| 141 |
* DublinCore::Element |
| 142 |
* Dublin Core <http://www.dublincore.org/> |
| 143 |
* RFC 2731 <http://www.ietf.org/rfc/rfc2731> |
| 144 |
* perl4lib <http://www.rice.edu/perl4lib> |
| 145 |
|
| 146 |
AUTHOR |
| 147 |
* Ed Summers <[email protected]> |
| 148 |
* Brian Cassidy <[email protected]> |
| 149 |
|
| 150 |
COPYRIGHT AND LICENSE |
| 151 |
Copyright 2007 by Ed Summers, Brian Cassidy |
| 152 |
|
| 153 |
This library is free software; you can redistribute it and/or modify it |
| 154 |
under the same terms as Perl itself. |
| 155 |
|