C4::Record - MARC, MARCXML, DC, MODS, XML, etc. Record Management Functions and API
New in Koha 3.x. This module handles all record-related management functions.
my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding);
Returns an ISO-2709 scalar
my ($error,$marcxml) = marc2marcxml($marc,$encoding,$flavour);
Returns a MARCXML scalar
$marc
- an ISO-2709 scalar or MARC::Record object
$encoding
- UTF-8 or MARC-8 [UTF-8]
$flavour
- MARC21 or UNIMARC
$dont_entity_encode
- a flag that instructs marc2marcxml not to entity encode the xml before returning (optional)
my ($error,$marc) = marcxml2marc($marcxml,$encoding,$flavour);
Returns an ISO-2709 scalar
$marcxml
- a MARCXML record
$encoding
- UTF-8 or MARC-8 [UTF-8]
$flavour
- MARC21 or UNIMARC
my dcxml = marc2dcxml ($marc, $xml, $biblionumber, $format);
EXAMPLE
my dcxml = marc2dcxml (undef, undef, 1, "oaidc");
Convert MARC or MARCXML to Dublin Core metadata (XSLT Transformation), optionally can get an XML directly from database (biblioitems.marcxml) without item information. This method take into consideration the syspref 'marcflavour' (UNIMARC, MARC21 and NORMARC). Return an XML file with the format defined in $format
$marc
- an ISO-2709 scalar or MARC::Record object
$xml
- a MARCXML file
$biblionumber
- obtain the record directly from database (biblioitems.marcxml)
$format
- accept three type of DC formats (oaidc, srwdc, and rdfdc )
my $modsxml = marc2modsxml($marc);
Returns a MODS scalar
my $madsxml = marc2madsxml($marc);
Returns a MADS scalar
my $xml = _transformWithStylesheet($marc, $stylesheet)
Returns the XML scalar result of the transformation. $stylesheet should contain the path to a stylesheet under intrahtdocs.
my ($csv) = marc2csv($biblios, $csvprofileid, $itemnumbers);
Pre and postprocessing can be done through a YAML file
Returns a CSV scalar
$biblio
- a list of biblionumbers
$csvprofileid
- the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv)
$itemnumbers
- a list of itemnumbers to export
my ($csv) = marcrecord2csv($biblio, $csvprofileid, $header);
Returns a CSV scalar
$biblio
- a biblionumber
$csvprofileid
- the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv)
$header
- true if the headers are to be printed (typically at first pass)
$csv
- an already initialised Text::CSV object
$fieldprocessing
$itemnumbers
a list of itemnumbers to export
my ($error, $newrecord) = changeEncoding($record,$format,$flavour,$to_encoding,$from_encoding);
Changes the encoding of a record
$record
- the record itself can be in ISO-2709, a MARC::Record object, or MARCXML for now (required)
$format
- MARC or MARCXML (required)
$flavour
- MARC21 or UNIMARC, if MARC21, it will change the leader (optional) [defaults to Koha system preference]
$to_encoding
- the encoding you want the record to end up in (optional) [UTF-8]
$from_encoding
- the encoding the record is currently in (optional, it will probably be able to tell unless there's a problem with the record)
FIXME: the from_encoding doesn't work yet
FIXME: better handling for UNIMARC, it should allow management of 100 field
FIXME: shouldn't have to convert to and from xml/marc just to change encoding someone needs to re-write MARC::Record's 'encoding' method to actually alter the encoding rather than just changing the leader
my ($bibtex) = marc2bibtex($record, $id);
Returns a BibTex scalar
$record
- a MARC::Record object
$id
- an id for the BibTex record (might be the biblionumber)
my ($entity_encoded_string) = _entity_encode($string);
or
my (@entity_encoded_strings) = _entity_encode(@strings);
Entity-encode an array of strings
Joshua Ferraro <jmf@liblime.com>