62 lines
2.1 KiB
Text
62 lines
2.1 KiB
Text
|
|
A proposed perl data structure for storing marc info
|
|
|
|
|
|
$record is a hash reference
|
|
|
|
$record->{leader}=
|
|
$record->{bibid}=58973
|
|
$record->{tags}=$tags
|
|
|
|
$tags is a hash reference
|
|
|
|
$tags->{$tag}
|
|
$tags->{$tag}->{$tagorder}
|
|
$tags->{$tag}->{$tagorder}->{indicator}='04'
|
|
$tags->{$tag}->{$tagorder}->{tagid}=573498
|
|
$tags->{$tag}->{$tagorder}->{subfields}=$subfields
|
|
|
|
$subfields is a hash reference
|
|
|
|
$subfields->{$mark}
|
|
$subfields->{$mark}->{$subfieldorder}
|
|
$subfields->{$mark}->{$subfieldorder}='MacDonald, John A.'
|
|
|
|
Sample :
|
|
bibid=58973,
|
|
110 ## $afirst text $asecond text $bthird text
|
|
120 ## $alast text ??
|
|
120 01 $nno, another text
|
|
|
|
in perlmarcstructure, it can be writen :
|
|
$record->{bibid}=58973;
|
|
$record->{tags}->{110}->{1}->{indicator}='##';
|
|
$record->{tags}->{110}->{1}->{subfields}->{a}->{1}='first text';
|
|
$record->{tags}->{110}->{1}->{subfields}->{a}->{2}='second text';
|
|
$record->{tags}->{110}->{1}->{subfields}->{b}->{1}='third text';
|
|
|
|
$record->{tags}->{120}->{1}->{indicator}='##';
|
|
$record->{tags}->{120}->{1}->{subfields}->{a}->{1}='last text ??';
|
|
|
|
$record->{tags}->{120}->{2}->{indicator}='01';
|
|
$record->{tags}->{120}->{2}->{subfields}->{n}->{1}='no, another text';
|
|
|
|
This takes care of possible repeating tags and subfields as well as ordering of
|
|
tags and subfields, but it makes it difficult to look up specific tags and
|
|
subfields without looping through every time. It might be an idea to add an
|
|
index to the structure to aid these lookups.
|
|
|
|
$record->{index}->{110}->{tags}=\(3,4) <-- array ref shows that tags 3 and 4
|
|
are 110 tags
|
|
|
|
Need a similar index for subfields.... I'm not sure if this is any simpler than
|
|
just looping through the tags every time. :)
|
|
|
|
I think looping is the way to go...
|
|
|
|
This still needs more work. This will also require an API for accessing or
|
|
modifying this structure, as it is non-trivial to parse the data. I'm also
|
|
starting to wonder how difficult it is going to be to develop templates using
|
|
this kind of structure. HTML::Template has no facility for parsing this kind
|
|
of data structure. We might need an alternate (or completely different) data
|
|
structure that is parseable by HTML::Template.
|