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