Catman...:struct(3pm)

πŸ“¦
version 0.43.0 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Catman...:struct(3pm) πŸ’–

ok so bestie, welcome to the manual page for Catmandu::Importer::SRU::Parser::struct β€” she lives in the Perl user-contributed docs (3pm), and she is exactly the little parser you want when your SRU responses need to become structured XML. sit down, grab a strawberry πŸ“, let's get into it.


✨ NAME ✨

Catmandu::Importer::SRU::Parser::struct β€” the glow-up that transforms SRU responses into structured XML records. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

literally all you do is this:

my $importer = Catmandu::Importer::SRU->new(
    base   => $base,
    query  => $query,
    parser => 'struct'
);

that's it. parser => 'struct' and she's serving structured records. no cap. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

every single SRU response record gets transformed into order-preserving, structured XML, exactly as defined by XML::Struct. so the order stays put, the structure stays cute, and nothing gets rearranged behind your back. iconic behaviour honestly. πŸ‘‘


🌸 CONFIGURATION 🌸

ok so here's the tea β˜• β€” options of XML::Struct::Reader are not supported here. not me being dramatic, that's just the rules.

but bestie, there's a workaround: if you need them, wrap the reader yourself, like this:

my $reader = XML::Struct::Reader->new( %options );

my $importer = Catmandu::Importer::SRU->new(
    base   => $base,
    query  => $query,
    parser => sub {
        $reader->readDocument(
            XML::LibXML::Reader->new( string => $_[0]->{recordData} )
        );
    },

);
πŸ’€ careful with the details here β€” the parser is a sub, the record data comes from $_[0]->{recordData}, and it's fed into XML::LibXML::Reader->new( string => ... ) before hitting $reader->readDocument(...). copy it exactly, don't freestyle. πŸ™ˆ

πŸ’œ AUTHOR πŸ’œ

Jakob Voss β€” "voss@gbv.de" 🫢


🌈 cute sign-off 🌈

and that's the whole page, bestie! this one's from perl v5.38.2, dated 2021-09-02, and it belongs to the Catman...:struct(3pm) manual. now go forth and parse those SRU responses like the main character you are πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from