On Fri, Nov 12, 2010 at 01:55:32AM +0100, Marc Chantreux wrote: > hi galen, > > On Thu, Nov 11, 2010 at 07:40:35PM -0500, Galen Charlton wrote: > > I don't see how a structure like this gets you anywhere closer to an > > abstraction layer that would permit somebody to code in terms of > > semantic concepts like title and author instead of MARC tags, > > It doesn't: the fact is we're working on libraries to do that (see > MARC::Mapper from my other mail) and i really would like to interact > both with > > - MARC::Record: it's heavily used in the koha ILS > - the Frederic Demians's MARC lib which is much more modern
Do you mean marc-moose, a.k.a. Marc? No offense to Frederic but it seems like overkill to me. But then I'm biased -- see below. > - what we at biblibre call a SimpleRecord which is just a hash of non > ordered fields > > i don't want to write a web of gateways for all those structures and > those to come so i propose to have a common way to share between all of > our works. > > For example: MARC::Template and ISO2709 have internal code to build > MARC::Records and SimpleRecords so they depends on MARC::Record. I > really would like to drop this code for something more generic and > simple. > > > you're looking for a serialization or data structure that is more > > i'm not talking about serialization at all, i'm talking about sharing > data between marc related tools as PSGI does for the web thing. sorry if > i wasn't clear. You might be interested in my *non*-object-oriented module -- see http://search.cpan.org/dist/MARC-Loop/ -- that parses records into a structure like this: ($leader, \...@fields) Where @fields is a list of array refs, each like this: [ $tag, \$rawfield, $delete_flag, $i1, $i2, @subfields ] And @subfields is a list of array refs, each like this: [ $subid, \$subval ] No objects, just data, so you get to (read: have to) slice and dice the data yourself. And of course there's a function that goes the other way -- and a looping function that was my main justification for writing the thing in the first place: use MARC::Loop qw(marcloop TAG DEL); marcloop { my ($leader, $fields) = @_; # Strip all local fields and print the record if there were any my $changed; $changed = $_->[DELETE] = 1 for grep { $_->[TAG] =~ /9/ } @$fields; print marcbuild($leader, $fields) if $changed; } \*STDIN; It's meant to be simple (one module, three main functions, ca. 340 LOC total), robust (won't barf on invalid UTF-8 or bad leaders), and *fast* -- but if you prefer an object-oriented interface then it's probably not a good fit. Paul. -- Paul Hoffman <nkui...@nkuitse.com>