View | Details | Raw Unified | Return to bug 20540
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +7 lines)
Lines 2263-2268 sub TransformHtmlToXml { Link Here
2263
    my $prevtag = -1;
2263
    my $prevtag = -1;
2264
    my $first   = 1;
2264
    my $first   = 1;
2265
    my $j       = -1;
2265
    my $j       = -1;
2266
    my $close_last_tag;
2266
    for ( my $i = 0 ; $i < @$tags ; $i++ ) {
2267
    for ( my $i = 0 ; $i < @$tags ; $i++ ) {
2267
2268
2268
        if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and @$tags[$i] eq "100" and @$subfields[$i] eq "a" ) {
2269
        if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and @$tags[$i] eq "100" and @$subfields[$i] eq "a" ) {
Lines 2283-2288 sub TransformHtmlToXml { Link Here
2283
        @$values[$i] =~ s/'/&apos;/g;
2284
        @$values[$i] =~ s/'/&apos;/g;
2284
2285
2285
        if ( ( @$tags[$i] ne $prevtag ) ) {
2286
        if ( ( @$tags[$i] ne $prevtag ) ) {
2287
            $close_last_tag = 0;
2286
            $j++ unless ( @$tags[$i] eq "" );
2288
            $j++ unless ( @$tags[$i] eq "" );
2287
            my $indicator1 = eval { substr( @$indicator[$j], 0, 1 ) };
2289
            my $indicator1 = eval { substr( @$indicator[$j], 0, 1 ) };
2288
            my $indicator2 = eval { substr( @$indicator[$j], 1, 1 ) };
2290
            my $indicator2 = eval { substr( @$indicator[$j], 1, 1 ) };
Lines 2301-2306 sub TransformHtmlToXml { Link Here
2301
                    $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2303
                    $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2302
                    $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2304
                    $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2303
                    $first = 0;
2305
                    $first = 0;
2306
                    $close_last_tag = 1;
2304
                } else {
2307
                } else {
2305
                    $first = 1;
2308
                    $first = 1;
2306
                }
2309
                }
Lines 2320-2325 sub TransformHtmlToXml { Link Here
2320
                        $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2323
                        $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2321
                        $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2324
                        $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2322
                        $first = 0;
2325
                        $first = 0;
2326
                        $close_last_tag = 1;
2323
                    }
2327
                    }
2324
                }
2328
                }
2325
            }
2329
            }
Lines 2339-2351 sub TransformHtmlToXml { Link Here
2339
                if ($first) {
2343
                if ($first) {
2340
                    $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2344
                    $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
2341
                    $first = 0;
2345
                    $first = 0;
2346
                    $close_last_tag = 1;
2342
                }
2347
                }
2343
                $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2348
                $xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
2344
            }
2349
            }
2345
        }
2350
        }
2346
        $prevtag = @$tags[$i];
2351
        $prevtag = @$tags[$i];
2347
    }
2352
    }
2348
    $xml .= "</datafield>\n" if $xml =~ m/<datafield/;
2353
    $xml .= "</datafield>\n" if $close_last_tag;
2349
    if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and !$unimarc_and_100_exist ) {
2354
    if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and !$unimarc_and_100_exist ) {
2350
2355
2351
        #     warn "SETTING 100 for $auth_type";
2356
        #     warn "SETTING 100 for $auth_type";
Lines 2362-2367 sub TransformHtmlToXml { Link Here
2362
    }
2367
    }
2363
    $xml .= "</record>\n";
2368
    $xml .= "</record>\n";
2364
    $xml .= MARC::File::XML::footer();
2369
    $xml .= MARC::File::XML::footer();
2370
    use Data::Printer colored => 1; warn p $xml;
2365
    return $xml;
2371
    return $xml;
2366
}
2372
}
2367
2373
(-)a/t/Biblio/TransformHtmlToXml.t (-7 / +6 lines)
Lines 33-46 sub run_tests { Link Here
33
33
34
    my ( $tags, $subfields );
34
    my ( $tags, $subfields );
35
    if ( $marc_flavour eq 'UNIMARC' ) {
35
    if ( $marc_flavour eq 'UNIMARC' ) {
36
        $tags= [ '001', '600',  '200', '200' ];
36
        $tags= [ '001', '600',  '200', '200', '400' ];
37
        $subfields = [ '', 'a', 'a', 'c' ];
37
        $subfields = [ '', 'a', 'a', 'c', 'a' ];
38
    } else {
38
    } else {
39
        $tags= [ '001', '100',  '245', '245' ];
39
        $tags= [ '001', '100',  '245', '245', '400' ];
40
        $subfields = [ '', 'a', 'a', 'c' ];
40
        $subfields = [ '', 'a', 'a', 'c', 'a' ];
41
    }
41
    }
42
    my $values = [ '12345', 'author', 'title', 'resp' ];
42
    my $values = [ '12345', 'author', 'title', 'resp', '' ];
43
    my $ind = [ '  ', '00', ' 9', '  ' ];
43
    my $ind = [ '  ', '00', ' 9', '  ', ' ' ];
44
44
45
    my $xml = TransformHtmlToXml( $tags, $subfields, $values, $ind, undef, $marc_flavour );
45
    my $xml = TransformHtmlToXml( $tags, $subfields, $values, $ind, undef, $marc_flavour );
46
    my $xmlh = XML::Simple->new->XMLin( $xml );
46
    my $xmlh = XML::Simple->new->XMLin( $xml );
47
- 

Return to bug 20540