Added POD.
[koha.git] / 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}->{subfields}->{a}->{1}='first text';
35 $record->{tags}->{110}->{1}->{subfields}->{a}->{2}='second text';
36 $record->{tags}->{110}->{1}->{subfields}->{b}->{1}='third text';
37
38 $record->{tags}->{120}->{1}->{indicator}='##';
39 $record->{tags}->{120}->{1}->{subfields}->{a}->{1}='last text ??';
40
41 $record->{tags}->{120}->{2}->{indicator}='01';
42 $record->{tags}->{120}->{2}->{subfields}->{n}->{1}='no, another text';
43
44 This takes care of possible repeating tags and subfields as well as ordering of
45 tags and subfields, but it makes it difficult to look up specific tags and
46 subfields without looping through every time.  It might be an idea to add an
47 index to the structure to aid these lookups.
48
49 $record->{index}->{110}->{tags}=\(3,4)   <-- array ref shows that tags 3 and 4
50                                              are 110 tags
51
52 Need a similar index for subfields.... I'm not sure if this is any simpler than
53 just looping through the tags every time.  :)
54
55 I think looping is the way to go...
56
57 This still needs more work.  This will also require an API for accessing or
58 modifying this structure, as it is non-trivial to parse the data.  I'm also
59 starting to wonder how difficult it is going to be to develop templates using
60 this kind of structure.  HTML::Template has no facility for parsing this kind
61 of data structure.  We might need an alternate (or completely different) data
62 structure that is parseable by HTML::Template.