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

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 737-742 our $PERL_DEPS = { Link Here
737
        'required' => '0',
737
        'required' => '0',
738
        'min_ver'  => '1.17',
738
        'min_ver'  => '1.17',
739
    },
739
    },
740
    'RDF::Trine' => {
741
        'usage'    => 'Core',
742
        'required' => '1',
743
        'min_ver'  => '1.000',
744
    },
740
};
745
};
741
746
742
1;
747
1;
(-)a/C4/Record.pm (-22 / +105 lines)
Lines 25-31 use strict; Link Here
25
# please specify in which methods a given module is used
25
# please specify in which methods a given module is used
26
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
26
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
27
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
27
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
28
use MARC::Crosswalk::DublinCore; # marc2dcxml
28
use Koha::DublinCore; # marc2dcxml
29
use Biblio::EndnoteStyle;
29
use Biblio::EndnoteStyle;
30
use Unicode::Normalize; # _entity_encode
30
use Unicode::Normalize; # _entity_encode
31
use C4::Biblio; #marc2bibtex
31
use C4::Biblio; #marc2bibtex
Lines 219-238 sub marcxml2marc { Link Here
219
219
220
=head2 marc2dcxml - Convert from ISO-2709 to Dublin Core
220
=head2 marc2dcxml - Convert from ISO-2709 to Dublin Core
221
221
222
  my ($error,$dcxml) = marc2dcxml($marc,$qualified);
222
  ($error,$marc) = marc2dcxml($marc, $type, $qualified,
223
                              $entities, $root, $xsi_schemaLocation, $rdf_subject, $rdf_format);
223
224
224
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar
225
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar
225
226
226
FIXME: should return actual XML, not just an object
227
FIXME: should return actual XML, not just an object (Koha::DublinCore return an XML)
227
228
228
C<$marc> - an ISO-2709 scalar or MARC::Record object
229
C<$marc> - an ISO-2709 scalar or MARC::Record object
229
230
230
C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0]
231
C<$type> - the recommendation ( simple-dc-rdf, dc-rdf, dc-xml, oai-dc, srw_dc )
232
233
C<$qualified> - specify whether simple or qualified Dublin Core should be used in output [0 or 1]
234
235
C<$entities> placing entities to 0 will codify only the five basic entities e.g., &lt, &gt, &quot, &amp, and &apos. Conversely if it is encoded to 1, all entities will coded into decimal
236
237
C<$root> root element for XML files
238
239
C<$xsi_schemaLocation> the xsischemaLocation for XML files.
240
241
C<$rdf_subject> Represent the main subject of RDF triples (for Koha the URI of the resource)
242
243
C<$rdf_format> Imply multiple formats for RDF (ntriples, nquads, rdfxml, rdfjson, ntriples-canonical, turtle)
231
244
232
=cut
245
=cut
233
246
234
sub marc2dcxml {
247
sub marc2dcxml {
235
	my ($marc,$qualified) = @_;
248
    my ( $marc, $type, $qualified, $entities, $root, $xsi_schemaLocation, $rdf_subject,
249
        $rdf_format ) = @_;
236
	my $error;
250
	my $error;
237
    # test if it's already a MARC::Record object, if not, make it one
251
    # test if it's already a MARC::Record object, if not, make it one
238
    my $marc_record_obj;
252
    my $marc_record_obj;
Lines 246-269 sub marc2dcxml { Link Here
246
			$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR;
260
			$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR;
247
		}
261
		}
248
	}
262
	}
249
	my $crosswalk = MARC::Crosswalk::DublinCore->new;
263
    my $dcxml;
250
	if ($qualified) {
264
251
		$crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
265
    SWITCH:
252
	}
266
    for ($type) {
253
	my $dcxml = $crosswalk->as_dublincore($marc_record_obj);
267
        if (/^simple-dc-rdf/) {
254
	my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
268
            my $objectDC = Koha::DublinCore->new({
255
	$dcxmlfinal .= "<metadata
269
                type            => 'rdf',
256
  xmlns=\"http://example.org/myapp/\"
270
                qualified       => 0,
257
  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
271
                get_marc_record => $marc,
258
  xsi:schemaLocation=\"http://example.org/myapp/ http://example.org/myapp/schema.xsd\"
272
            });
259
  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
273
260
  xmlns:dcterms=\"http://purl.org/dc/terms/\">";
274
            $objectDC->get_rdf_data({
261
275
                rdf_subject => $rdf_subject,
262
	foreach my $element ( $dcxml->elements() ) {
276
                rdf_format  => $rdf_format,
263
                $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n";
277
                entities    => 1,
278
            });
279
            $dcxml = $objectDC->write_rdf();
280
            last SWITCH;
281
        }
282
        if (/^dc-rdf/) {
283
            my $objectDC = Koha::DublinCore->new({
284
                type            => 'rdf',
285
                qualified       => 1,
286
                get_marc_record => $marc,
287
            });
288
289
            $objectDC->get_rdf_data({
290
                rdf_subject => $rdf_subject,
291
                rdf_format  => $rdf_format,
292
                entities    => 1,
293
            });
294
            $dcxml = $objectDC->write_rdf();
295
            last SWITCH;
296
        }
297
        if (/^dc-xml/) {
298
            my $objectDC = Koha::DublinCore->new({
299
                type            => 'xml',
300
                qualified       => $qualified,
301
                get_marc_record => $marc,
302
            });
303
304
            $objectDC->get_xml_data({
305
                root               => $root,
306
                xsi_schemaLocation => $xsi_schemaLocation,
307
                entities           => 1,
308
            });
309
            $dcxml = $objectDC->write_xml();
310
            last SWITCH;
311
        }
312
        if (/^oai-dc/) {
313
            my $objectDC = Koha::DublinCore->new({
314
                type            => 'xml',
315
                qualified       => 0,
316
                get_marc_record => $marc,
317
            });
318
319
            $objectDC->get_xml_data({
320
                root               => 'oai_dc:dc',
321
                xsi_schemaLocation => 'http://www.openarchives.org/OAI/2.0/oai_dc/' .
322
                                      ' http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
323
                entities           => 0,
324
                opt_namespace      => 'oai_dc',
325
                opt_namespace_url  => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
326
            });
327
            $dcxml = $objectDC->write_xml();
328
            last SWITCH;
329
        }
330
        if (/^srw_dc/) {
331
            my $objectDC = Koha::DublinCore->new({
332
                type            => 'xml',
333
                qualified       => 0,
334
                get_marc_record => $marc,
335
            });
336
337
            $objectDC->get_xml_data({
338
                root               => 'srw_dc:dc',
339
                xsi_schemaLocation => 'info:srw/schema/1/dc-schema' .
340
                                      ' http://www.loc.gov/standards/sru/resources/dc-schema.xsd',
341
                entities           => 0,
342
                opt_namespace      => 'srw_dc',
343
                opt_namespace_url  => 'info:srw/schema/1/dc-schema',
344
            });
345
            $dcxml = $objectDC->write_xml();
346
            last SWITCH;
347
        }
264
    }
348
    }
265
	$dcxmlfinal .= "\n</metadata>";
349
    return ( $error, $dcxml );
266
	return ($error,$dcxmlfinal);
267
}
350
}
268
351
269
=head2 marc2modsxml - Convert from ISO-2709 to MODS
352
=head2 marc2modsxml - Convert from ISO-2709 to MODS
(-)a/Koha/DublinCore.pm (+992 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
package Koha::DublinCore;
3
4
#
5
# This file is part of Koha.
6
#
7
# Copyright (C) 2014 Universidad de El Salvador,
8
# Facultad Multidisciplinaria Oriental
9
#
10
# Koha is free software; you can redistribute it and/or modify it
11
# under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# Koha is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
#
23
24
use Modern::Perl;
25
use strict;
26
use warnings::register;
27
use utf8;
28
use version;
29
30
BEGIN {
31
    require Exporter;
32
33
    # set the version for version checking
34
    our $VERSION = version->declare("v0.01");
35
36
    # Inherit from Exporter to export functions and variables
37
    our @ISA = qw(Exporter);
38
39
    # Functions and variables which are exported by default
40
    our @EXPORT = qw(new get_xml_data get_rdf_data write_xml write_rdf);
41
42
    # Functions and variables which can be optionally exported
43
    our @EXPORT_OK =
44
      qw(type qualified get_marc_record root xsi_schemaLocation rdf_subject rdf_format opt_namespace opt_namespace_url);
45
46
}
47
48
use MARC::File::USMARC;
49
use MARC::Crosswalk::DublinCore;
50
use XML::LibXML;
51
use C4::Record;
52
use RDF::Trine;
53
use base qw(Class::Accessor);
54
__PACKAGE__->mk_accessors(
55
    qw(type qualified get_marc_record root xsi_schemaLocation rdf_subject rdf_format entities opt_namespace opt_namespace_url)
56
);
57
58
# Defining some constants
59
my $xsi_schema  = qq(http://www.w3.org/2001/XMLSchema-instance);
60
my $unqualified = qq(http://purl.org/dc/elements/1.1/);
61
my $qualified   = qq(http://purl.org/dc/terms/);
62
my $dcam        = qq(http://purl.org/dc/dcam/);
63
my $rdfNS       = qq(http://www.w3.org/1999/02/22-rdf-syntax-ns#);
64
my @elementupcase =
65
  qw/tableOfContents dateAccepted dateCopyrighted dateSubmitted isVersionOf hasVersion isReplacedBy isRequiredBy isPartOf hasPart isReferencedBy isFormatOf hasFormat conformsTo accrualMethod accrualPeriodicity accrualPolicy instructionalMethod rightsHolder educationLevel accessRights bibliographicCitation/;
66
my $map;
67
68
#USAGE: Koha::DublinCore->new({
69
#    type => 'xml|rdf',
70
#    qualified => 0|1,
71
#    get_marc_record => $record
72
#});
73
74
sub new {
75
    my ( $class, $args ) = @_;
76
    $args = {} unless defined $args;
77
    return bless( $args, $class );
78
}
79
80
sub get_xml_data {
81
82
#USAGE: oop->get_xml_data({
83
#        root => 'root',
84
#        xsi_schemaLocation => 'http://example.org/myapp/ http://example.org/myapp/schema.xsd',
85
#        entities => 0|1,
86
#        opt_namespace => 'oai_dc'
87
#        opt_namespace_url => 'http://www.openarchives.org/OAI/2.0/oai_dc/'
88
#});
89
    my $self = shift;
90
    my ($args) = @_;
91
92
    if (@_) {
93
        $self->root( $args->{root} );
94
        $self->xsi_schemaLocation( $args->{xsi_schemaLocation} );
95
        $self->entities( $args->{entities} );
96
        $self->opt_namespace( $args->{opt_namespace} );
97
        $self->opt_namespace_url( $args->{opt_namespace_url} );
98
    }
99
100
    #if data not filled
101
    $self->{root}     = "metadata" unless ( defined $self->{root} );
102
    $self->{entities} = 0          unless ( defined $self->{entities} );
103
    my %dataxml = (
104
        xmlroot            => $self->{root},
105
        entities           => $self->{entities},
106
        opt_namespace => $self->{opt_namespace},
107
        opt_namespace_url      => $self->{opt_namespace_url},
108
    );
109
110
    if ( exists $self->{xsi_schemaLocation} ) {
111
        $dataxml{'xsi_schemaLocation'} = $self->{xsi_schemaLocation};
112
    }
113
    if ( exists $self->{xsi_schemaLocation} ) {
114
        $dataxml{'opt_namespace'} = $self->{opt_namespace};
115
    }
116
    if ( exists $self->{xsi_schemaLocation} ) {
117
        $dataxml{'opt_namespace_url'} = $self->{opt_namespace_url};
118
    }
119
    return \%dataxml;
120
}
121
122
sub get_rdf_data {
123
124
#USAGE: oop->get_rdf_data({
125
#        rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
126
#        rdf_format => 'ntriples | nquads| rdfxml | rdfjson | ntriples-canonical | turtle',
127
#        entities => 0|1,
128
#})
129
130
    my $self = shift;
131
    my ($args) = @_;
132
133
    if (@_) {
134
        $self->rdf_subject( $args->{rdf_subject} );
135
        $self->rdf_format( $args->{rdf_format} );
136
        $self->entities( $args->{entities} );
137
    }
138
139
    #if data not filled
140
    $self->{rdf_subject} = "http://koha-community.org/"
141
      unless ( defined $self->{rdf_subject} );
142
    $self->{rdf_format} = "rdfxml" unless ( defined $self->{rdf_format} );
143
    $self->{entities}   = 0        unless ( defined $self->{entities} );
144
    my %rdfdescription = (
145
        rdf_subject => $self->{rdf_subject},
146
        rdf_format  => $self->{rdf_format},
147
        entities    => $self->{entities},
148
    );
149
150
    return \%rdfdescription;
151
}
152
153
sub conversion_to_dc {
154
155
#Get the MARC record and return a Dublin Core elements, passed as argument in dc_order_execution method.
156
#USAGE:
157
#my dc = $self->conversion_to_dc();
158
#$self->dc_order_execution ($dc, $dcxml, $root);
159
    my $self            = shift;
160
    my $marc_record_obj = $self->get_marc_record();
161
    my $crosswalk;
162
    my $dc;
163
164
    #if data not filled
165
    $self->qualified(0) unless ( exists $self->{qualified} );
166
    if ( ( $self->qualified() != 0 and $self->qualified() != 1 )
167
        && warnings::enabled($self) )
168
    {
169
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
170
        die "Set qualified => " . $self->qualified() . " is no good, stopped";
171
    }
172
    if ( $self->qualified() == 1 ) {
173
        $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
174
    }
175
    elsif ( $self->qualified() == 0 ) {
176
        $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 0 );
177
    }
178
    if ( $marc_record_obj =~ /^MARC::Record/ ) {
179
        $dc = $crosswalk->as_dublincore($marc_record_obj);
180
    }
181
    else {
182
        warnings::warn( $self,
183
            "MARC::Record object failed or not a MARC::Record" );
184
        die "Stopped due get_marc_record => is not a MARC::Record";
185
    }
186
187
    return $dc;
188
189
}
190
191
sub write_xml {
192
    my $self    = shift;
193
    my $dataxml = $self->get_xml_data();
194
    my $dc      = $self->conversion_to_dc();
195
196
    #Looking for bad data
197
    if ( ( $self->type() ne 'xml' and $self->type() ne 'rdf' )
198
        && warnings::enabled($self) )
199
    {
200
        warnings::warn( $self, "Only the xml or rdf values are accepted" );
201
        die "Set type => " . $self->type() . " is no good, stopped";
202
    }
203
    elsif ( $self->type() eq 'rdf' && warnings::enabled($self) ) {
204
        warnings::warn( $self, "The constructor specified rdf" );
205
        die "Cannot use this method with rdf. This is no good, stopped";
206
    }
207
208
    if ( ( $self->entities() != 0 and $self->entities() != 1 )
209
        && warnings::enabled($self) )
210
    {
211
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
212
        die "Set entities => " . $self->entities() . " is no good, stopped";
213
    }
214
215
    #Creating XML object
216
    my $doc = XML::LibXML::Document->new( '1.0', 'utf-8' );
217
    my $root = $doc->createElement( $dataxml->{'xmlroot'} );
218
    $root->setNamespace( $xsi_schema, 'xsi', 0 );
219
220
    if ( defined $dataxml->{'opt_namespace'} ) {
221
        $root->setNamespace( $dataxml->{'opt_namespace_url'},
222
            $dataxml->{'opt_namespace'}, 0 );
223
    }
224
225
    if ( $self->type() eq 'xml' ) {
226
        if ( $self->qualified() == 0 ) {
227
            if ( defined $dataxml->{'xsi_schemaLocation'} ) {
228
                $root->setAttribute(
229
                    'xsi:schemaLocation' => $dataxml->{'xsi_schemaLocation'} );
230
                $root->setNamespace( $unqualified, 'dc', 0 );
231
                $self->dc_order_execution( $dc, $doc, $root );
232
            }
233
            else {
234
                $root->setNamespace( $unqualified, 'dc', 0 );
235
                $self->dc_order_execution( $dc, $doc, $root );
236
            }
237
        }
238
        elsif ( $self->qualified() == 1 ) {
239
            if ( defined $dataxml->{'xsi_schemaLocation'} ) {
240
                $root->setAttribute(
241
                    'xsi:schemaLocation' => $dataxml->{'xsi_schemaLocation'} );
242
                $root->setNamespace( $unqualified, 'dc',      0 );
243
                $root->setNamespace( $qualified,   'dcterms', 0 );
244
                $self->dc_order_execution( $dc, $doc, $root );
245
            }
246
            else {
247
                $root->setNamespace( $unqualified, 'dc',      0 );
248
                $root->setNamespace( $qualified,   'dcterms', 0 );
249
                $self->dc_order_execution( $dc, $doc, $root );
250
            }
251
        }
252
    }
253
254
    $doc->setDocumentElement($root);
255
256
    #Enabling or desabling entities and print the xml and, decoding string to utf8
257
    if ( $dataxml->{'entities'} == 1 ) {
258
        my $serialized_data = $doc->toString(1);
259
        utf8::decode($serialized_data);
260
        my ($dcxml_entity_encoded) = C4::Record::_entity_encode($serialized_data);
261
        $serialized_data = $dcxml_entity_encoded;
262
        return $serialized_data;
263
    }
264
    else {
265
        return $doc->toString(1);
266
    }
267
}
268
269
sub write_rdf {
270
    my $self           = shift;
271
    my $rdfdescription = $self->get_rdf_data();
272
    my $dc             = $self->conversion_to_dc();
273
    my $serializer;
274
    my %namespaces;
275
276
    #Looking for bad data
277
    if ( ( $self->type() ne 'xml' and $self->type() ne 'rdf' )
278
        && warnings::enabled($self) )
279
    {
280
        warnings::warn( $self, "Only the xml or rdf values are accepted" );
281
        die "Set type => " . $self->type() . " is no good, stopped";
282
    }
283
    elsif ( $self->type() eq 'xml' && warnings::enabled($self) ) {
284
        warnings::warn( $self, "The constructor specified xml" );
285
        die "Cannot use this method with xml. This is no good, stopped";
286
    }
287
288
    if ( ( $self->entities() != 0 and $self->entities() != 1 )
289
        && warnings::enabled($self) )
290
    {
291
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
292
        die "Set entities => " . $self->entities() . " is no good, stopped";
293
    }
294
295
    # Creating the triple store in temporary data
296
    my $store = RDF::Trine::Store::Memory->new();
297
298
    # Creating the model
299
    my $rdf = RDF::Trine::Model->new($store);
300
301
    # Creating the subject
302
    my $subject =
303
      RDF::Trine::Node::Resource->new( $rdfdescription->{'rdf_subject'} );
304
305
    $namespaces{'rdf'} = $rdfNS;
306
307
    if ( $self->qualified() == 0 ) {
308
309
        # Declaring all namespaces in a hash
310
        $namespaces{'dc'} = $unqualified;
311
    }
312
    else {
313
314
        # Declaring all namespaces in a hash
315
        $namespaces{'dcterms'} = $qualified;
316
        $namespaces{'dcam'}    = $dcam;
317
    }
318
319
    # Creating namespaces
320
    $map = RDF::Trine::NamespaceMap->new( \%namespaces );
321
322
    if ( $self->type() eq 'rdf' ) {
323
        $self->dc_order_execution( $dc, $rdf, $subject );
324
    }
325
326
   #Enabling or desabling entities and print the xml and, decoding string to utf8
327
    if ( $rdfdescription->{'rdf_format'} eq 'rdfxml' ) {
328
        if ( $rdfdescription->{'entities'} == 1 ) {
329
            $serializer =
330
              RDF::Trine::Serializer::RDFXML->new(
331
                namespaces => {%namespaces} );
332
            my $serialized_data = $serializer->serialize_model_to_string($rdf);
333
            utf8::decode($serialized_data);
334
            my ($dcxml_entity_encoded) = C4::Record::_entity_encode($serialized_data);
335
            return $serialized_data = $dcxml_entity_encoded;
336
        }
337
        else {
338
            $serializer =
339
              RDF::Trine::Serializer::RDFXML->new(
340
                namespaces => {%namespaces} );
341
            return $serializer->serialize_model_to_string($rdf);
342
        }
343
    }
344
    elsif ( $rdfdescription->{'rdf_format'} eq 'turtle' ) {
345
        $serializer =
346
          RDF::Trine::Serializer::Turtle->new( namespaces => {%namespaces} );
347
        return $serializer->serialize_model_to_string($rdf);
348
    }
349
    else {
350
        $serializer =
351
          RDF::Trine::Serializer->new( $rdfdescription->{'rdf_format'} );
352
        return $serializer->serialize_model_to_string($rdf);
353
    }
354
}
355
356
sub upper_or_lowercase {
357
358
#This subroutine define if is necessary to convert lowercase some qualifiers or let them as crosswalk method basis
359
#USAGE: upper_or_lowercase (element->qualifier())
360
    my $dcelement = $_[0];
361
    my $count     = 0;
362
    my $result;
363
    while ( $count <= $#elementupcase ) {
364
        if ( $elementupcase[$count] eq $dcelement ) {
365
            $result = $dcelement;
366
            last;
367
        }
368
        elsif ( $dcelement ne $elementupcase[$count] ) {
369
            $result = lc($dcelement);
370
            $count++;
371
            next;
372
        }
373
    }
374
375
    return $result;
376
377
}
378
379
sub xml_constructor {
380
381
#xml_constructor ( doc, root, namespace, attr, element_name, element_content, element_qualifier, element_scheme )
382
#USAGE: define all posible elements (name, content, qualifier, scheme) as neccesary
383
#doc: the XML object
384
#root: append root to doc
385
#namespace: defined as "dc" or "dcterms"
386
#attr: a boolean value to determinate xsi:type xml namespace for dcterms
387
#examples:
388
#xml_constructor ( $dcxml, $root, "dc", 0, element->name(), element->content() );
389
#xml_constructor ( $dcxml, $root, "dcterms", 1, element->name(), element->content(), $element->qualifier() );
390
391
    my ( $doc, $root, $namespace, $attr, $element_name, $element_content,
392
        $element_qualifier, $element_scheme )
393
      = @_;
394
395
    # This scalar is used for deleting spaces in scheme elements
396
    my $deletespaces;
397
398
    # This scalar is used for making upper or lowercase the qualifier elements
399
    my $lowercase;
400
    my $tagxml;
401
402
    if ( $namespace eq "dc" ) {
403
        $lowercase = lc($element_name);
404
    }
405
    elsif ( $namespace eq "dcterms" ) {
406
        $lowercase = upper_or_lowercase($element_qualifier);
407
408
        #replacing spacial to spatial, bug from dublin or crosswalk.
409
        $lowercase =~ s/spacial/spatial/;
410
    }
411
412
    if ( ( $namespace eq "dc" or "dcterms" ) and $attr == 0 ) {
413
414
        # This will do something like: <dc:title>Title</dc:title>
415
        $tagxml = XML::LibXML::Element->new($lowercase);
416
        $tagxml->setNamespace( undef, $namespace, 1 );
417
        $tagxml->appendTextNode($element_content);
418
        $root->appendChild($tagxml);
419
    }
420
    elsif ( ( $namespace eq "dcterms" ) and $attr == 1 ) {
421
422
# This will do something like: <dcterms:spatial xsi:type="dcterms:ISO3166">us</dcterms:spatial>
423
        $deletespaces = $element_scheme;
424
        $deletespaces =~ s/\s//;
425
        $tagxml = XML::LibXML::Element->new($lowercase);
426
        $tagxml->setNamespace( undef, $namespace, 1 );
427
        my $attribute = $namespace . ':' . $deletespaces;
428
        $tagxml->setAttribute( 'xsi:type', $attribute );
429
        $tagxml->appendTextNode($element_content);
430
        $root->appendChild($tagxml);
431
    }
432
    elsif ( ( $namespace eq "dc" ) and $attr == 1 ) {
433
434
# This will do something like: <dc:subject xsi:type="dcterms:LCSH">Water supply.</dc:subject>
435
            if ( $element_scheme ne "DCMI Type Vocabulary" )
436
            {    #Dublin core returns DCMI Type Vocabulary
437
                $deletespaces = $element_scheme;
438
                $deletespaces =~ s/\s//;
439
                $tagxml = XML::LibXML::Element->new($lowercase);
440
                $tagxml->setNamespace( undef, $namespace, 1 );
441
                my $attribute = 'dcterms:' . $deletespaces;
442
                $tagxml->setAttribute( 'xsi:type', $attribute );
443
                $tagxml->appendTextNode($element_content);
444
                $root->appendChild($tagxml);
445
            }
446
            elsif ( $element_scheme eq "DCMI Type Vocabulary" )
447
            {    #Changing for DCMIType
448
                 # This will do something like: <dc:type xsi:type="dcterms:DCMIType">Text</dc:type>
449
                $tagxml = XML::LibXML::Element->new($lowercase);
450
                $tagxml->setNamespace( undef, $namespace, 1 );
451
                $tagxml->setAttribute( 'xsi:type', 'dcterms:DCMIType' );
452
                $tagxml->appendTextNode($element_content);
453
                $root->appendChild($tagxml);
454
            }
455
    }    #if...elsif
456
457
    return $tagxml;
458
459
}    #subroutine
460
461
sub rdf_constructor {
462
463
#xml_constructor ( rdf, subject, namespace, attr, element_name, element_content, element_qualifier, element_scheme )
464
#USAGE: define all posible elements (name, content, qualifier, scheme) as neccesary
465
#rdf: the RDF object
466
#subject: the subject for the triples
467
#namespace: defined as "dc" or "dcterms". This is for Simple DC or DC-RDF recommendations.
468
#attr: a boolean value to determine the nodeID attribute for dcterms
469
470
    my ( $rdf, $subject, $namespace, $attr, $element_name, $element_content,
471
        $element_qualifier, $element_scheme )
472
      = @_;
473
474
    #This scalar is used for deleting spaces in scheme elements
475
    my $deletespaces;
476
477
    #This scalar is used for making upper or lowercase the qualifier elements
478
    my $lowercase;
479
480
    if ( $namespace eq "dc" ) {
481
        $lowercase = lc($element_name);
482
    }
483
    elsif ( $namespace eq "dcterms" ) {
484
        $lowercase = upper_or_lowercase($element_qualifier);
485
486
        #replacing spacial to spatial, bug from dublin or crosswalk.
487
        $lowercase =~ s/spacial/spatial/;
488
    }
489
490
    if ( ( $namespace eq "dc" or "dcterms" ) and $attr == 0 ) {
491
492
        # This will do something like: <dc:title>Title</dc:title>
493
        my $predicate = undef;
494
        if ( $namespace eq "dc" ) {
495
            $predicate = $map->dc($lowercase);
496
        }
497
        else {
498
            $predicate = $map->dcterms($lowercase);
499
        }
500
        my $object = RDF::Trine::Node::Literal->new($element_content);
501
        my $statement =
502
          RDF::Trine::Statement->new( $subject, $predicate, $object );
503
        $rdf->add_statement($statement);
504
    }
505
    elsif ( ( $namespace eq "dc" ) and $attr == 2 ) {
506
507
        # This will do something like: <dcterms:title>Title</dcterms:title>
508
        my $predicate = $map->dcterms($lowercase);
509
        my $object    = RDF::Trine::Node::Literal->new($element_content);
510
        my $statement =
511
          RDF::Trine::Statement->new( $subject, $predicate, $object );
512
        $rdf->add_statement($statement);
513
    }
514
    elsif ( ( $namespace eq "dc" ) and $attr == 1 ) {
515
        $deletespaces = $element_scheme;
516
        $deletespaces =~ s/\s//;
517
      SWITCH:
518
        for ($element_scheme) {
519
            if (/^ISO 3166/) {
520
521
       #  Dublin core returns DCMI Type Vocabulary
522
       #  This will do something like:
523
       #    <rdf:Description rdf:nodeID="country">
524
       #        <dcam:memberOf rdf:resource="http://purl.org/dc/terms/ISO3166"/>
525
       #        <rdf:value>us</rdf:value>
526
       #    </rdf:Description>
527
       #    <dcterms:spatial rdf:nodeID="country"/>
528
                my $objectbnode = RDF::Trine::Node::Blank->new('country');
529
                my $predicate   = $map->dcterms($lowercase);
530
                my $object = RDF::Trine::Node::Literal->new($element_content);
531
                my $dcam_member_of  = $map->dcam('memberOf');
532
                my $resource_schema = $map->dcterms($deletespaces);
533
                my $rdf_value       = $map->rdf('value');
534
                my $statement1 =
535
                  RDF::Trine::Statement->new( $subject, $predicate,
536
                    $objectbnode );
537
                my $statement2 =
538
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
539
                    $resource_schema );
540
                my $statement3 =
541
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
542
                    $object );
543
                $rdf->add_statement($statement1);
544
                $rdf->add_statement($statement2);
545
                $rdf->add_statement($statement3);
546
                last SWITCH;
547
            }
548
            if (/^DCMI Type Vocabulary/) {    #Changing for DCMIType
549
                my $objectbnode = RDF::Trine::Node::Blank->new('DCMIType');
550
                my $predicate   = $map->dcterms($lowercase);
551
                my $object = RDF::Trine::Node::Literal->new($element_content);
552
                my $dcam_member_of  = $map->dcam('memberOf');
553
                my $resource_schema = $map->dcterms('DCMIType');
554
                my $rdf_value       = $map->rdf('value');
555
                my $statement1 =
556
                  RDF::Trine::Statement->new( $subject, $predicate,
557
                    $objectbnode );
558
                my $statement2 =
559
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
560
                    $resource_schema );
561
                my $statement3 =
562
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
563
                    $object );
564
                $rdf->add_statement($statement1);
565
                $rdf->add_statement($statement2);
566
                $rdf->add_statement($statement3);
567
                last SWITCH;
568
            }
569
            if (/^ISO 639-2/) {    #Changing bnodeId ISO639-2 for language
570
                my $objectbnode = RDF::Trine::Node::Blank->new('language');
571
                my $predicate   = $map->dcterms($lowercase);
572
                my $object = RDF::Trine::Node::Literal->new($element_content);
573
                my $dcam_member_of  = $map->dcam('memberOf');
574
                my $resource_schema = $map->dcterms($deletespaces);
575
                my $rdf_value       = $map->rdf('value');
576
                my $statement1 =
577
                  RDF::Trine::Statement->new( $subject, $predicate,
578
                    $objectbnode );
579
                my $statement2 =
580
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
581
                    $resource_schema );
582
                my $statement3 =
583
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
584
                    $object );
585
                $rdf->add_statement($statement1);
586
                $rdf->add_statement($statement2);
587
                $rdf->add_statement($statement3);
588
                last SWITCH;
589
            }
590
            if (/^RFC 1766/) {    #Changing bnodeId RFC1766 for languagetag
591
                my $objectbnode = RDF::Trine::Node::Blank->new('languagetag');
592
                my $predicate   = $map->dcterms($lowercase);
593
                my $object = RDF::Trine::Node::Literal->new($element_content);
594
                my $dcam_member_of  = $map->dcam('memberOf');
595
                my $resource_schema = $map->dcterms($deletespaces);
596
                my $rdf_value       = $map->rdf('value');
597
                my $statement1 =
598
                  RDF::Trine::Statement->new( $subject, $predicate,
599
                    $objectbnode );
600
                my $statement2 =
601
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
602
                    $resource_schema );
603
                my $statement3 =
604
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
605
                    $object );
606
                $rdf->add_statement($statement1);
607
                $rdf->add_statement($statement2);
608
                $rdf->add_statement($statement3);
609
                last SWITCH;
610
            }
611
            if ( /^LCSH/ || /^MeSH/ || /^LCC/ || /^DDC/ ||
612
                 /^UDC/ || /^IMT/ || /^URI/ || /^TGN/ )
613
            {    #Scheme sharing common elements
614
                my $objectbnode = RDF::Trine::Node::Blank->new($deletespaces);
615
                my $predicate   = $map->dcterms($lowercase);
616
                my $object = RDF::Trine::Node::Literal->new($element_content);
617
                my $dcam_member_of  = $map->dcam('memberOf');
618
                my $resource_schema = $map->dcterms($deletespaces);
619
                my $rdf_value       = $map->rdf('value');
620
                my $statement1 =
621
                  RDF::Trine::Statement->new( $subject, $predicate,
622
                    $objectbnode );
623
                my $statement2 =
624
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
625
                    $resource_schema );
626
                my $statement3 =
627
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
628
                    $object );
629
                $rdf->add_statement($statement1);
630
                $rdf->add_statement($statement2);
631
                $rdf->add_statement($statement3);
632
                last SWITCH;
633
            }
634
        }
635
    }    #if-elsif
636
    return $rdf;
637
}    #subroutine
638
639
sub dc_order_execution {
640
641
    #USAGE: USAGE: Get the parameters for xml or rdf and execute in order.
642
    my $self = shift;
643
644
    if ( $self->type() eq 'xml' ) {    #Order for xml
645
        my ( $dc, $dcxml, $root ) = @_;
646
        foreach my $element ( $dc->elements() ) {
647
          SWITCH: {
648
                if (    $element->name()
649
                    and not defined $element->scheme()
650
                    and not defined $element->qualifier() )
651
                {
652
                    $dcxml =
653
                      xml_constructor( $dcxml, $root, "dc", 0, $element->name(),
654
                        $element->content() );
655
                    last SWITCH;
656
                }
657
658
                if (    $element->name()
659
                    and not defined $element->scheme()
660
                    and not defined $element->qualifier() )
661
                {
662
                    $dcxml =
663
                      xml_constructor( $dcxml, $root, "dcterms", 0,
664
                        $element->name(), $element->content() );
665
                    last SWITCH;
666
                }
667
668
                if (    $element->name()
669
                    and $element->scheme()
670
                    and $element->qualifier() )
671
                {
672
                    $dcxml = xml_constructor(
673
                        $dcxml,                $root,
674
                        "dcterms",             1,
675
                        $element->name(),      $element->content(),
676
                        $element->qualifier(), $element->scheme()
677
                    );
678
                    last SWITCH;
679
                }
680
681
                if (    $element->name()
682
                    and $element->scheme()
683
                    and ( $element->scheme ne "DCMI Type Vocabulary" ) )
684
                {
685
                    $dcxml =
686
                      xml_constructor( $dcxml, $root, "dc", 1, $element->name(),
687
                        $element->content(), $element->qualifier(),
688
                        $element->scheme() );
689
                    last SWITCH;
690
                }
691
692
                if (    $element->name()
693
                    and $element->scheme()
694
                    and ( $element->scheme() eq "DCMI Type Vocabulary" ) )
695
                {
696
                    $dcxml =
697
                      xml_constructor( $dcxml, $root, "dc", 1, $element->name(),
698
                        $element->content(), $element->qualifier(),
699
                        $element->scheme() );
700
                    last SWITCH;
701
                }
702
703
                if ( $element->name() and $element->qualifier() ) {
704
                    $dcxml = xml_constructor(
705
                        $dcxml,                $root,
706
                        "dcterms",             0,
707
                        $element->name(),      $element->content(),
708
                        $element->qualifier(), $element->scheme()
709
                    );
710
                    last SWITCH;
711
                }    #if
712
            }    #SWITCH
713
        }    #foreach 1
714
    }
715
    elsif ( $self->type() eq 'rdf' ) {    #Order for rdf/xml
716
        my ( $dc, $rdf, $subject ) = @_;
717
        foreach my $element ( $dc->elements() ) {
718
          SWITCH: {
719
                if (    $element->name()
720
                    and not defined $element->scheme()
721
                    and not defined $element->qualifier() )
722
                {
723
                    rdf_constructor( $rdf, $subject, "dc", 0, $element->name(),
724
                        $element->content() )
725
                      unless $self->qualified() == 1;
726
                    rdf_constructor( $rdf, $subject, "dc", 2, $element->name(),
727
                        $element->content() )
728
                      unless $self->qualified() == 0;
729
                    last SWITCH;
730
                }
731
732
                if (    $element->name()
733
                    and $element->scheme()
734
                    and ( $element->scheme ne "DCMI Type Vocabulary" ) )
735
                {
736
                    rdf_constructor( $rdf, $subject, "dc", 1, $element->name(),
737
                        $element->content(), $element->qualifier(),
738
                        $element->scheme() );
739
                    last SWITCH;
740
                }
741
742
                if (    $element->name()
743
                    and $element->scheme()
744
                    and ( $element->scheme() eq "DCMI Type Vocabulary" ) )
745
                {
746
                    rdf_constructor( $rdf, $subject, "dc", 1, $element->name(),
747
                        $element->content(), $element->qualifier(),
748
                        $element->scheme() );
749
                    last SWITCH;
750
                }
751
752
                if ( $element->name() and $element->qualifier() ) {
753
                    rdf_constructor(
754
                        $rdf,                  $subject,
755
                        "dcterms",             0,
756
                        $element->name(),      $element->content(),
757
                        $element->qualifier(), $element->scheme()
758
                    );
759
                    last SWITCH;
760
                }    #if
761
            }    #SWITCH
762
        }    #foreach 2
763
    }
764
    return;
765
}
766
767
END {
768
769
    #When opened with MARC::File::USMARC, close marc record if not closed
770
    sub DESTROY {
771
        my $self = shift;
772
        if ( $self->{get_marc_record} =~ /^MARC:File::USMARC/ ) {
773
            $self->{get_marc_record}->close();
774
            undef $self->{get_marc_record};
775
        }
776
    }
777
}
778
1;
779
__END__
780
781
=pod
782
783
=encoding UTF-8
784
785
=head1 NAME
786
787
Koha::DublinCore - transform the values of MARC::Crosswalk::DublinCore
788
into metadata in XML or RDF format.
789
790
=head1 SYNOPSIS
791
792
=head2 XML-DC
793
794
  use Koha::DublinCore;
795
  use MARC::File::USMARC;
796
  my $batch = MARC::File::USMARC->in('in.mrc');
797
798
  ## the $record will be a MARC::Record object.
799
  my $record = $batch->next();
800
801
  #For Simple DC-XML
802
  my $objectDC = Koha::DublinCore->new({
803
        type => 'xml',
804
        qualified => 0,
805
        get_marc_record => $record});
806
807
  #For Qualified DC-XML
808
  my $objectDC = Koha::DublinCore->new({
809
        type => 'xml',
810
        qualified => 1,
811
        get_marc_record => $record});
812
813
  #After call constructor you need to pass the root element and
814
  #the schema in .xsd format. If you prefer or you don't know nothing
815
  #about it pass the method in blank, i.e., without arguments.
816
  #Also you can determine if you want to encode with xml entities or
817
  #just with the five basics entities.
818
  #Set entities to 0 for the five basics or 1 to encode with the
819
  #complete xml entities.
820
  $objectDC->get_xml_data({
821
        root => 'metadata',
822
        xsi_schemaLocation => 'http://example.org/myapp/' .
823
                              ' http://example.org/myapp/schema.xsd',
824
  });
825
  #This print your xml file in STDOUT
826
  my $XML-DC = $objectDC->write_xml();
827
  print $XML-DC;
828
829
  #Close the file according to MARC::File::USMARC
830
  $batch->close();
831
  undef $batch;
832
833
  #Or if you want to generate a file
834
  open (OUTPUT, '> dc2xml.xml') or die $!;
835
  print OUTPUT $XML-DC;
836
  close(OUTPUT);
837
838
=head2 DC-RDF
839
840
  use Koha::DublinCore;
841
  use MARC::File::USMARC;
842
  my $marc = MARC::File::USMARC->in('in.mrc');
843
  my $record = $marc->next();
844
845
  #Simple DC-RDF is not used but not deprecated, DublinCore
846
  #can generate it as follow:
847
  my $objectDC = Koha::DublinCore->new({
848
        type => 'rdf',
849
        qualified => 0,
850
        get_marc_record => $record});
851
852
  #DC-RDF
853
  my $objectDC = Koha::DublinCore->new({
854
        type => 'rdf',
855
        qualified => 1,
856
        get_marc_record => $record});
857
858
  #The get_rdf_data method for RDF does not need to use the root element
859
  #and the schema, but you need to declare the resource being described,
860
  #i.e., the record.
861
  #Note: For Koha is the IRI identifier of the record
862
  $objectDC->get_rdf_data({
863
        rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
864
  });
865
866
  my $XML-RDF = $objectDC->write_rdf();
867
  print $XML-RDF;
868
  #Close the file according to MARC::File::USMARC
869
  $batch->close();
870
  undef $marc;
871
872
=head1 DESCRIPTION
873
874
The Koha::DublinCore defines the interface to transform
875
and manipulate MARC records into DC-XML or DC-RDF recommendation.
876
This package transform MARC records to XML or RDF/XML Dublin Core
877
and follows the recommendations listed below:
878
879
L<DC-XML-GUIDELINES [DCMI Recommendation]|http://dublincore.org/documents/dc-xml-guidelines/>
880
881
L<Expressing Simple Dublin Core in RDF-XML|http://dublincore.org/documents/dcmes-xml/>
882
This recommendation is superseded by DC-RDFrecommendation but not obsoleted at all.
883
884
L<DC-RDF [DCMI Recommendation]|http://dublincore.org/documents/dc-rdf/>
885
886
=head2 Methods
887
888
=over 12
889
890
=item C<new>
891
892
Return a new Koha::DublinCore object.
893
This constructor sets the output type (RDF or XML), the level of the standard (Simple DC or Qualified DC) and the MARC record to be transformed to DC.
894
895
  my $objectDC = Koha::DublinCore->new({
896
        type => 'rdf',
897
        qualified => 0,
898
        get_marc_record => $record});
899
900
=item C<get_xml_data>
901
902
This method is just for DC-XML: Fetch the xml root element and the schema in .xsd format.
903
904
  $objectDC->get_xml_data({
905
        root => 'metadata',
906
        xsi_schemaLocation => 'http://example.org/myapp/ http://example.org/myapp/schema.xsd',
907
        entities => 1,
908
  });
909
910
The entities argument is for extended xml entities, i.e., placing entities to zero will codify only the five basic entities e.g., &lt, &gt, &quot, &amp, and &apos. Conversely if it is encoded to one, all entities will coded into decimal.
911
912
Additionally, has been included the opt_namespace and opt_namespace_url arguments to include another XML name space, like OAI-DC or SRW-DC.
913
914
NOTE: This method is only for use of the DC-XML recommendation, i.e., type => 'xml'.
915
See C<new> method or the section SYNOPSIS.
916
917
=item C<get_rdf_data>
918
919
This method is only for DC-RDF: Fetch the IRI identifier of the resource being described. As well, you can pass the format you want to generate with the rdf, by default the DC-RDF specify RDF/XML but RDF can represent in other formats listed below:
920
921
. ntriples
922
923
. nquads
924
925
. rdfxml
926
927
. rdfjson
928
929
. ntriples-canonical
930
931
. turtle
932
933
    $objectDC->get_rdf_data({
934
        rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
935
        rdf_format => 'rdfxml',
936
        entities => 0|1,
937
    });
938
939
NOTE: The entities is needed only for rdfxml value and is used like C<get_xml_data> method.
940
941
=item C<write_xml>
942
943
Return the xml object as string.
944
945
NOTE: This method is only for use of the DC-XML recommendation, i.e., type => 'xml'.
946
See C<new> and C<get_xml_data> methods or the section SYNOPSIS.
947
948
=item C<write_rdf>
949
950
Return the rdf object as string.
951
952
NOTE: This method is only for use of the DC-RDF recommendation, i.e., type => 'rdf'.
953
See C<new> and C<get_rdf_data> methods or the section SYNOPSIS.
954
955
=back
956
957
=head1 VERSION
958
959
version 0.01
960
961
=head1 RELATES MODULES
962
963
This package requires the following modules:
964
965
L<DublinCore::Record>
966
967
L<MARC::Record>
968
969
L<MARC::File::USMARC>
970
971
L<MARC::Crosswalk::DublinCore>
972
973
L<XML::LibXML>
974
975
L<RDF::Trine>
976
977
L<C4::Record>
978
979
=head2 SEE ALSO
980
981
Dublin Core Web Page L<http://dublincore.org>.
982
983
=head1 LICENSE
984
985
Copyright (c) 2014 Koha Community. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
986
987
=head1 AUTHOR
988
989
Hector Eduardo Catro Avalos E<lt> hector.hecaxmmx at gmail dot com E<gt>
990
and the Koha Development Team.
991
992
=cut
(-)a/catalogue/export.pl (-2 / +34 lines)
Lines 26-31 my $format=$query->param("format"); Link Here
26
my $error = '';
26
my $error = '';
27
if ($op eq "export") {
27
if ($op eq "export") {
28
    my $biblionumber = $query->param("bib");
28
    my $biblionumber = $query->param("bib");
29
    my $recommendation = $query->param("recommendation");
30
    my $formats = $query->param("formats");
31
    my $qualifier = $query->param("qualifier");
32
    my $root_element = $query->param("root_element");
33
    my $xsischemalocation = $query->param("xsischemalocation");
34
    my $resource_url = $query->url(-base => 1) .
35
                       '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' .
36
                       $biblionumber;
29
        if ($biblionumber){
37
        if ($biblionumber){
30
38
31
            my $marc = GetMarcBiblio($biblionumber, 1);
39
            my $marc = GetMarcBiblio($biblionumber, 1);
Lines 51-58 if ($op eq "export") { Link Here
51
                $format = "bibtex";
59
                $format = "bibtex";
52
            }
60
            }
53
            elsif ($format =~ /dc/) {
61
            elsif ($format =~ /dc/) {
54
                ($error,$marc) = marc2dcxml($marc,1);
62
                SWITCH:
55
                $format = "dublin-core.xml";
63
                    for ($recommendation) {
64
                        if (/^simple-dc-rdf/) {
65
                            ($error,$marc) = marc2dcxml($marc, $recommendation, 0,
66
                            1, undef, undef, $resource_url , $formats);
67
                            $format = "dublin-core." . $formats;
68
                            last SWITCH; }
69
                        if (/^dc-rdf/) {
70
                            ($error,$marc) = marc2dcxml($marc, $recommendation, 1,
71
                            1, undef, undef, $resource_url, $formats);
72
                            $format = "dublin-core." . $formats;
73
                            last SWITCH; }
74
                        if (/^dc-xml/) {
75
                            ($error,$marc) = marc2dcxml($marc, $recommendation, $qualifier,
76
                            1, $root_element, $xsischemalocation, undef, undef);
77
                            $format = "dublin-core.xml";
78
                            last SWITCH; }
79
                        if (/^oai-dc/) {
80
                            ($error,$marc) = marc2dcxml($marc, $recommendation);
81
                            $format = "dublin-core.xml";
82
                            last SWITCH; }
83
                        if (/^srw_dc/) {
84
                            ($error,$marc) = marc2dcxml($marc, $recommendation);
85
                            $format = "dublin-core.xml";
86
                            last SWITCH; }
87
                    }
56
            }
88
            }
57
            elsif ($format =~ /marc8/) {
89
            elsif ($format =~ /marc8/) {
58
                $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
90
                $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
(-)a/debian/control (-1 / +5 lines)
Lines 43-48 Build-Depends: libalgorithm-checkdigits-perl, Link Here
43
 libdbi-perl,
43
 libdbi-perl,
44
 libdbix-class-schema-loader-perl,
44
 libdbix-class-schema-loader-perl,
45
 libdbix-connector-perl,
45
 libdbix-connector-perl,
46
 libdevel-cover-perl,
46
 libdigest-sha-perl | perl,
47
 libdigest-sha-perl | perl,
47
 libemail-date-perl,
48
 libemail-date-perl,
48
 libemail-valid-perl,
49
 libemail-valid-perl,
Lines 87-92 Build-Depends: libalgorithm-checkdigits-perl, Link Here
87
 libpdf-reuse-barcode-perl,
88
 libpdf-reuse-barcode-perl,
88
 libpdf-reuse-perl,
89
 libpdf-reuse-perl,
89
 libpdf-table-perl,
90
 libpdf-table-perl,
91
 librdf-trine-perl,
90
 libscalar-list-utils-perl,
92
 libscalar-list-utils-perl,
91
 libschedule-at-perl,
93
 libschedule-at-perl,
92
 libsms-send-perl,
94
 libsms-send-perl,
Lines 124-130 Build-Depends: libalgorithm-checkdigits-perl, Link Here
124
 libyaml-perl,
126
 libyaml-perl,
125
 libyaml-syck-perl,
127
 libyaml-syck-perl,
126
 perl,
128
 perl,
127
 perl-modules,
129
 perl-modules, 
128
 debhelper (>= 7.0.50), gettext, xsltproc, docbook-xsl,
130
 debhelper (>= 7.0.50), gettext, xsltproc, docbook-xsl,
129
 libxml2-utils, bash-completion, perl-modules (>= 5.14.2) | libtest-simple-perl (>= 0.98)
131
 libxml2-utils, bash-completion, perl-modules (>= 5.14.2) | libtest-simple-perl (>= 0.98)
130
132
Lines 239-244 Depends: libalgorithm-checkdigits-perl, Link Here
239
 libdbi-perl,
241
 libdbi-perl,
240
 libdbix-class-schema-loader-perl,
242
 libdbix-class-schema-loader-perl,
241
 libdbix-connector-perl,
243
 libdbix-connector-perl,
244
 libdevel-cover-perl,
242
 libdigest-sha-perl | perl,
245
 libdigest-sha-perl | perl,
243
 libemail-date-perl,
246
 libemail-date-perl,
244
 libemail-valid-perl,
247
 libemail-valid-perl,
Lines 283-288 Depends: libalgorithm-checkdigits-perl, Link Here
283
 libpdf-reuse-barcode-perl,
286
 libpdf-reuse-barcode-perl,
284
 libpdf-reuse-perl,
287
 libpdf-reuse-perl,
285
 libpdf-table-perl,
288
 libpdf-table-perl,
289
 librdf-trine-perl,
286
 libscalar-list-utils-perl,
290
 libscalar-list-utils-perl,
287
 libschedule-at-perl,
291
 libschedule-at-perl,
288
 libsms-send-perl,
292
 libsms-send-perl,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +1 lines)
Lines 221-227 CAN_user_serials_create_subscription ) %] Link Here
221
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt"></i> Save <span class="caret"></span></button>
221
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt"></i> Save <span class="caret"></span></button>
222
    <ul class="dropdown-menu">
222
    <ul class="dropdown-menu">
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=bibtex&amp;op=export&amp;bib=[% biblionumber %]">BIBTEX</a></li>
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=bibtex&amp;op=export&amp;bib=[% biblionumber %]">BIBTEX</a></li>
224
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=dc&amp;op=export&amp;bib=[% biblionumber %]">Dublin Core (XML)</a></li>
224
        <li><a href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
225
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcxml&amp;op=export&amp;bib=[% biblionumber %]">MARCXML</a></li>
225
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcxml&amp;op=export&amp;bib=[% biblionumber %]">MARCXML</a></li>
226
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marc8&amp;op=export&amp;bib=[% biblionumber %]">MARC (non-Unicode/MARC-8)</a></li>
226
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marc8&amp;op=export&amp;bib=[% biblionumber %]">MARC (non-Unicode/MARC-8)</a></li>
227
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=utf8&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8)</a></li>
227
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=utf8&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8)</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +142 lines)
Lines 303-308 function verify_images() { Link Here
303
303
304
        [% END %]
304
        [% END %]
305
    });
305
    });
306
307
    //JQuery for Dublin Core Modal
308
    $(document).ready(function(){
309
        $("#input-simple").click(function(){
310
            $(".rdfoptions").removeAttr("disabled");
311
            $(".xmloptions").attr("disabled","disabled");
312
            $("#dc-rdf").toggle();
313
            $("#dc-xml").hide();
314
        });
315
    });
316
317
    $(document).ready(function(){
318
        $("#input-rdf").click(function(){
319
            $(".rdfoptions").removeAttr("disabled");
320
            $(".xmloptions").attr("disabled","disabled");
321
            $("#dc-rdf").toggle();
322
            $("#dc-xml").hide();
323
        });
324
    });
325
326
    $(document).ready(function(){
327
        $("#input-xml").click(function(){
328
            $(".xmloptions").removeAttr("disabled");
329
            $(".rdfoptions").attr("disabled","disabled");
330
                if($("#root_checked").is(':checked')){
331
                    $("#root_value").removeAttr("disabled");
332
                } else {
333
                    $("#root_value").attr("disabled","disabled");
334
                }
335
                if($("#schema_checked").is(':checked')){
336
                    $("#schema_value").removeAttr("disabled");
337
                } else {
338
                    $("#schema_value").attr("disabled","disabled");
339
                }
340
                $("#dc-xml").toggle();
341
                $("#dc-rdf").hide();
342
        });
343
    });
344
345
    $(document).ready(function(){
346
        $("#root_checked").click(function(){
347
            if($("#root_checked").is(':checked')){
348
                $("#root_value").removeAttr("disabled");
349
            } else {
350
                $("#root_value").attr("disabled","disabled");
351
            }
352
        });
353
    });
354
355
    $(document).ready(function(){
356
        $("#schema_checked").click(function(){
357
            if($("#schema_checked").is(':checked')){
358
                $("#schema_value").removeAttr("disabled");
359
            } else {
360
                $("#schema_value").attr("disabled","disabled");
361
            }
362
        });
363
    });
364
365
    $(document).ready(function(){
366
        $("#input-oai").click(function(){
367
            $(".rdfoptions").attr("disabled","disabled");
368
            $(".xmloptions").attr("disabled","disabled");
369
            $("#dc-rdf").hide();
370
            $("#dc-xml").hide();
371
        });
372
    });
373
374
    $(document).ready(function(){
375
        $("#input-srw").click(function(){
376
            $(".rdfoptions").attr("disabled","disabled");
377
            $(".xmloptions").attr("disabled","disabled");
378
            $("#dc-rdf").hide();
379
            $("#dc-xml").hide();
380
        });
381
    });
382
306
//]]>
383
//]]>
307
</script>
384
</script>
308
</head>
385
</head>
Lines 1043-1049 function verify_images() { Link Here
1043
      <th>Save Record</th>   </tr>
1120
      <th>Save Record</th>   </tr>
1044
    <tr><td> Select download format:    <select name="format">
1121
    <tr><td> Select download format:    <select name="format">
1045
        <option value="mods">MODS (XML)</option>
1122
        <option value="mods">MODS (XML)</option>
1046
        <option value="dc">Dublin Core (XML)</option>
1123
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1047
        <option value="marcxml">MARCXML</option>
1124
        <option value="marcxml">MARCXML</option>
1048
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1125
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1049
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1126
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
Lines 1076-1079 function verify_images() { Link Here
1076
</div>
1153
</div>
1077
[% END %]
1154
[% END %]
1078
</div>
1155
</div>
1156
1157
    <!--Modal for Dublin Core-->
1158
    <div class="modal hide" id="exportModal_" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_" aria-hidden="true">
1159
        <div class="modal-header">
1160
            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">&times;</button>
1161
            <h3 id="exportLabelexportModal_">Exporting to Dublin Core...</h3>
1162
        </div>
1163
        <!-- Form to recolect data for Dublin Core-->
1164
        <form method="get" action="/cgi-bin/koha/catalogue/export.pl">
1165
        <div class="modal-body">
1166
            <fieldset>
1167
                <input id="input-simple" type="radio" name="recommendation" value="simple-dc-rdf">Simple DC-RDF
1168
                <br>
1169
                <input id="input-rdf" type="radio" name="recommendation" value="dc-rdf" checked>DC-RDF (Recommended)
1170
                <div id="dc-rdf" style="display:none;">
1171
                    <br>DC-RDF is downloadable in &quot;rdfxml&quot; by default (this is according with the
1172
                    <br>recommendation),  but you can download the file in other formats:
1173
                    <br>
1174
                    <input class="rdfoptions" type="radio" name="formats" value="rdfxml" checked>rdfxml
1175
                    <input class="rdfoptions" type="radio" name="formats" value="rdfjson">rdfjson
1176
                    <input class="rdfoptions" type="radio" name="formats" value="ntriples">ntriples
1177
                    <input class="rdfoptions" type="radio" name="formats" value="nquads">nquads
1178
                    <input class="rdfoptions" type="radio" name="formats" value="ntriples-canonical">ntriples-canonical
1179
                    <input class="rdfoptions" type="radio" name="formats" value="turtle">turtle
1180
                </div>
1181
                <br>
1182
                <input id="input-xml" type="radio" name="recommendation" value="dc-xml">DC-XML
1183
                <div id="dc-xml" style="display:none;">
1184
                    <p><b>Output options for DC-XML</b>
1185
                    <br>
1186
                    <b>Dublin Core level</b></p>
1187
                    <p><input class="xmloptions" type="radio" name="qualifier" value="0" checked disabled>Simple Dublin Core
1188
                    <input class="xmloptions" type="radio" name="qualifier" value="1" disabled>Qualified Dublin Core</p>
1189
                    <b>Other data (Optional)</b>
1190
                    <br>
1191
                    <input id="root_checked" class="xmloptions" type="checkbox" value="root">
1192
                    Root element: <input id="root_value" class="xmloptions" type="text" name="root_element" value="metadata" disabled>
1193
                    <br>The xsischemaLocation should be filled like:
1194
                    <br>http://example.org/myapp/ http://example.org/myapp/schema.xsd
1195
                    <br>
1196
                    <input id="schema_checked" class="xmloptions" type="checkbox" value="schema" disabled>
1197
                    xsischemaLocation: <input id="schema_value" class="xmloptions" type="url" name="xsischemalocation" disabled><br>
1198
                </div>
1199
                <br>
1200
                <input id="input-oai" type="radio" name="recommendation" value="oai-dc">OAI-DC
1201
                <br>
1202
                <input id="input-srw" type="radio" name="recommendation" value="srw_dc">SRW-DC
1203
                <br>
1204
                <div>
1205
                <br>Learn more about DCMI Specifications at: <a href="http://dublincore.org/specifications/">http://dublincore.org/specifications/</a>
1206
                <br>
1207
                </div>
1208
            </fieldset>
1209
        </div>
1210
        <div class="modal-footer">
1211
            <button type="submit" class="btn">Export</button>
1212
            <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1213
        </div>
1214
        <input type="hidden" name="op" value="export" />
1215
        <input type="hidden" name="format" value="dc" />
1216
        <input type="hidden" name="bib" value="[% biblionumber %]" />
1217
        </form>
1218
    </div>
1219
1079
[% INCLUDE 'intranet-bottom.inc' %]
1220
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (+66 lines)
Lines 316-318 Link Here
316
            </div>
316
            </div>
317
        </form> <!-- /#auth -->
317
        </form> <!-- /#auth -->
318
    </div>  <!-- /#modalAuth  -->
318
    </div>  <!-- /#modalAuth  -->
319
320
    <!-- Dublin Core Modal Form -->
321
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
322
        <div class="modal-dialog">
323
            <div class="modal-content">
324
                <div class="modal-header">
325
                    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">&times;</button>
326
                    <h4 class="modal-title" id="myModalLabel">Exporting to Dublin Core...</h4>
327
                </div>
328
                <form method="get" action="/cgi-bin/koha/opac-export.pl">
329
                    <div class="modal-body">
330
                        <fieldset>
331
                            <input id="input-simple" type="radio" name="recommendation" value="simple-dc-rdf">Simple DC-RDF
332
                            <br>
333
                            <input id="input-rdf" type="radio" name="recommendation" value="dc-rdf" checked>DC-RDF (Recommended)
334
                            <div id="dc-rdf" style="display:none;">
335
                                <br>DC-RDF is downloadable in &quot;rdfxml&quot; by default (this is according with the
336
                                <br>recommendation),  but you can download the file in other formats:
337
                                <br>
338
                                <input class="rdfoptions" type="radio" name="formats" value="rdfxml" checked>rdfxml
339
                                <input class="rdfoptions" type="radio" name="formats" value="rdfjson">rdfjson
340
                                <input class="rdfoptions" type="radio" name="formats" value="ntriples">ntriples
341
                                <input class="rdfoptions" type="radio" name="formats" value="nquads">nquads
342
                                <input class="rdfoptions" type="radio" name="formats" value="ntriples-canonical">ntriples-canonical
343
                                <input class="rdfoptions" type="radio" name="formats" value="turtle">turtle
344
                            </div>
345
                            <br>
346
                            <input id="input-xml" type="radio" name="recommendation" value="dc-xml">DC-XML
347
                            <div id="dc-xml" style="display:none;">
348
                                <p><b>Output options for DC-XML</b>
349
                                <br>
350
                                <b>Dublin Core level</b></p>
351
                                <p><input class="xmloptions" type="radio" name="qualifier" value="0" checked disabled>Simple Dublin Core
352
                                <input class="xmloptions" type="radio" name="qualifier" value="1" disabled>Qualified Dublin Core</p>
353
                                <b>Other data (Optional)</b>
354
                                <br>
355
                                <input id="root_checked" class="xmloptions" type="checkbox" value="root">
356
                                Root element: <input id="root_value" class="xmloptions" type="text" name="root_element" value="metadata" disabled>
357
                                <br>The xsischemaLocation should be filled like:
358
                                <br>http://example.org/myapp/ http://example.org/myapp/schema.xsd
359
                                <br>
360
                                <input id="schema_checked" class="xmloptions" type="checkbox" value="schema" disabled>
361
                                xsischemaLocation: <input id="schema_value" class="xmloptions" type="url" name="xsischemalocation" disabled><br>
362
                            </div>
363
                            <br>
364
                            <input id="input-oai" type="radio" name="recommendation" value="oai-dc">OAI-DC
365
                            <br>
366
                            <input id="input-srw" type="radio" name="recommendation" value="srw_dc">SRW-DC
367
                            <br>
368
                            <div>
369
                                <br>Learn more about DCMI Specifications at: <a href="http://dublincore.org/specifications/">http://dublincore.org/specifications/</a>
370
                                <br>
371
                            </div>
372
                        </fieldset>
373
                    </div>
374
                    <div class="modal-footer">
375
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
376
                        <button type="submit" class="btn btn-primary">Export</button>
377
                    </div>
378
                    <input type="hidden" name="op" value="export" />
379
                    <input type="hidden" name="format" value="dc" />
380
                    <input type="hidden" name="bib" value="[% biblionumber %]" />
381
                </form>
382
            </div>
383
        </div>
384
    </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +4 lines)
Lines 38-48 Link Here
38
                    <a id="format" class="dropdown-toggle" data-toggle="dropdown" href="#">Save record <b class="caret"></b></a>
38
                    <a id="format" class="dropdown-toggle" data-toggle="dropdown" href="#">Save record <b class="caret"></b></a>
39
                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="format">
39
                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="format">
40
                            [% FOREACH option IN export_options %]
40
                            [% FOREACH option IN export_options %]
41
                                [% IF option == 'dc' %]
42
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#myModal">Dublin Core</a></li>
43
                                [% ELSE %]
41
                                <li>
44
                                <li>
42
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblionumber %]&amp;format=[% option %]">
45
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblionumber %]&amp;format=[% option %]">
43
                                        [% SWITCH option %]
46
                                        [% SWITCH option %]
44
                                            [% CASE 'bibtex' %]BIBTEX
47
                                            [% CASE 'bibtex' %]BIBTEX
45
                                            [% CASE 'dc' %]Dublin Core (XML)
46
                                            [% CASE 'endnote' %]EndNote
48
                                            [% CASE 'endnote' %]EndNote
47
                                            [% CASE 'marcxml' %]MARCXML
49
                                            [% CASE 'marcxml' %]MARCXML
48
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
50
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
Lines 54-59 Link Here
54
                                        [% END %]
56
                                        [% END %]
55
                                    </a>
57
                                    </a>
56
                                </li>
58
                                </li>
59
                                [% END %]
57
                            [% END %]
60
                            [% END %]
58
                        </ul>
61
                        </ul>
59
                </div>
62
                </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/script.js (-1 / +77 lines)
Lines 63-66 $(document).ready(function(){ Link Here
63
            $("#members").removeAttr("style");
63
            $("#members").removeAttr("style");
64
        }
64
        }
65
    });
65
    });
66
});
66
});
67
68
    //JQuery for Dublin Core Modal
69
    $(document).ready(function(){
70
        $("#input-simple").click(function(){
71
            $(".rdfoptions").removeAttr("disabled");
72
            $(".xmloptions").attr("disabled","disabled");
73
            $("#dc-rdf").toggle();
74
            $("#dc-xml").hide();
75
        });
76
    });
77
78
    $(document).ready(function(){
79
        $("#input-rdf").click(function(){
80
            $(".rdfoptions").removeAttr("disabled");
81
            $(".xmloptions").attr("disabled","disabled");
82
            $("#dc-rdf").toggle();
83
            $("#dc-xml").hide();
84
        });
85
    });
86
87
    $(document).ready(function(){
88
        $("#input-xml").click(function(){
89
            $(".xmloptions").removeAttr("disabled");
90
            $(".rdfoptions").attr("disabled","disabled");
91
                if($("#root_checked").is(':checked')){
92
                    $("#root_value").removeAttr("disabled");
93
                } else {
94
                    $("#root_value").attr("disabled","disabled");
95
                }
96
                if($("#schema_checked").is(':checked')){
97
                    $("#schema_value").removeAttr("disabled");
98
                } else {
99
                    $("#schema_value").attr("disabled","disabled");
100
                }
101
                $("#dc-xml").toggle();
102
                $("#dc-rdf").hide();
103
        });
104
    });
105
106
    $(document).ready(function(){
107
        $("#root_checked").click(function(){
108
            if($("#root_checked").is(':checked')){
109
                $("#root_value").removeAttr("disabled");
110
            } else {
111
                $("#root_value").attr("disabled","disabled");
112
            }
113
        });
114
    });
115
116
    $(document).ready(function(){
117
        $("#schema_checked").click(function(){
118
            if($("#schema_checked").is(':checked')){
119
                $("#schema_value").removeAttr("disabled");
120
            } else {
121
                $("#schema_value").attr("disabled","disabled");
122
            }
123
        });
124
    });
125
126
    $(document).ready(function(){
127
        $("#input-oai").click(function(){
128
            $(".rdfoptions").attr("disabled","disabled");
129
            $(".xmloptions").attr("disabled","disabled");
130
            $("#dc-rdf").hide();
131
            $("#dc-xml").hide();
132
        });
133
    });
134
135
    $(document).ready(function(){
136
        $("#input-srw").click(function(){
137
            $(".rdfoptions").attr("disabled","disabled");
138
            $(".xmloptions").attr("disabled","disabled");
139
            $("#dc-rdf").hide();
140
            $("#dc-xml").hide();
141
        });
142
    });
(-)a/opac/opac-export.pl (-2 / +34 lines)
Lines 34-39 my $format=$query->param("format")||'utf8'; Link Here
34
my $biblionumber = $query->param("bib")||0;
34
my $biblionumber = $query->param("bib")||0;
35
$biblionumber = int($biblionumber);
35
$biblionumber = int($biblionumber);
36
my ($marc, $error)= ('','');
36
my ($marc, $error)= ('','');
37
my $recommendation = $query->param("recommendation");
38
my $formats = $query->param("formats");
39
my $qualifier = $query->param("qualifier");
40
my $root_element = $query->param("root_element");
41
my $xsischemalocation = $query->param("xsischemalocation");
42
my $resource_url = $query->url(-base => 1) .
43
                   '/cgi-bin/koha/opac-detail.pl?biblionumber=' .
44
                   $biblionumber;
37
45
38
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber;
46
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber;
39
if(!$marc) {
47
if(!$marc) {
Lines 61-68 elsif ($format =~ /bibtex/) { Link Here
61
    $format = 'bibtex';
69
    $format = 'bibtex';
62
}
70
}
63
elsif ($format =~ /dc/) {
71
elsif ($format =~ /dc/) {
64
    ($error,$marc) = marc2dcxml($marc,1);
72
    SWITCH:
65
    $format = "dublin-core.xml";
73
        for ($recommendation) {
74
            if (/^simple-dc-rdf/) {
75
                ($error,$marc) = marc2dcxml($marc, $recommendation, 0,
76
                1, undef, undef, $resource_url , $formats);
77
                $format = "dublin-core." . $formats;
78
                last SWITCH; }
79
            if (/^dc-rdf/) {
80
                ($error,$marc) = marc2dcxml($marc, $recommendation, 1,
81
                1, undef, undef, $resource_url, $formats);
82
                $format = "dublin-core." . $formats;
83
                last SWITCH; }
84
            if (/^dc-xml/) {
85
                ($error,$marc) = marc2dcxml($marc, $recommendation, $qualifier,
86
                1, $root_element, $xsischemalocation, undef, undef);
87
                $format = "dublin-core.xml";
88
                last SWITCH; }
89
            if (/^oai-dc/) {
90
                ($error,$marc) = marc2dcxml($marc, $recommendation);
91
                $format = "dublin-core.xml";
92
                last SWITCH; }
93
            if (/^srw_dc/) {
94
                ($error,$marc) = marc2dcxml($marc, $recommendation);
95
                $format = "dublin-core.xml";
96
                last SWITCH; }
97
        }
66
}
98
}
67
elsif ($format =~ /marc8/) {
99
elsif ($format =~ /marc8/) {
68
    ($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8");
100
    ($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8");
(-)a/t/db_dependent/Record.t (-24 / +16 lines)
Lines 46-74 is ($marcxml, $testxml, "testing marc2xml"); Link Here
46
my $marcconvert=marcxml2marc($marcxml);
46
my $marcconvert=marcxml2marc($marcxml);
47
is ($marcconvert->as_xml,$marc->as_xml, "testing xml2marc");
47
is ($marcconvert->as_xml,$marc->as_xml, "testing xml2marc");
48
48
49
my $marcdc=marc2dcxml($marc);
49
my $marcrdf=marc2dcxml($marc, 'dc-rdf', 1,
50
my $test2xml=qq(<?xml version="1.0" encoding="UTF-8"?>
50
                      0, undef, undef, undef, 'rdfxml');
51
<metadata
51
my $test2xml=qq(<?xml version="1.0" encoding="utf-8"?>
52
  xmlns="http://example.org/myapp/"
52
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:dcterms="http://purl.org/dc/terms/">
53
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53
</rdf:RDF>
54
  xsi:schemaLocation="http://example.org/myapp/ http://example.org/myapp/schema.xsd"
54
);
55
  xmlns:dc="http://purl.org/dc/elements/1.1/"
55
56
  xmlns:dcterms="http://purl.org/dc/terms/">
56
is ($marcrdf, $test2xml, "testing marc2dcxml with dc-rdf");
57
</metadata>);
57
58
58
my $marcdc=marc2dcxml($marc, 'dc-xml', 0,
59
is ($marcdc, $test2xml, "testing marc2dcxml");
59
                      0, 'metadata', undef, undef, undef);
60
60
my $test3xml=qq(<?xml version="1.0" encoding="utf-8"?>
61
my $marcqualified=marc2dcxml($marc,1);
61
<metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/"/>
62
my $test3xml=qq(<?xml version="1.0" encoding="UTF-8"?>
62
);
63
<metadata
63
64
  xmlns="http://example.org/myapp/"
64
is ($marcdc, $test3xml, "testing marc2dcxml with unqualified dc-xml");
65
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
  xsi:schemaLocation="http://example.org/myapp/ http://example.org/myapp/schema.xsd"
67
  xmlns:dc="http://purl.org/dc/elements/1.1/"
68
  xmlns:dcterms="http://purl.org/dc/terms/">
69
</metadata>);
70
71
is ($marcqualified, $test3xml, "testing marcQualified");
72
65
73
my $mods=marc2modsxml($marc);
66
my $mods=marc2modsxml($marc);
74
my $test4xml=qq(<?xml version="1.0" encoding="UTF-8"?>
67
my $test4xml=qq(<?xml version="1.0" encoding="UTF-8"?>
75
- 

Return to bug 13642