<<

NAME

C4::Record - MARC, MARCXML, DC, MODS, XML, etc. Record Management Functions and API

SYNOPSIS

New in Koha 3.x. This module handles all record-related management functions.

API (EXPORTED FUNCTIONS)

marc2marc - Convert from one flavour of ISO-2709 to another

my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding);

Returns an ISO-2709 scalar

marc2marcxml - Convert from ISO-2709 to MARCXML

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)

marcxml2marc - Convert from MARCXML to ISO-2709

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

marc2dcxml - Convert from ISO-2709 to Dublin Core

my ($error,$dcxml) = marc2dcxml($marc,$qualified);

Returns a DublinCore::Record object, will eventually return a Dublin Core scalar

FIXME: should return actual XML, not just an object

$marc - an ISO-2709 scalar or MARC::Record object

$qualified - specify whether qualified Dublin Core should be used in the input or output [0]

marc2modsxml - Convert from ISO-2709 to MODS

my ($error,$modsxml) = marc2modsxml($marc);

Returns a MODS scalar

html2marcxml

my ($error,$marcxml) = html2marcxml($tags,$subfields,$values,$indicator,$ind_tag);

Returns a MARCXML scalar

this is used in addbiblio.pl and additem.pl to build the MARCXML record from the form submission.

FIXME: this could use some better code documentation

html2marc

Probably best to avoid using this ... it has some rather striking problems:

* saves blank subfields

* subfield order is hardcoded to always start with 'a' for repeatable tags (because it is hardcoded in the addfield routine).

* only possible to specify one set of indicators for each set of tags (ie, one for all the 650s). (because they were stored in a hash with the tag as the key).

* the underlying routines didn't support subfield reordering or subfield repeatability.

I've left it in here because it could be useful if someone took the time to fix it. -- kados

changeEncoding - Change the encoding of a record

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

INTERNAL FUNCTIONS

_entity_encode - Entity-encode an array of strings

my ($entity_encoded_string) = _entity_encode($string);

or

my (@entity_encoded_strings) = _entity_encode(@strings);

Entity-encode an array of strings

AUTHOR

Joshua Ferraro <jmf@liblime.com>

MODIFICATIONS

<<