Bug 3116 - ISBD parsing does not preserve subfield order
Summary: ISBD parsing does not preserve subfield order
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Bibliographic data support (show other bugs)
Version: Main
Hardware: PC All
: P5 - low enhancement
Assignee: Galen Charlton
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 05:03 UTC by Chris Cormack
Modified: 2018-01-30 23:58 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Add option 'all' to ISBD template (1.84 KB, patch)
2017-02-22 16:47 UTC, Pongtawat
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Cormack 2010-05-21 01:06:34 UTC


---- Reported by rch@liblime.com 2009-04-15 17:03:03 ----

When many subfields exist in a single tag, order is not preserved for ISBD display.  e.g. For 505,

with ISBD definition:  
#505|<br/><br/>|{ 505a }{ 505t }{ 505r }{ 505g }{ 505u }|

MARC: 

505 00 _tExtreme fanfare /
       _rJason Graves
       _g(4:45) --
       _tEntry of the gladiators /
       _rJulius Fucik ; trans. William H. Griffin
       _g(2:57) --

The display improperly groups each ‡t , followed by each ‡r , rather than preserving the subfield order.



---- Additional Comments From paul.poulain@biblibre.com 2009-04-18 21:08:41 ----

the actual ISDB can't preserve subfield order.
From 3 choose one: 
* use $field->as_string = we have subfield preserved, but no ISBD signs like ,.;-
* use what I did, and you loose the subfield order
* completly rewritte the ISBD parser to do something with XSLT

I think the last is the way to go. But it's a lot of work !



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:06 UTC  ---

This bug was previously known as _bug_ 3116 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3116

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was rch@liblime.com.

Comment 1 Mark Tompsett 2015-12-17 04:08:03 UTC
Just need to figure out the other half of that test case, and I'll be able to complete something. :)
Comment 2 Mark Tompsett 2016-02-23 23:50:52 UTC
I don't remember what I was thinking, nor do I understand the problem. Resetting back to defaults.

I don't think

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 10faa83..9a5a372 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -958,11 +958,11 @@ sub GetISBDView {
                   if ( ( $template eq 'opac' )
                     && ( $tagslib->{$fieldvalue}->{$subfvalue}->{'hidden'} || 0 ) > 0 );
                 foreach my $field (@fieldslist) {
+                    my $tag = $field->tag();
                     foreach my $subfield ( $field->subfield($subfvalue) ) {
-                        my $calculated = $analysestring;
-                        my $tag        = $field->tag();
                         if ( $tag < 10 ) {
                         } else {
+                            my $calculated = $analysestring;
                             my $subfieldvalue = GetAuthorisedValueDesc( $tag, $subfvalue, $subfield, '', $tagslib );
                             my $tagsubf = $tag . $subfvalue;
                             $calculated =~ s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
@@ -988,7 +988,16 @@ sub GetISBDView {
                     my $tag        = $field->tag();
                     if ( $tag < 10 ) {
                     } else {
-                        my @subf = $field->subfields;
+                        my @ordered_subfields;
+                        while ($calculated =~ /(\d\d\d)([0-9a-zA-Z])/g) {
+                            push @ordered_subfields,$2;
+                        }
+                        my @subf;
+                        foreach my $subtag (@ordered_subfields) {
+                            foreach my $subfield ($field->subfields) {
+                                push @subf,[@{$subfield}] if $subfield->[0] eq $subtag;
+                            }
+                        }
                         for my $i ( 0 .. $#subf ) {
                             my $valuecode     = $subf[$i][1];
                             my $subfieldcode  = $subf[$i][0];

Was what people were wanting.
Comment 3 Pongtawat 2017-02-22 16:44:28 UTC
I made a patch that add an option "all" to the field list that will show all subfields in order as they appeared in the record, separated by specified separator.

Test
1. Add a MARC record with 650 with some subfields, says a z x a
2. Assume the ISBD preference define template for 650 as follows:

#650|<br/><br/><label>Subjects--Topical Terms: </label>|{\n6503 }{\n650a}{ 650b }{ 650c }{ 650d }{ 650e }{--650x}{--650z}{--650y}{--650v}|

3. Go to ISBD tab, it will show:

Subjects--Topical Terms: 
a--a--x--z

4. Apply patch
5. Go to ISBD tab, it will show the same result as in 3.
6. Change ISBD template for 650 to

#650|<br/><br/><label>Subjects--Topical Terms: </label>|all--|

7. Go to ISBD tab, it will show:

Subjects--Topical Terms: 
a--z--x--a

Separator can be changed to something else, just put it after "all"

(Patch tested on 16.11)
Comment 4 Pongtawat 2017-02-22 16:47:39 UTC
Created attachment 60566 [details] [review]
Add option 'all' to ISBD template
Comment 5 Mark Tompsett 2018-01-30 23:58:52 UTC
This adds functionality to C4::Biblio. It requires tests. None were provided.