module Kwmarc:sig
..end
Functions to read and parse MARC (ISO 2709) records. Also includes a MARC to Dublin Core crosswalk.
Missing functionality: lots, but most notably, MARC-8 character set
handling; all strings from field values are simply octets.
Author(s): Keith Waclena
module L:Kwlookup.Alist
(
String
)
exception Bad of string
type
leader = {
|
reclen : |
|
status : |
|
typeof : |
|
biblevel : |
|
control : |
|
charset : |
|
indcnt : |
|
sfccnt : |
|
base : |
|
enclevel : |
|
desccat : |
|
multipart : |
|
lof : |
|
scp : |
|
id : |
|
undefined : |
val leader_field_of_offset : string array
type
data = {
|
indicator : |
|
subs : |
type
field =
| |
Control of |
| |
Data of |
type
marc = {
|
leader : |
|
fields : |
|
raw : |
val string_of_marc : marc -> string
val parse : string -> marc
val leader : marc -> leader
val field : L.key -> marc -> field
val subfield : L.key -> field -> string
val indicator : 'a -> field -> 'b
val read : Pervasives.in_channel -> string option
val fold : ('a -> string -> 'a) -> 'a -> Pervasives.in_channel -> 'a
The Kwmarc.crosswalk
function can convert a MARC record into other formats. We only provide
one crosswalk (Unqualified Dublin Core) but more are possible.
exception BadFF
ff
) substring in crosswalkval crosswalk : ('a * spec list) list -> marc -> ('a * string) list
crosswalk cw record
: generate a translation of this MARC record
according to the crosswalk cw
.
This function generates a list of repeatable named elements, each
of which is mapped to values of a MARC field (which may be restricted
to particular subfields); subfields are joined together with spaces
between them. This is suitable to generate simple XML (for, say,
Dublin Core), where the names could be XML elements and the values,
CDATA.
Returns an alist of (name, value) pairs
record
: a parse MARC recordval df : ?subs:char list -> string -> spec
df ?subs f
: content of variable data field, with optional subfield restrictions.subs
: restricted subfield namesf
: field nameval cf : string -> int -> int -> spec
cf f a b
: content of control field characters a-b
.f
: field namea
: index of first character of datab
: index of last character of dataval except : int list -> int list -> int list
except ex list
: exclude (eliminate) all fields numbered in ex
from list
.
For example, to specify all 5xx fields except for 506, 530, 540, and 546, you could say
500--599 |> except [506; 530; 540; 546] |> map (df & string_of_int)
ex
: field numbers to excludeval ($) : int -> char -> spec
f$s
: content of field f
, subfield s
module DC:sig
..end