Bugzilla – Attachment 35638 Details for
Bug 13642
Adding new features for Dublin Core metadata
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13642 [ENH] Adding new features for Dublin Core metadata #2/9
0004-Bug-13642-ENH-Adding-new-features-for-Dublin-Core-me.patch (text/plain), 5.69 KB, created by
Héctor Eduardo Castro Avalos
on 2015-01-30 19:48:48 UTC
(
hide
)
Description:
Bug 13642 [ENH] Adding new features for Dublin Core metadata #2/9
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2015-01-30 19:48:48 UTC
Size:
5.69 KB
patch
obsolete
>From 547e9f498220268b209b28926002a74515baf281 Mon Sep 17 00:00:00 2001 >From: Hector Castro <hector.hecaxmmx@gmail.com> >Date: Fri, 30 Jan 2015 11:04:00 -0600 >Subject: [PATCH 04/11] Bug 13642 [ENH] Adding new features for Dublin Core > metadata Changes to marc2dcxml method in Record.pm > >- Update marc2dcxml() to obtain more arguments >- Update the pod of marc2dcxml() >- Change the use MARC::Crosswalk::DublinCore for C4::DublinCoreTransformer >--- > C4/Record.pm | 106 ++++++++++++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 85 insertions(+), 21 deletions(-) > mode change 100644 => 100755 C4/Record.pm > >diff --git a/C4/Record.pm b/C4/Record.pm >old mode 100644 >new mode 100755 >index 16d3f54..fa85ea0 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -25,7 +25,7 @@ use strict; > # please specify in which methods a given module is used > use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding > use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding >-use MARC::Crosswalk::DublinCore; # marc2dcxml >+use C4::DublinCoreTransformer; # marc2dcxml > use Biblio::EndnoteStyle; > use Unicode::Normalize; # _entity_encode > use C4::Biblio; #marc2bibtex >@@ -222,16 +222,29 @@ sub marcxml2marc { > > Returns a DublinCore::Record object, will eventually return a Dublin Core scalar > >-FIXME: should return actual XML, not just an object >+FIXME: should return actual XML, not just an object (C4::DublinCoreTransformer return an XML) >+ >+C<$type> - the recommendation ( simple-dc-rdf, dc-rdf, dc-xml, oai-dc) > > C<$marc> - an ISO-2709 scalar or MARC::Record object > >-C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0] >+C<$qualified> - specify whether simple or qualified Dublin Core should be used in output [0 or 1] >+ >+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 >+ >+C<$root> root element for XML files >+ >+C<$xsi_schemaLocation> the xsischemaLocation for XML files. >+ >+C<$rdf_subject> Represent the main subject of RDF triples (for Koha the URI of the resource) >+ >+C<$rdf_format> Imply multiple formats for RDF (ntriples, nquads, rdfxml, rdfjson, ntriples-canonical, turtle) > > =cut > > sub marc2dcxml { >- my ($marc,$qualified) = @_; >+ my ( $type, $marc, $qualified, $entities, $root, $xsi_schemaLocation, $rdf_subject, >+ $rdf_format ) = @_; > my $error; > # test if it's already a MARC::Record object, if not, make it one > my $marc_record_obj; >@@ -245,24 +258,75 @@ sub marc2dcxml { > $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR; > } > } >- my $crosswalk = MARC::Crosswalk::DublinCore->new; >- if ($qualified) { >- $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 ); >- } >- my $dcxml = $crosswalk->as_dublincore($marc_record_obj); >- my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; >- $dcxmlfinal .= "<metadata >- xmlns=\"http://example.org/myapp/\" >- xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >- xsi:schemaLocation=\"http://example.org/myapp/ http://example.org/myapp/schema.xsd\" >- xmlns:dc=\"http://purl.org/dc/elements/1.1/\" >- xmlns:dcterms=\"http://purl.org/dc/terms/\">"; >- >- foreach my $element ( $dcxml->elements() ) { >- $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n"; >+ my $dcxml; >+ >+ SWITCH: >+ for ($type) { >+ if (/^simple-dc-rdf/) { >+ my $objectDC = C4::DublinCoreTransformer->new({ >+ type => 'rdf', >+ qualified => 0, >+ get_marc_record => $marc, >+ }); >+ >+ $objectDC->get_rdf_data({ >+ rdf_subject => $rdf_subject, >+ rdf_format => 'rdfxml', >+ entities => 1, >+ }); >+ $dcxml = $objectDC->write_rdf(); >+ last SWITCH; >+ } >+ if (/^dc-rdf/) { >+ my $objectDC = C4::DublinCoreTransformer->new({ >+ type => 'rdf', >+ qualified => 1, >+ get_marc_record => $marc, >+ }); >+ >+ $objectDC->get_rdf_data({ >+ rdf_subject => $rdf_subject, >+ rdf_format => $rdf_format, >+ entities => 1, >+ }); >+ $dcxml = $objectDC->write_rdf(); >+ last SWITCH; >+ } >+ if (/^dc-xml/) { >+ my $objectDC = C4::DublinCoreTransformer->new({ >+ type => 'xml', >+ qualified => $qualified, >+ get_marc_record => $marc, >+ }); >+ >+ $objectDC->get_xml_data({ >+ root => $root, >+ xsi_schemaLocation => $xsi_schemaLocation, >+ entities => 1, >+ }); >+ $dcxml = $objectDC->write_xml(); >+ last SWITCH; >+ } >+ if ($type eq 'oai-dc') { >+ my $objectDC = C4::DublinCoreTransformer->new({ >+ type => 'xml', >+ qualified => 0, >+ get_marc_record => $marc, >+ }); >+ >+ $objectDC->get_xml_data({ >+ root => 'oai_dc:dc', >+ xsi_schemaLocation => 'http://www.openarchives.org/OAI/2.0/oai_dc/' . >+ ' http://www.openarchives.org/OAI/2.0/oai_dc.xsd', >+ entities => 0, >+ optional_namespace => 'oai_dc', >+ namespace_url => 'http://www.openarchives.org/OAI/2.0/oai_dc/', >+ }); >+ $dcxml = $objectDC->write_xml(); >+ last SWITCH; >+ } > } >- $dcxmlfinal .= "\n</metadata>"; >- return ($error,$dcxmlfinal); >+ return ( $error, $dcxml ); > } > > =head2 marc2modsxml - Convert from ISO-2709 to MODS >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13642
:
35637
|
35638
|
35639
|
35640
|
35641
|
35642
|
35643
|
35644
|
35645
|
35663
|
35957
|
35981
|
35982
|
35983
|
35999
|
36000
|
36005
|
36006
|
36147
|
36154
|
36631
|
36632
|
36633
|
36636
|
36714
|
38220
|
38819
|
39623
|
39654
|
40786
|
40787
|
42168
|
43311
|
43313
|
43545
|
43548
|
43549
|
43586
|
43612
|
44627
|
44629
|
44658
|
44659
|
44660
|
44661
|
44662
|
44669
|
44672
|
44677
|
44727
|
44728
|
44729
|
44815
|
44816
|
44819
|
45970
|
45971
|
46514
|
46584
|
46585
|
46586
|
46587
|
46588