MODS-Record-0.13 000755 000765 000024 0 13375542142 13520 5 ustar 00hochsten staff 000000 000000 README 100644 000765 000024 16074 13375542142 14511 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 NAME
MODS::Record - Perl extension for handling MODS records
SYNOPSIS
use MODS::Record qw(xml_string);
use open qw(:utf8);
my $mods = MODS::Record->new;
my $collection = MODS::Collection->new;
my $mods = $collection->add_mods(ID => '1234');
$mods->add_abstract("Hello", lang => 'eng');
$mods->add_abstract("Bonjour", lang => 'fra');
# Set a deeply nested field...
$mods->add_language()->add_languageTerm('eng');
# Set a list of deeply nested fields...
$mods->add_location(sub {
$_[0]->add_physicalLocation('here');
$_[0]->add_shelfLocator('here too');
$_[0]->add_url('http://here.org/there');
});
# Set an inline XML extension...
$mods->add_accessCondition(xml_string("21212"));
# Retrieve a field by a filter...
$mods->get_abstract(lang => 'fra')->body("Bonjour :)");
$mods->get_abstract(lang => 'fra')->contentType('text/plain');
for ($mods->get_abstract(lang => 'fra')) {
printf "%s\n" , $_->body;
}
# Set a field to a new value
my @newabstract;
for ($mods->get_abstract) {
push @newabstract, $_ unless $_->lang eq 'fra';
}
$mods->set_abstract(@newabstract);
# Clear all abstracts;
$mods->set_abstract(undef);
# Serialize
print $mods->as_json(pretty => 1);
print $mods->as_xml;
# Deserialize
my $mods = MODS::Record->from_xml(IO::File->new('mods.xml'));
my $mods = MODS::Record->from_json(IO::File->new('mods.js'));
my $count = MODS::Record->from_xml(IO::File->new('mods.xml'), sub {
my $mods = shift;
...
});
my $count = MODS::Record->from_json(IO::File->new('mods.js'), sub {
my $mods = shift;
...
});
DESCRIPTION
This module provides MODS (http://www.loc.gov/standards/mods/) parsing
and creation for MODS Schema 3.5.
METHODS
MODS::Record->new(%attribs)
MODS::Collection->new(%attribs)
Create a new MODS record or collection. Optionally attributes can be
provided as defined by the MODS specification. E.g.
$mods = MODS::Record->new(ID='123');
add_xxx()
Add a new element to the record where 'xxx' is the name of a MODS
element (e.g. titleInfo, name, genre, etc). This method returns an
instance of the added MODS element. E.g.
$titleInfo = $mods->add_titleInfo; # $titleInfo is a 'MODS::Element::TitleInfo'
add_xxx($text,%attribs)
Add a new element to the record where 'xxx' is the name of a MODS
element. Set the text content of the element to $text and optionally
provide further attributes. This method returns an instance of the
added MODS element. E.g.
$mods->add_abstract("My abstract", lang=>'eng');
add_xxx(sub { })
Add a new element to the record where 'xxx' is the name of a MODS
element. The provided coderef gets as input an instance of the added
MODS element. This method returns an instance of the added MODS
element. E.g.
$mods->add_abstract(sub {
my $o = shift;
$o->body("My abstract");
$o->lang("eng");
})
add_xxx($obj)
Add a new element to the record where 'xxx' is the name of a MODS
element. The $obj is an instance of a MODS::Element::Xxx class (where
Xxx is the corresponding MODS element). This method returns an instance
of the added MODS element. E.g.
$mods->add_abstract(
MODS::Element::Abstract->new(_body=>'My abstract', lang=>'eng')
);
get_xxx()
get_xxx(%filter)
get_xxx(sub { })
Retrieve an element from the record where 'xxx' is the name of a MODS
element. This methods return in array context all the matching elements
or the first match in scalar context. Optionally provide a %filter or a
coderef filter function. E.g.
@titles = $mods->get_titleInfo();
$alt = $mods->get_titleInfo(type=>'alternate');
$alt = $mods->get_titleInfo(sub { shift->type eq 'alternate'});
set_xxxx()
set_xxx(undef)
set_xxx($array_ref)
set_xxx($xxx1,$xxx2,...)
Set an element of the record to a new value where 'xxx' is the name of
a MODS element. When no arguments are provided, then this is a null
operation. When undef als argument is provided, then the element is
deleted. To overwrite the existing content of the element an ARRAY
(ref) of MODS::Element::Xxx can be provided (where 'Xxx' is the
corresponding MODS element). E.g.
# Delete all abstracts
$mods->set_abstract(undef);
# Set all abstracts
$mods->set_abstract(MODS::Element::Abstract->new(), MODS::Element::Abstract->new(), ...);
$mods->set_abstract([ MODS::Element::Abstract->new(), MODS::Element::Abstract->new(), ... ]);
as_xml()
as_xml(xml_prolog=>1)
Return the record as XML.
from_xml($string [, $callback])
from_xml(IO::Handle [, $callback])
Parse an XML string or IO::Handle into a MODS::Record. This method
return the parsed JSON.
If a callback function is provided then for each MODS element in the
XML stream the callback will be called. The method returns the number
of parsed MODS elements.
E.g.
my $mods = MODS::Record->from_xml( IO::File->new(...) );
my $count = MODS::Record->from_xml( IO::File->new(...) , sub {
my $mods = shift;
} );
as_json()
as_json(pretty=>1)
Return the record as JSON string.
from_json($string [, $callback])
from_json(IO::Handle [, $callback])
Parse and JSON string or JSON::Handle into a MODS::Record. This method
return the parsed JSON.
If a callback function is provided then we expect as input a stream of
JSON strings (each line one JSON string). For each MODS object in the
JSON stream the callback will be called. The method returns the number
of parsed strings.
E.g.
my $mods = MODS::Record->from_json( IO::File->new(...) );
my $count = MODS::Record->from_json( IO::File->new(...) , sub {
my $mods = shift;
} );
SEE ALSO
* Library Of Congress MODS pages (http://www.loc.gov/standards/mods/)
DESIGN NOTES
* I'm not a MODS expert
* I needed a MODS module to parse and create MODS records for our
institutional repository
* This module is part of the LibreCat/Catmandu project
http://librecat.org
* This module is not created for speed
* This module doesn't have any notion of ordering of MODS elements
themselves (e.g. first 'titleInfo', then 'name'). But each
sub-element keeps its original order (e.g. each 'title' in
'titleInfo').
* Heiko Jansen provides at GitHub a Moose-based MODS parser
https://github.com/heikojansen/MODS--Record
AUTHOR
Patrick Hochstenbach
LICENSE AND COPYRIGHT
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Changes 100644 000765 000024 1752 13375542142 15101 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 Revision history for perl module MODS::Record
0.13 2018-11-22 15:59:34 CET
- Fixing name element has missing type attribute #4
- Fixing empty MODS::Element::Affiliation #5
- Fixing license
0.11 2015-09-23 09:23:57 CEST
- Fixing UTF8 bug in JSON export
0.10 2015-09-22 15:46:42 CEST
- Adding missing Affiliation tag
0.09 2015-04-01 13:18:23 CEST
- Downgrading cpanfile
0.08 2015-03-02
- Changed shelfLocation to shelfLocator
- Migrating to Dist::Milla
- Bumping version +
0.07 2013-08-08
- Changed 'defined-or' operators to 'or' operators to suport perl 5.8.X
0.06 2013-08-06
- Fixing UTF-8 handling of JSON
0.05 2013-08-05
- Adding Changes file
- Adding support for callback function in from_xml, from_json
0.04 2013-08-04
- Fixing test scripts based on CPAN feedback
0.03 2013-08-03
- Switching to Build.PL Scripts
- Fixing documentation
0.02 2013-08-03
- Adding a LICENSE
0.01 2013-08-02
- First release to CPAN
LICENSE 100644 000765 000024 43705 13375542142 14637 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 This software is copyright (c) 2018 by Patrick Hochstenbach.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2018 by Patrick Hochstenbach.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2018 by Patrick Hochstenbach.
This is free software, licensed under:
The Artistic License 1.0
The Artistic License
Preamble
The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.
Definitions:
- "Package" refers to the collection of files distributed by the Copyright
Holder, and derivatives of that collection of files created through
textual modification.
- "Standard Version" refers to such a Package if it has not been modified,
or has been modified in accordance with the wishes of the Copyright
Holder.
- "Copyright Holder" is whoever is named in the copyright or copyrights for
the package.
- "You" is you, if you're thinking about copying or distributing this Package.
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or an
equivalent medium, or placing the modifications on a major archive site
such as ftp.uu.net, or by allowing the Copyright Holder to include your
modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict with
standard executables, which must also be provided, and provide a separate
manual page for each non-standard executable that clearly documents how it
differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.
b) accompany the distribution with the machine-readable source of the Package
with your modifications.
c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
cpanfile 100644 000765 000024 461 13375542142 15266 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 requires 'perl', 'v5.10.1';
on 'test', sub {
requires 'Test::Deep', '0.110';
requires 'Test::Exception', '0.31';
requires 'Test::More', 0;
requires 'Test::Pod', '0.06';
};
requires 'Carp', 0;
requires 'IO', 0;
requires 'JSON', '2.53';
requires 'Moo', '0.091011';
requires 'XML::Parser', '2.44';
Build.PL 100644 000765 000024 260 13375542142 15053 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 # This Build.PL for MODS-Record was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.015.
use strict;
use warnings;
use v5.10.1;
use Module::Build::Tiny 0.034;
Build_PL();
META.yml 100644 000765 000024 2025 13375542142 15051 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 ---
abstract: 'Perl extension for handling MODS records'
author:
- 'Patrick Hochstenbach '
build_requires:
Test::Deep: '0.110'
Test::Exception: '0.31'
Test::More: '0'
Test::Pod: '0.06'
configure_requires:
Module::Build::Tiny: '0.034'
dynamic_config: 0
generated_by: 'Dist::Milla version v1.0.17, Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: MODS-Record
no_index:
directory:
- eg
- examples
- inc
- share
- t
- xt
requires:
Carp: '0'
IO: '0'
JSON: '2.53'
Moo: '0.091011'
XML::Parser: '2.44'
perl: v5.10.1
resources:
bugtracker: https://github.com/LibreCat/MODS-Record/issues
homepage: https://github.com/LibreCat/MODS-Record
repository: https://github.com/LibreCat/MODS-Record.git
version: '0.13'
x_contributors:
- 'Patrick Hochstenbach '
x_serialization_backend: 'YAML::Tiny version 1.69'
MANIFEST 100644 000765 000024 421 13375542142 14707 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008.
Build.PL
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.json
META.yml
README
cpanfile
lib/MODS/Record.pm
t/00_load.t
t/01_mods.t
t/author-pod-syntax.t
t/mods.json
t/mods.xml
t/mods_multiple.json
META.json 100644 000765 000024 3564 13375542142 15232 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 {
"abstract" : "Perl extension for handling MODS records",
"author" : [
"Patrick Hochstenbach "
],
"dynamic_config" : 0,
"generated_by" : "Dist::Milla version v1.0.17, Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "MODS-Record",
"no_index" : {
"directory" : [
"eg",
"examples",
"inc",
"share",
"t",
"xt"
]
},
"prereqs" : {
"configure" : {
"requires" : {
"Module::Build::Tiny" : "0.034"
}
},
"develop" : {
"requires" : {
"Dist::Milla" : "v1.0.17",
"Test::Pod" : "1.41"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"IO" : "0",
"JSON" : "2.53",
"Moo" : "0.091011",
"XML::Parser" : "2.44",
"perl" : "v5.10.1"
}
},
"test" : {
"requires" : {
"Test::Deep" : "0.110",
"Test::Exception" : "0.31",
"Test::More" : "0",
"Test::Pod" : "0.06"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/LibreCat/MODS-Record/issues"
},
"homepage" : "https://github.com/LibreCat/MODS-Record",
"repository" : {
"type" : "git",
"url" : "https://github.com/LibreCat/MODS-Record.git",
"web" : "https://github.com/LibreCat/MODS-Record"
}
},
"version" : "0.13",
"x_contributors" : [
"Patrick Hochstenbach "
],
"x_serialization_backend" : "Cpanel::JSON::XS version 3.0225"
}
t 000755 000765 000024 0 13375542142 13704 5 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 mods.xml 100644 000765 000024 7700 13375542142 15534 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t
Telescope Peak from Zabriskie Point
Telescope PK from Zabriskie Pt.
Cushman
Charles Weever
1896-1972
pht
Photographer
ug_TW14
still image
Landscape photographs
1955-03-22
2003
image/jpeg
reformatted digital
Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available.
100 f 6.3 tl
Mountains
Snow
Telescope Peak (Inyo County, Calif.)
Zabriskie Point (Calif.)
United States
California
Inyo
1955-03-22
1 slide : col. ; 35mm
Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available.
Indiana University, Bloomington. University Archives P07803
381 J8223
Indiana University Digital Library Program: Charles W. Cushman Photograph Collection
955.11
P07803
http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803
http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png
Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405
Indiana University Digital Library Program
2004-09-09
archives/cushman/P07803
00_load.t 100644 000765 000024 223 13375542142 15424 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t #!perl -Tw
use strict;
use Test::More tests=>1;
BEGIN {
use_ok( 'MODS::Record' );
}
diag( "Testing MODS::Record $MODS::Record::VERSION" );
01_mods.t 100644 000765 000024 11771 13375542142 15522 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t #!perl -w
use strict;
use Test::More tests=>68;
use MODS::Record qw(xml_string);
use IO::File;
use open qw(:utf8);
use utf8;
my $mods;
ok($mods = MODS::Record->new,"new");
is($mods->version,"3.5","version");
ok($mods->version("3.3"),"set version");
is($mods->version,"3.3","version");
my $abstract;
ok($abstract = $mods->add_abstract("test123",lang=>'eng',contentType=>'text/plain'),"set abstract");
is($abstract,"test123","test abstract body");
is($abstract->lang,"eng","test abstract lang");
is($abstract->contentType,"text/plain","test abstract contentType");
ok($abstract = $mods->add_abstract(MODS::Element::Abstract->new(_body=>'test123',lang=>'eng',contentType=>'text/plain')),"set abstract");
is($abstract,"test123","test abstract body");
is($abstract->lang,"eng","test abstract lang");
is($abstract->contentType,"text/plain","test abstract contentType");
ok($abstract = $mods->add_abstract(sub { my $o = shift; $o->body('test123'); $o->lang('eng'); $o->contentType('text/plain')}),"set abstract");
is($abstract,"test123","test abstract body");
is($abstract->lang,"eng","test abstract lang");
is($abstract->contentType,"text/plain","test abstract contentType");
$abstract = $mods->add_abstract();
ok($abstract->body('test123'));
ok($abstract->lang('eng'));
ok($abstract->contentType('text/plain'));
is($abstract,"test123","test abstract body");
is($abstract->lang,"eng","test abstract lang");
is($abstract->contentType,"text/plain","test abstract contentType");
my @abstract;
ok(@abstract = $mods->get_abstract,"get abstract");
is(@abstract,4,"count abstract");
ok($abstract = $mods->abstract([MODS::Element::Abstract->new(_body=>'test123',lang=>'eng',contentType=>'text/plain')]),"set abstract");
is($abstract->[0],"test123","test abstract body");
is($abstract->[0]->lang,"eng","test abstract lang");
is($abstract->[0]->contentType,"text/plain","test abstract contentType");
ok(@abstract = $mods->get_abstract,"get abstract");
is(@abstract,1,"count abstract");
is($mods->get_abstract(lang=>'eng'),"test123","get one abstract");
is($mods->get_abstract(sub { shift->lang eq 'eng'}),"test123","get one abstract");
my $access;
ok($access = $mods->add_accessCondition('test'),"set string accessCondition");
is($access,'test');
ok($access = $mods->add_accessCondition(xml_string('')),"set XML accessCondition");
is($access,'');
my $name = $mods->add_name(type => 'test');
ok ($name->type,'test');
ok ($mods->get_name(type => 'test'));
ok (!$mods->get_name(type => 'best'));
my @access;
ok(@access = $mods->get_accessCondition,"get accessCondition");
is(@access,2,"count accessCondition");
is(@access = $mods->set_accessCondition(),2,"set accessCondition");
is(@access = $mods->set_accessCondition(undef),0,"set accessCondition");
is(@access = $mods->set_accessCondition(MODS::Element::AccessCondition->new(_body=>'test')),1,"set accessCondition");
is(@access = $mods->set_accessCondition([MODS::Element::AccessCondition->new(_body=>'test')]),1,"set accessCondition");
my $collection;
ok($collection = MODS::Record->from_xml(IO::File->new("t/mods.xml")),"from_xml");
is($collection->get_mods->get_titleInfo->get_title,"Telescope Peak from Zabriskie Point","titleInfo/title");
is($collection->get_mods->get_titleInfo(type=>'alternative')->get_title,"Telescope PK from Zabriskie Pt.","titleInfo[type=\"alternative\"]/title");
is($collection->get_mods->get_relatedItem(type=>'original')->get_location->get_shelfLocator,"381 J8223","relatedItem[type=\"original\"]/location/shelfLocator");
is($collection->get_mods->get_name->get_affiliation,"ug_TW14");
ok($collection = MODS::Record->from_json(IO::File->new("t/mods.json")),"from_json");
is($collection->get_mods->get_titleInfo->get_title,"Telescope Peak from Zabriskie Point","titleInfo/title");
is($collection->get_mods->get_titleInfo(type=>'alternative')->get_title,"Telescope PK from Zabriskie Pt.","titleInfo[type=\"alternative\"]/title");
my $xml;
ok($xml = $collection->as_xml,"as_xml");
ok($xml =~ /^as_json,"as_json");
ok($json = $collection->get_mods->as_json,"as_json (element)");
ok($json = $collection->get_mods->get_titleInfo->as_json,"as_json (element)");
my $obj;
is(MODS::Record->from_json(IO::File->new("t/mods_multiple.json"),sub { $obj = shift }),2,"from_json (callback)");
is($obj->get_titleInfo->get_title,"Telescope Peak from Zabriskie Point","titleInfo/title");
is(MODS::Record->from_xml(IO::File->new("t/mods.xml"), sub { $obj = shift}),1,"from_xml (callback");
is($obj->get_titleInfo->get_title,"Telescope Peak from Zabriskie Point","titleInfo/title");
$mods = MODS::Record->new;
$mods->add_abstract("中华人民共和国");
ok($json = $mods->as_json, "UTF-8 json");
ok($mods = MODS::Record->from_json($json),"UTF-8 parse");
is($mods->get_abstract,"中华人民共和国","read abstract");
$mods = MODS::Record->new;
$mods->add_abstract("中华人民共和国");
ok($xml = $mods->as_xml, "UTF-8 xml");
ok($xml = MODS::Record->from_xml($xml),"UTF-8 parse");
is($mods->get_abstract,"中华人民共和国","read abstract");
mods.json 100644 000765 000024 5615 13375542142 15710 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t {"modsCollection":{"mods":[{"accessCondition":[{"_body":" Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405"}],"physicalDescription":[{"internetMediaType":[{"_body":"image/jpeg"}],"digitalOrigin":[{"_body":"reformatted digital"}],"note":[{"_body":" Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."},{"_body":"100 f 6.3 tl"}]}],"identifier":[{"displayLabel":"Cushman number","type":"local","_body":"955.11"},{"displayLabel":"IU Archives number","type":"local","_body":"P07803"}],"typeOfResource":[{"_body":"still image"}],"location":[{"url":[{"_body":"http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803"},{"access":"preview","_body":"http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png"}]}],"version":"3.3","subject":[{"topic":[{"_body":"Mountains"}],"authority":"lctgm"},{"topic":[{"_body":"Snow"}],"authority":"lctgm"},{"topic":[{"_body":"Telescope Peak (Inyo County, Calif.)"}]},{"topic":[{"_body":"Zabriskie Point (Calif.)"}]},{"hierarchicalGeographic":[{"country":[{"_body":"United States"}],"state":[{"_body":"California"}],"county":[{"_body":"Inyo"}]}]}],"name":[{"namePart":[{"type":"family","_body":"Cushman"},{"type":"given","_body":"Charles Weever"},{"type":"date","_body":"1896-1972"}],"role":[{"roleTerm":[{"type":"code","_body":"pht","authority":"marcrelator"},{"type":"text","_body":"Photographer","authority":"marcrelator"}]}]}],"genre":[{"_body":"Landscape photographs","authority":"gmgpc"}],"recordInfo":[{"recordCreationDate":[{"_body":"2004-09-09","encoding":"w3cdtf"}],"recordContentSource":[{"_body":"Indiana University Digital Library Program"}],"recordIdentifier":[{"_body":"archives/cushman/P07803"}]}],"titleInfo":[{"title":[{"_body":"Telescope Peak from Zabriskie Point"}]},{"title":[{"_body":"Telescope PK from Zabriskie Pt."}],"type":"alternative"}],"relatedItem":[{"physicalDescription":[{"form":[{"_body":"graphic","authority":"gmd"}],"extent":[{"_body":"1 slide : col. ; 35mm"}],"note":[{"_body":"Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."}]}],"location":[{"physicalLocation":[{"displayLabel":"Original slide","_body":" Indiana University, Bloomington. University Archives P07803 "}]}],"type":"original","originInfo":[{"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]},{"titleInfo":[{"title":[{"_body":" Indiana University Digital Library Program: Charles W. Cushman Photograph Collection"}],"type":"uniform","authority":"dlfaqcoll"}],"type":"host"}],"originInfo":[{"copyrightDate":[{"_body":"2003","encoding":"w3cdtf"}],"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]}]}}
MANIFEST.SKIP 100644 000765 000024 11 13375542142 15427 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13 dist.ini
MODS 000755 000765 000024 0 13375542142 14751 5 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/lib Record.pm 100644 000765 000024 177366 13375542142 16751 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/lib/MODS package MODS::Record;
=head1 NAME
MODS::Record - Perl extension for handling MODS records
=head1 SYNOPSIS
use MODS::Record qw(xml_string);
use open qw(:utf8);
my $mods = MODS::Record->new;
my $collection = MODS::Collection->new;
my $mods = $collection->add_mods(ID => '1234');
$mods->add_abstract("Hello", lang => 'eng');
$mods->add_abstract("Bonjour", lang => 'fra');
# Set a deeply nested field...
$mods->add_language()->add_languageTerm('eng');
# Set a list of deeply nested fields...
$mods->add_location(sub {
$_[0]->add_physicalLocation('here');
$_[0]->add_shelfLocator('here too');
$_[0]->add_url('http://here.org/there');
});
# Set an inline XML extension...
$mods->add_accessCondition(xml_string("21212"));
# Retrieve a field by a filter...
$mods->get_abstract(lang => 'fra')->body("Bonjour :)");
$mods->get_abstract(lang => 'fra')->contentType('text/plain');
for ($mods->get_abstract(lang => 'fra')) {
printf "%s\n" , $_->body;
}
# Set a field to a new value
my @newabstract;
for ($mods->get_abstract) {
push @newabstract, $_ unless $_->lang eq 'fra';
}
$mods->set_abstract(@newabstract);
# Clear all abstracts;
$mods->set_abstract(undef);
# Serialize
print $mods->as_json(pretty => 1);
print $mods->as_xml;
# Deserialize
my $mods = MODS::Record->from_xml(IO::File->new('mods.xml'));
my $mods = MODS::Record->from_json(IO::File->new('mods.js'));
my $count = MODS::Record->from_xml(IO::File->new('mods.xml'), sub {
my $mods = shift;
...
});
my $count = MODS::Record->from_json(IO::File->new('mods.js'), sub {
my $mods = shift;
...
});
=head1 DESCRIPTION
This module provides MODS (http://www.loc.gov/standards/mods/) parsing and creation for MODS Schema 3.5.
=head1 METHODS
=head2 MODS::Record->new(%attribs)
=head2 MODS::Collection->new(%attribs)
Create a new MODS record or collection. Optionally attributes can be provided as
defined by the MODS specification. E.g.
$mods = MODS::Record->new(ID='123');
=head2 add_xxx()
Add a new element to the record where 'xxx' is the name of a MODS element (e.g. titleInfo, name, genre, etc).
This method returns an instance of the added MODS element. E.g.
$titleInfo = $mods->add_titleInfo; # $titleInfo is a 'MODS::Element::TitleInfo'
=head2 add_xxx($text,%attribs)
Add a new element to the record where 'xxx' is the name of a MODS element. Set the text content of the element to $text
and optionally provide further attributes. This method returns an instance of the added MODS element. E.g.
$mods->add_abstract("My abstract", lang=>'eng');
=head2 add_xxx(sub { })
Add a new element to the record where 'xxx' is the name of a MODS element. The provided coderef gets as input an instance
of the added MODS element. This method returns an instance of the added MODS element. E.g.
$mods->add_abstract(sub {
my $o = shift;
$o->body("My abstract");
$o->lang("eng");
})
=head2 add_xxx($obj)
Add a new element to the record where 'xxx' is the name of a MODS element. The $obj is an instance of a MODS::Element::Xxx
class (where Xxx is the corresponding MODS element). This method returns an instance of the added MODS element. E.g.
$mods->add_abstract(
MODS::Element::Abstract->new(_body=>'My abstract', lang=>'eng')
);
=head2 get_xxx()
=head2 get_xxx(%filter)
=head2 get_xxx(sub { })
Retrieve an element from the record where 'xxx' is the name of a MODS element. This methods return in array context all the
matching elements or the first match in scalar context. Optionally provide a %filter or a coderef filter function.
E.g.
@titles = $mods->get_titleInfo();
$alt = $mods->get_titleInfo(type=>'alternate');
$alt = $mods->get_titleInfo(sub { shift->type eq 'alternate'});
=head2 set_xxxx()
=head2 set_xxx(undef)
=head2 set_xxx($array_ref)
=head2 set_xxx($xxx1,$xxx2,...)
Set an element of the record to a new value where 'xxx' is the name of a MODS element. When no arguments are provided, then this
is a null operation. When undef als argument is provided, then the element is deleted. To overwrite the existing content of the
element an ARRAY (ref) of MODS::Element::Xxx can be provided (where 'Xxx' is the corresponding MODS element). E.g.
# Delete all abstracts
$mods->set_abstract(undef);
# Set all abstracts
$mods->set_abstract(MODS::Element::Abstract->new(), MODS::Element::Abstract->new(), ...);
$mods->set_abstract([ MODS::Element::Abstract->new(), MODS::Element::Abstract->new(), ... ]);
=head2 as_xml()
=head2 as_xml(xml_prolog=>1)
Return the record as XML.
=head2 from_xml($string [, $callback])
=head2 from_xml(IO::Handle [, $callback])
Parse an XML string or IO::Handle into a MODS::Record. This method return the parsed JSON.
If a callback function is provided then for each MODS element in the XML stream the callback will be called.
The method returns the number of parsed MODS elements.
E.g.
my $mods = MODS::Record->from_xml( IO::File->new(...) );
my $count = MODS::Record->from_xml( IO::File->new(...) , sub {
my $mods = shift;
} );
=head2 as_json()
=head2 as_json(pretty=>1)
Return the record as JSON string.
=head2 from_json($string [, $callback])
=head2 from_json(IO::Handle [, $callback])
Parse and JSON string or JSON::Handle into a MODS::Record. This method return the parsed JSON.
If a callback function is provided then we expect as input a stream of JSON strings
(each line one JSON string). For each MODS object in the JSON stream the callback will be called.
The method returns the number of parsed strings.
E.g.
my $mods = MODS::Record->from_json( IO::File->new(...) );
my $count = MODS::Record->from_json( IO::File->new(...) , sub {
my $mods = shift;
} );
=head1 SEE ALSO
=over 4
=item * Library Of Congress MODS pages (http://www.loc.gov/standards/mods/)
=back
=head1 DESIGN NOTES
=over 4
=item * I'm not a MODS expert
=item * I needed a MODS module to parse and create MODS records for our institutional repository
=item * This module is part of the LibreCat/Catmandu project http://librecat.org
=item * This module is not created for speed
=item * This module doesn't have any notion of ordering of MODS elements themselves (e.g. first 'titleInfo', then 'name').
But each sub-element keeps its original order (e.g. each 'title' in 'titleInfo').
=item * Heiko Jansen provides at GitHub a Moose-based MODS parser https://github.com/heikojansen/MODS--Record
=back
=head1 AUTHOR
Patrick Hochstenbach
=head1 LICENSE AND COPYRIGHT
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See L for more information.
=cut
use vars qw( $VERSION );
$VERSION = '0.13';
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(xml_string);
sub new {
my ($class,@opts) = @_;
return MODS::Element::Mods->new(@opts);
}
sub from_xml {
my ($self,@opts) = @_;
MODS::Parser->new->parse(@opts);
}
sub from_json {
my ($self,@opts) = @_;
MODS::Parser->new->parse_json(@opts);
}
sub xml_string {
my $string = shift;
return MODS::Record::Xml_String->new(_body => $string);
}
package MODS::Collection;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(xml_string);
sub new {
my ($class,@opts) = @_;
return MODS::Element::ModsCollection->new(@opts);
}
sub from_xml {
my ($self,@opts) = @_;
MODS::Parser->new->parse(@opts);
}
sub from_json {
my ($self,@opts) = @_;
MODS::Parser->new->parse_json(@opts);
}
sub xml_string {
my $string = shift;
return MODS::Record::Xml_String->new(_body => $string);
}
package MODS::Record::Util;
use Moo::Role;
use Carp;
use JSON;
sub AUTOLOAD {
my ($self,@args) = @_;
my ($meth) = (our $AUTOLOAD =~ /([^:]+)$/);
if ($meth =~ /^add_(\w+)/) {
my ($attrib) = $1;
die "no such method $attrib" unless $self->can($attrib);
return $self->_adder($attrib,@args);
}
elsif ($meth =~ /^get_(\w+)/) {
my ($attrib) = $1;
die "no such method $attrib" unless $self->can($attrib);
return $self->_getter($attrib,@args);
}
elsif ($meth =~ /^set_(\w+)/) {
my ($attrib) = $1;
die "no such method $attrib" unless $self->can($attrib);
return $self->_setter($attrib,@args);
}
}
sub escape {
my $str = shift;
return "" unless defined $str;
$str =~ s{&}{&}g;
$str =~ s{"}{"}g;
$str =~ s{'}{'}g;
$str =~ s{<}{<}g;
$str =~ s{>}{>}g;
$str;
}
sub _getter {
my ($self, $attrib, $where, %guard);
if (@_ % 2 == 0) {
($self, $attrib, %guard) = @_;
}
else {
($self, $attrib, $where) = @_;
}
my @ret = ();
for (@{ $self->$attrib }) {
if (ref $where eq 'CODE') {
push(@ret,$_) if $where->($_);
}
else {
my $ok = 1;
for my $k (keys %guard) {
my $val = $guard{$k};
$ok = 0 unless (defined $_->$k && $_->$k eq $val);
}
push(@ret,$_) if $ok == 1;
}
}
wantarray ? @ret : $ret[0];
}
sub _setter {
my ($self, $attrib, @objs) = @_;
my $ret;
if (@objs == 0) {
$ret = $self->$attrib;
}
elsif (@objs == 1 && ref($objs[0]) eq 'ARRAY') {
$self->$attrib($objs[0]);
$ret = $objs[0];
}
elsif (@objs == 1 && !defined $objs[0]) {
$self->$attrib([]);
$ret = [];
}
else {
$self->$attrib(\@objs);
$ret = \@objs;
}
wantarray ? @$ret : $ret;
}
sub _adder {
my ($self, $attrib, $obj,%opts);
if (@_ % 2 == 0) {
($self, $attrib,%opts) = @_;
}
else {
($self, $attrib, $obj,%opts) = @_;
}
my $class = $attrib;
$class =~ s{^(.)}{uc($1)}e;
$class = "MODS::Element::$class";
if (ref $obj eq 'CODE') {
my $sub = $obj;
$obj = $class->new(%opts);
my $ref = $self->$attrib;
push (@$ref,$obj);
$self->$attrib($ref);
$sub->($obj);
}
elsif (ref $obj eq $class) {
my $ref = $self->$attrib;
push (@$ref,$obj);
$self->$attrib($ref);
}
elsif (defined $obj && $class->can('_body')) {
$obj = $class->new(_body => $obj, %opts);
my $ref = $self->$attrib;
push (@$ref,$obj);
$self->$attrib($ref);
}
elsif (! defined $obj) {
$obj = $class->new(%opts);
my $ref = $self->$attrib;
push (@$ref,$obj);
$self->$attrib($ref);
}
else {
croak "eek: self($self) class($class) obj($obj)";
}
if ($obj->does('MODS::Record::Unique')) {
my $ref = $self->$attrib;
$self->$attrib([$ref->[-1]]);
}
$obj;
}
sub _isa {
my $type = shift;
die "Need an array of MODS::Element::*" unless ref $type eq 'ARRAY';
for (@$type) {
die "Need a element of MODS::Element::*" unless ref($_) =~ /^MODS::Element::/;
}
}
sub body {
my ($self,$val) = @_;
if ($self->can('_body')) {
$self->_body($val) if defined $val;
return $self->_body;
}
else {
return undef;
}
}
sub as_xml {
my ($self,%opts) = @_;
my $output = '';
my $class = ref $self;
$class =~ s{^(.*)::(.)(.*)}{lc($2) . $3}e;
my $encoding = $opts{'encoding'} || 'UTF-8';
$output .= "\n" if $opts{'xml_prolog'};
$output .= "$key;
if ($key =~ /^_/) {
next;
}
elsif (ref $val eq '') {
$output .= " $key=\"" . escape($val) . "\"";
}
}
$output .= ">";
if ($self->can('_body')) {
if (ref $self->_body && $self->_body->can('as_xml')) {
$output .= $self->_body->as_xml;
}
else {
$output .= escape($self->_body);
}
}
for my $key (keys %$self) {
my $val = $self->$key;
if ($key =~ /^_/ || ref $val ne 'ARRAY') {
next;
}
for (@{ $self->$key} ) {
$output .= $_->as_xml;
}
}
$output .= "";
$output;
}
sub as_json {
my ($self, %opts) = @_;
my $class = ref $self;
$class =~ s{^(.*)::(.)(.*)}{lc($2) . $3}e;
to_json({$class => $self}, { utf8 => 1, convert_blessed => 1 , allow_blessed => 1 , pretty => $opts{pretty}});
}
sub TO_JSON {
my $ret = { %{ shift() } };
for (keys %$ret) {
if (ref $ret->{$_} eq 'ARRAY' && @{$ret->{$_}} == 0) {
delete $ret->{$_};
}
}
$ret;
}
package MODS::Record::Unique;
use Moo::Role;
package MODS::Record::Xml_String;
use Moo;
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => (is => 'ro');
sub as_xml {
my $self = shift;
$self->_body;
}
sub TO_JSON { return shift->_body; }
package MODS::Element::Abstract;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has xlink => ( is => 'rw' );
has shareable => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has altFormat => ( is => 'rw' );
has contentType => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::AccessCondition;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has xlink => ( is => 'rw' );
has type => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has altFormat => ( is => 'rw' );
has contentType => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Affiliation;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => ( is => 'rw' );
package MODS::Element::Classification;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has edition => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has usage => ( is => 'rw' );
has generator => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Extension;
use Moo;
with('MODS::Record::Util');
has displayLabel => ( is => 'rw' );
has _body => ( is => 'rw' );
use overload fallback => 1 , '""' => sub { $_[0]->_body };
package MODS::Element::Genre;
# [Warning]
# The genre-element in MODS is used in different context.
# All solution we provide here the broadest possible interpretation.
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has usage => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Identifier;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has typeURI => ( is => 'rw' );
has invalid => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Language;
use Moo;
with('MODS::Record::Util');
has objectPart => ( is => 'rw' );
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has usage => ( is => 'rw' );
has languageTerm => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has scriptTerm => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::LanguageTerm;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::ScriptTerm;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Location;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has physicalLocation => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has shelfLocator => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has url => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has holdingSimple => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has holdingExternal => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::PhysicalLocation;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has xlink => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Url;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has dateLastAccessed => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has note => ( is => 'rw' );
has access => ( is => 'rw' );
has usage => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::HoldingSimple;
use Moo;
with('MODS::Record::Util','MODS::Record::Unique');
has copyInformation => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::CopyInformation;
use Moo;
with('MODS::Record::Util');
has form => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has subLocation => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has shelfLocator => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has electronicLocator => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has note => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has enumerationAndChronology => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::Form;
use Moo;
# [Warning]
# The form-element is used in more than one context in MODS. One usage
# required unique, the other usag is repeatable. We use the latter here
# for all 'form'-elements.
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has type => ( is => 'rw' );
has ID => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::SubLocation;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::ShelfLocator;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Note;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has ID => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has typeURI => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has xlink => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::EnumerationAndChronology;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has unitType => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::HoldingExternal;
use Moo;
with('MODS::Record::Util','MODS::Record::Unique');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has displayLabel => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Name;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has ID => ( is => 'rw' );
has xlink => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has usage => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has nameTitleGroup => ( is => 'rw' );
has type => ( is => 'rw' );
has namePart => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has displayForm => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has affiliation => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has role => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has description => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has etal => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::NamePart;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DisplayForm;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Role;
use Moo;
with('MODS::Record::Util');
has roleTerm => ( is => 'rw' , default => sub{ [] } );
package MODS::Element::RoleTerm;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Description;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Etal;
use Moo;
with('MODS::Record::Util','MODS::Record::Unique');
package MODS::Element::OriginInfo;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has eventType => ( is => 'rw' );
has place => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has publisher => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateIssued => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateCreated => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateCaptured => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateValid => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateModified => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has copyrightDate => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has dateOther => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has edition => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has issuance => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has frequency => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Place;
use Moo;
with('MODS::Record::Util');
has supplied => ( is => 'rw' );
has placeTerm => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::PlaceTerm;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Publisher;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has supplied => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateIssued;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateCreated;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateCaptured;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateValid;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateModified;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::CopyrightDate;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DateOther;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Edition;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has supplied => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Issuance;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => ( is => 'rw' );
package MODS::Element::Frequency;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Part;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has ID => ( is => 'rw' );
has type => ( is => 'rw' );
has order => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has detail => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has extent => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has date => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has text => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::Detail;
use Moo;
with('MODS::Record::Util');
has type => ( is => 'rw' );
has level => ( is => 'rw' );
has number => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has caption => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
has title => ( is => 'rw' , isa => \&_isa , default => sub { [] } );
package MODS::Element::Number;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Caption;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Extent;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
# [Warning]
# The 'extent' element is used in MODS in two different contexts.
# As temporary solution we push all possible attributes in one Extent-package...
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has supplied => ( is => 'rw' );
has unit => ( is => 'rw' );
has start => ( is => 'rw' , default => sub {[]});
has end => ( is => 'rw' , default => sub {[]});
has total => ( is => 'rw' , default => sub {[]});
has list => ( is => 'rw' , default => sub {[]});
has _body => ( is => 'rw' );
package MODS::Element::Start;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::End;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Total;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => ( is => 'rw' );
package MODS::Element::List;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Date;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Text;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has xlink => ( is => 'rw' );
has type => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::PhysicalDescription;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has form => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has reformattingQuality => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has internetMediaType => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has extent => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has digitalOrigin => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has note => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::ReformattingQuality;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => ( is => 'rw' );
package MODS::Element::InternetMediaType;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::DigitalOrigin;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has _body => ( is => 'rw' );
package MODS::Element::RecordInfo;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has recordContentSource => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordCreationDate => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordChangeDate => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordIdentifier => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordOrigin => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has languageOfCataloging => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has descriptionStandard => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::RecordContentSource;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::RecordCreationDate;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::RecordChangeDate;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::RecordIdentifier;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has source => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::RecordOrigin;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::LanguageOfCataloging;
use Moo;
with('MODS::Record::Util');
has objectPart => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has usage => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has languageTerm => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has scriptTerm => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::DescriptionStandard;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::RelatedItem;
use Moo;
with('MODS::Record::Util');
has ID => ( is => 'rw' );
has xlink => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has titleInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has name => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has typeOfResource => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has genre => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has originInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has language => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has physicalDescription => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has abstract => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has tableOfContents => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has targetAudience => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has note => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has subject => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has classification => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has relatedItem => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has identifier => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has location => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has accessCondition => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has part => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has extension => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Subject;
use Moo;
with('MODS::Record::Util');
has ID => ( is => 'rw' );
has xlink => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has usage => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has topic => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has geographic => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has temporal => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has titleInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has name => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has geographicCode => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has genre => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has hierarchicalGeographic => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has cartographics => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has occupation => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Topic;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Geographic;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Temporal;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has encoding => ( is => 'rw' );
has point => ( is => 'rw' );
has keyDate => ( is => 'rw' );
has qualifier => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::GeographicCode;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::HierarchicalGeographic;
use Moo;
with('MODS::Record::Util');
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has continent => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has country => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has province => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has region => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has state => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has territory => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has county => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has city => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has island => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has area => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has extraterrestrialArea => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has citySection => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Continent;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Country;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Province;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Region;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::State;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Territory;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::County;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::City;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Island;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Area;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::ExtraterrestrialArea;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::CitySection;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Occupation;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Cartographics;
use Moo;
with('MODS::Record::Util');
has scale => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has projection => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has coordinates => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Scale;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Projection;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Coordinates;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::TableOfContents;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has xlink => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has type => ( is => 'rw' );
has shareable => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has altFormat => ( is => 'rw' );
has contentType => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::TargetAudience;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::TitleInfo;
use Moo;
with('MODS::Record::Util');
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has authorityURI => ( is => 'rw' );
has valueURI => ( is => 'rw' );
has authority => ( is => 'rw' );
has ID => ( is => 'rw' );
has type => ( is => 'rw' );
has otherType => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has supplied => ( is => 'rw' );
has usage => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has nameTitleGroup => ( is => 'rw' );
has altFormat => ( is => 'rw' );
has contentType => ( is => 'rw' );
has title => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has subTitle => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has partNumber => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has partName => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has nonSort => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::Title;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::SubTitle;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::PartNumber;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::PartName;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::NonSort;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has lang => ( is => 'rw' );
has xml_lang => ( is => 'rw' );
has script => ( is => 'rw' );
has transliteration => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::TypeOfResource;
use Moo;
with('MODS::Record::Util');
use overload fallback => 1 , '""' => sub { $_[0]->_body };
has collection => ( is => 'rw' );
has manuscript => ( is => 'rw' );
has displayLabel => ( is => 'rw' );
has usage => ( is => 'rw' );
has altRepGroup => ( is => 'rw' );
has _body => ( is => 'rw' );
package MODS::Element::Mods;
use Moo;
with('MODS::Record::Util');
has version => ( is => 'rw' , default => sub { "3.5"} );
has ID => ( is => 'rw');
has abstract => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has accessCondition => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has classification => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has extension => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has genre => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has identifier => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has language => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has location => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has name => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has note => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has originInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has part => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has physicalDescription => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has recordInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has relatedItem => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has subject => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has tableOfContents => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has targetAudience => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has titleInfo => ( is => 'rw' , isa => \&_isa , default => sub { [] });
has typeOfResource => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Element::ModsCollection;
use Moo;
with('MODS::Record::Util');
has mods => ( is => 'rw' , isa => \&_isa , default => sub { [] });
package MODS::Parser;
use Moo;
use XML::Parser;
use JSON;
with('MODS::Record::Util');
our @stack = ();
our $body;
our $level = 0;
our $flag = 0;
our $count = 0;
sub parse {
my ($self,$source,$callback) = @_;
@stack = ();
$body = undef;
$level = 0;
$flag = 0;
$count = 0;
my $parser = XML::Parser->new(Handlers => {
Start => \&start ,
Char => \&char,
End => \&end ,
} , 'Non-Expat-Options' => { callback => $callback });
$parser->parse($source);
if (defined $callback) {
$count;
}
else {
$stack[0];
}
}
sub parse_json {
my ($self, $source, $callback) = @_;
if (ref($source) =~ /^IO::/) {
if (defined $callback) {
my $count = 0;
while(<$source>) {
$callback->(_parse_json($_));
$count++;
}
$count;
}
else {
local $/;
my $json_txt = <$source>;
_parse_json($json_txt);
}
}
elsif (defined $callback) {
my $count = 0;
for (split(/\n/,$source)) {
$callback->(_parse_json($_));
$count++;
}
$count;
}
else {
_parse_json($source);
}
}
sub _parse_json {
my $json_txt = shift;
my $perl = JSON->new->utf8(1)->decode($json_txt);
_bless_object($perl);
[ %{ $perl } ]->[1];
}
sub _bless_object {
my $obj = shift;
return unless ref($obj) =~ /^HASH|MODS::Element/;
for (keys %$obj) {
my $val = $obj->{$_};
my $class = $_;
$class =~ s{^(.)}{uc($1)}e;
$class = "MODS::Element::$class";
if (ref($val) eq 'ARRAY') {
for (@{$val}) {
_bless_object(bless($_,$class));
}
}
elsif (ref($val) eq 'HASH') {
_bless_object(bless($val,$class));
}
}
}
sub start {
my ($expat,$element,%attrs) = @_;
my $local_name = $element; $local_name =~ s/^\w+://;
my $e;
if ($level) {
$level++;
}
elsif (@stack == 0) {
my $module = $local_name;
$module =~ s{^(.)}{uc($1)}e;
$module = "MODS::Element::$module";
$e = $module->new(%attrs);
$body = undef;
push(@stack,$e);
}
else {
my $method = "add_$local_name";
my $module = $local_name;
$module =~ s{^(.)}{uc($1)}e;
$module = "MODS::Element::$module";
# Start recording literal XML if we find an element we cant recognize...
if ($stack[-1]->can($local_name)) {
$e = $stack[-1]->$method($module->new(%attrs));
$body = undef;
push(@stack,$e);
}
else {
die "$element not allowed in " . ref($stack[-1]) unless ref($stack[-1]) =~ /^MODS::Element::(AccessCondition|Extension)$/;
$level++;
}
}
if ($level) {
$body .= "<$element";
for (keys %attrs) {
$body .= " $_=\"" . escape($attrs{$_}) . "\"";
}
$body .= ">";
}
}
sub char {
my ($expat,$string) = @_;
$body .= $string;
}
sub end {
my ($expat,$element,%attrs) = @_;
my $local_name = $element; $local_name =~ s/^\w+://;
my $callback = $expat->{'Non-Expat-Options'}->{'callback'};
if ($level) {
$body .= "$element>";
$level--;
$flag = 1;
}
else {
$body = MODS::Record::Xml_String->new(_body => $body) if $flag;
$flag = 0;
$stack[-1]->_body($body) if $stack[-1]->can('_body');
$body = undef;
if ($local_name eq 'mods' && defined $callback) {
$count++;
$callback->(pop(@stack));
}
else {
pop(@stack) unless @stack == 1;
}
}
}
sub debug {
my $msg = shift;
print STDERR "$msg\n";
print STDERR "level: $level\n";
print STDERR "flag: $flag\n";
for (@stack) {
printf STDERR "%s\n" , ref $_;
}
print STDERR "---\n";
}
1;
mods_multiple.json 100644 000765 000024 13360 13375542142 17637 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t {"mods":{"location":[{"url":[{"_body":"http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803"},{"access":"preview","_body":"http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png"}]}],"version":"3.3","subject":[{"topic":[{"_body":"Mountains"}],"authority":"lctgm"},{"topic":[{"_body":"Snow"}],"authority":"lctgm"},{"topic":[{"_body":"Telescope Peak (Inyo County, Calif.)"}]},{"topic":[{"_body":"Zabriskie Point (Calif.)"}]},{"hierarchicalGeographic":[{"country":[{"_body":"United States"}],"county":[{"_body":"Inyo"}],"state":[{"_body":"California"}]}]}],"name":[{"namePart":[{"type":"family","_body":"Cushman"},{"type":"given","_body":"Charles Weever"},{"type":"date","_body":"1896-1972"}],"role":[{"roleTerm":[{"type":"code","_body":"pht","authority":"marcrelator"},{"type":"text","_body":"Photographer","authority":"marcrelator"}]}]}],"accessCondition":[{"_body":" Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405"}],"genre":[{"_body":"Landscape photographs","authority":"gmgpc"}],"physicalDescription":[{"internetMediaType":[{"_body":"image/jpeg"}],"digitalOrigin":[{"_body":"reformatted digital"}],"note":[{"_body":" Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."},{"_body":"100 f 6.3 tl"}]}],"identifier":[{"displayLabel":"Cushman number","type":"local","_body":"955.11"},{"displayLabel":"IU Archives number","type":"local","_body":"P07803"}],"recordInfo":[{"recordCreationDate":[{"_body":"2004-09-09","encoding":"w3cdtf"}],"recordContentSource":[{"_body":"Indiana University Digital Library Program"}],"recordIdentifier":[{"_body":"archives/cushman/P07803"}]}],"titleInfo":[{"title":[{"_body":"Telescope Peak from Zabriskie Point"}]},{"title":[{"_body":"Telescope PK from Zabriskie Pt."}],"type":"alternative"}],"typeOfResource":[{"_body":"still image"}],"relatedItem":[{"physicalDescription":[{"form":[{"_body":"graphic","authority":"gmd"}],"extent":[{"_body":"1 slide : col. ; 35mm"}],"note":[{"_body":"Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."}]}],"location":[{"physicalLocation":[{"displayLabel":"Original slide","_body":" Indiana University, Bloomington. University Archives P07803 "}]}],"type":"original","originInfo":[{"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]},{"titleInfo":[{"title":[{"_body":" Indiana University Digital Library Program: Charles W. Cushman Photograph Collection"}],"type":"uniform","authority":"dlfaqcoll"}],"type":"host"}],"originInfo":[{"copyrightDate":[{"_body":"2003","encoding":"w3cdtf"}],"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]}}
{"mods":{"location":[{"url":[{"_body":"http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803"},{"access":"preview","_body":"http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png"}]}],"version":"3.3","subject":[{"topic":[{"_body":"Mountains"}],"authority":"lctgm"},{"topic":[{"_body":"Snow"}],"authority":"lctgm"},{"topic":[{"_body":"Telescope Peak (Inyo County, Calif.)"}]},{"topic":[{"_body":"Zabriskie Point (Calif.)"}]},{"hierarchicalGeographic":[{"country":[{"_body":"United States"}],"county":[{"_body":"Inyo"}],"state":[{"_body":"California"}]}]}],"name":[{"namePart":[{"type":"family","_body":"Cushman"},{"type":"given","_body":"Charles Weever"},{"type":"date","_body":"1896-1972"}],"role":[{"roleTerm":[{"type":"code","_body":"pht","authority":"marcrelator"},{"type":"text","_body":"Photographer","authority":"marcrelator"}]}]}],"accessCondition":[{"_body":" Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405"}],"genre":[{"_body":"Landscape photographs","authority":"gmgpc"}],"physicalDescription":[{"internetMediaType":[{"_body":"image/jpeg"}],"digitalOrigin":[{"_body":"reformatted digital"}],"note":[{"_body":" Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."},{"_body":"100 f 6.3 tl"}]}],"identifier":[{"displayLabel":"Cushman number","type":"local","_body":"955.11"},{"displayLabel":"IU Archives number","type":"local","_body":"P07803"}],"recordInfo":[{"recordCreationDate":[{"_body":"2004-09-09","encoding":"w3cdtf"}],"recordContentSource":[{"_body":"Indiana University Digital Library Program"}],"recordIdentifier":[{"_body":"archives/cushman/P07803"}]}],"titleInfo":[{"title":[{"_body":"Telescope Peak from Zabriskie Point"}]},{"title":[{"_body":"Telescope PK from Zabriskie Pt."}],"type":"alternative"}],"typeOfResource":[{"_body":"still image"}],"relatedItem":[{"physicalDescription":[{"form":[{"_body":"graphic","authority":"gmd"}],"extent":[{"_body":"1 slide : col. ; 35mm"}],"note":[{"_body":"Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available."}]}],"location":[{"physicalLocation":[{"displayLabel":"Original slide","_body":" Indiana University, Bloomington. University Archives P07803 "}]}],"type":"original","originInfo":[{"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]},{"titleInfo":[{"title":[{"_body":" Indiana University Digital Library Program: Charles W. Cushman Photograph Collection"}],"type":"uniform","authority":"dlfaqcoll"}],"type":"host"}],"originInfo":[{"copyrightDate":[{"_body":"2003","encoding":"w3cdtf"}],"dateCreated":[{"keyDate":"yes","_body":"1955-03-22","encoding":"w3cdtf"}]}]}}
author-pod-syntax.t 100644 000765 000024 454 13375542142 17622 0 ustar 00hochsten staff 000000 000000 MODS-Record-0.13/t #!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
print qq{1..0 # SKIP these tests are for testing by the author\n};
exit
}
}
# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use strict; use warnings;
use Test::More;
use Test::Pod 1.41;
all_pod_files_ok();