Proposing simplified perlmarcstructure. Interesting mainly for Steve
[koha_fer] / marc / perlmarcstructure
1
2 A proposed perl data structure for storing marc info
3
4
5 $record is a hash reference
6
7 $record->{leader}=
8 $record->{bibid}=58973
9 $record->{tags}=$tags
10
11 $tags is a hash reference
12
13 $tags->{$tag}
14 $tags->{$tag}->{$tagorder}
15 $tags->{$tag}->{$tagorder}->{indicator}='04'
16 $tags->{$tag}->{$tagorder}->{tagid}=573498
17 $tags->{$tag}->{$tagorder}->{subfields}=$subfields
18
19 $subfields is a hash reference
20
21 $subfields->{$mark}
22 $subfields->{$mark}->{$subfieldorder}
23 $subfields->{$mark}->{$subfieldorder}='MacDonald, John A.'
24
25 Sample :
26 bibid=58973,
27 110 ## $afirst text $asecond text $bthird text
28 120 ## $alast text ??
29 120 01 $nno, another text
30
31 in perlmarcstructure, it can be writen :
32 $record->{bibid}=58973
33 $record->{tags}->{110}->{1}->{indicator}='##';
34 $record->{tags}->{110}->{1}->->{a}->{1}='first text';
35 $record->{tags}->{110}->{1}->{a}->{2}='second text';
36 $record->{tags}->{110}->{1}->{b}->{1}='third text';
37
38 $record->{tags}->{120}->{1}->{indicator}='##';
39 $record->{tags}->{120}->{1}->{a}->{1}='last text ??';
40
41 $record->{tags}->{120}->{2}->{indicator}='01';
42 $record->{tags}->{120}->{2}->{n}->{1}='no, another text';
43
44
45 This takes care of possible repeating tags and subfields as well as ordering of
46 tags and subfields, but it makes it difficult to look up specific tags and
47 subfields without looping through every time.  It might be an idea to add an
48 index to the structure to aid these lookups.
49
50 $record->{index}->{110}->{tags}=\(3,4)   <-- array ref shows that tags 3 and 4
51                                              are 110 tags
52
53 Need a similar index for subfields.... I'm not sure if this is any simpler than
54 just looping through the tags every time.  :)
55
56 I think looping is the way to go...
57
58 This still needs more work.  This will also require an API for accessing or
59 modifying this structure, as it is non-trivial to parse the data.  I'm also
60 starting to wonder how difficult it is going to be to develop templates using
61 this kind of structure.  HTML::Template has no facility for parsing this kind
62 of data structure.  We might need an alternate (or completely different) data
63 structure that is parseable by HTML::Template.