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 C4::DublinCoreTransformer; # 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 222-237
sub marcxml2marc {
Link Here
|
222 |
|
222 |
|
223 |
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar |
223 |
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar |
224 |
|
224 |
|
225 |
FIXME: should return actual XML, not just an object |
225 |
FIXME: should return actual XML, not just an object (C4::DublinCoreTransformer return an XML) |
|
|
226 |
|
227 |
C<$type> - the recommendation ( simple-dc-rdf, dc-rdf, dc-xml, oai-dc) |
226 |
|
228 |
|
227 |
C<$marc> - an ISO-2709 scalar or MARC::Record object |
229 |
C<$marc> - an ISO-2709 scalar or MARC::Record object |
228 |
|
230 |
|
229 |
C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0] |
231 |
C<$qualified> - specify whether simple or qualified Dublin Core should be used in output [0 or 1] |
|
|
232 |
|
233 |
C<$entities> placing entities to 0 will codify only the five basic entities e.g., <, >, ", &, and &apos. Conversely if it is encoded to 1, all entities will coded into decimal |
234 |
|
235 |
C<$root> root element for XML files |
236 |
|
237 |
C<$xsi_schemaLocation> the xsischemaLocation for XML files. |
238 |
|
239 |
C<$rdf_subject> Represent the main subject of RDF triples (for Koha the URI of the resource) |
240 |
|
241 |
C<$rdf_format> Imply multiple formats for RDF (ntriples, nquads, rdfxml, rdfjson, ntriples-canonical, turtle) |
230 |
|
242 |
|
231 |
=cut |
243 |
=cut |
232 |
|
244 |
|
233 |
sub marc2dcxml { |
245 |
sub marc2dcxml { |
234 |
my ($marc,$qualified) = @_; |
246 |
my ( $type, $marc, $qualified, $entities, $root, $xsi_schemaLocation, $rdf_subject, |
|
|
247 |
$rdf_format ) = @_; |
235 |
my $error; |
248 |
my $error; |
236 |
# test if it's already a MARC::Record object, if not, make it one |
249 |
# test if it's already a MARC::Record object, if not, make it one |
237 |
my $marc_record_obj; |
250 |
my $marc_record_obj; |
Lines 245-268
sub marc2dcxml {
Link Here
|
245 |
$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR; |
258 |
$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR; |
246 |
} |
259 |
} |
247 |
} |
260 |
} |
248 |
my $crosswalk = MARC::Crosswalk::DublinCore->new; |
261 |
my $dcxml; |
249 |
if ($qualified) { |
262 |
|
250 |
$crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 ); |
263 |
SWITCH: |
251 |
} |
264 |
for ($type) { |
252 |
my $dcxml = $crosswalk->as_dublincore($marc_record_obj); |
265 |
if (/^simple-dc-rdf/) { |
253 |
my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
266 |
my $objectDC = C4::DublinCoreTransformer->new({ |
254 |
$dcxmlfinal .= "<metadata |
267 |
type => 'rdf', |
255 |
xmlns=\"http://example.org/myapp/\" |
268 |
qualified => 0, |
256 |
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" |
269 |
get_marc_record => $marc, |
257 |
xsi:schemaLocation=\"http://example.org/myapp/ http://example.org/myapp/schema.xsd\" |
270 |
}); |
258 |
xmlns:dc=\"http://purl.org/dc/elements/1.1/\" |
271 |
|
259 |
xmlns:dcterms=\"http://purl.org/dc/terms/\">"; |
272 |
$objectDC->get_rdf_data({ |
260 |
|
273 |
rdf_subject => $rdf_subject, |
261 |
foreach my $element ( $dcxml->elements() ) { |
274 |
rdf_format => 'rdfxml', |
262 |
$dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n"; |
275 |
entities => 1, |
|
|
276 |
}); |
277 |
$dcxml = $objectDC->write_rdf(); |
278 |
last SWITCH; |
279 |
} |
280 |
if (/^dc-rdf/) { |
281 |
my $objectDC = C4::DublinCoreTransformer->new({ |
282 |
type => 'rdf', |
283 |
qualified => 1, |
284 |
get_marc_record => $marc, |
285 |
}); |
286 |
|
287 |
$objectDC->get_rdf_data({ |
288 |
rdf_subject => $rdf_subject, |
289 |
rdf_format => $rdf_format, |
290 |
entities => 1, |
291 |
}); |
292 |
$dcxml = $objectDC->write_rdf(); |
293 |
last SWITCH; |
294 |
} |
295 |
if (/^dc-xml/) { |
296 |
my $objectDC = C4::DublinCoreTransformer->new({ |
297 |
type => 'xml', |
298 |
qualified => $qualified, |
299 |
get_marc_record => $marc, |
300 |
}); |
301 |
|
302 |
$objectDC->get_xml_data({ |
303 |
root => $root, |
304 |
xsi_schemaLocation => $xsi_schemaLocation, |
305 |
entities => 1, |
306 |
}); |
307 |
$dcxml = $objectDC->write_xml(); |
308 |
last SWITCH; |
309 |
} |
310 |
if ($type eq 'oai-dc') { |
311 |
my $objectDC = C4::DublinCoreTransformer->new({ |
312 |
type => 'xml', |
313 |
qualified => 0, |
314 |
get_marc_record => $marc, |
315 |
}); |
316 |
|
317 |
$objectDC->get_xml_data({ |
318 |
root => 'oai_dc:dc', |
319 |
xsi_schemaLocation => 'http://www.openarchives.org/OAI/2.0/oai_dc/' . |
320 |
' http://www.openarchives.org/OAI/2.0/oai_dc.xsd', |
321 |
entities => 0, |
322 |
optional_namespace => 'oai_dc', |
323 |
namespace_url => 'http://www.openarchives.org/OAI/2.0/oai_dc/', |
324 |
}); |
325 |
$dcxml = $objectDC->write_xml(); |
326 |
last SWITCH; |
327 |
} |
263 |
} |
328 |
} |
264 |
$dcxmlfinal .= "\n</metadata>"; |
329 |
return ( $error, $dcxml ); |
265 |
return ($error,$dcxmlfinal); |
|
|
266 |
} |
330 |
} |
267 |
|
331 |
|
268 |
=head2 marc2modsxml - Convert from ISO-2709 to MODS |
332 |
=head2 marc2modsxml - Convert from ISO-2709 to MODS |
269 |
- |
|
|