|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# |
| 4 |
# This file is part of Koha. |
| 5 |
# |
| 6 |
# Copyright (C) 2015 Universidad de El Salvador, |
| 7 |
# Facultad Multidisciplinaria Oriental |
| 8 |
# |
| 9 |
# Koha is free software; you can redistribute it and/or modify it |
| 10 |
# under the terms of the GNU General Public License as published by |
| 11 |
# the Free Software Foundation; either version 3 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# Koha is distributed in the hope that it will be useful, but |
| 15 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
# GNU General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU General Public License |
| 20 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 21 |
# |
| 22 |
|
| 23 |
use Modern::Perl; |
| 24 |
|
| 25 |
use Test::More tests => 11; |
| 26 |
use MARC::Record; |
| 27 |
|
| 28 |
BEGIN { |
| 29 |
use_ok('Koha::Crosswalk::DublinCore'); |
| 30 |
} |
| 31 |
|
| 32 |
## create a MARC::Record object. |
| 33 |
my $record = MARC::Record->new(); |
| 34 |
$record->leader('00000cam a2200000 i 4500'); |
| 35 |
my $control_number = MARC::Field->new( '001', '55645069' ); |
| 36 |
$record->append_fields($control_number); |
| 37 |
my $date_time_transection = MARC::Field->new( '005', '20050131000000.0' ); |
| 38 |
$record->append_fields($date_time_transection); |
| 39 |
my $fixed_length = MARC::Field->new( '008', '040526t20042004nju b 001 0 eng d' ); |
| 40 |
$record->append_fields($fixed_length); |
| 41 |
|
| 42 |
my $LCCN = MARC::Field->new( |
| 43 |
'010','','', |
| 44 |
a => '2004051516' |
| 45 |
); |
| 46 |
$record->append_fields($LCCN); |
| 47 |
|
| 48 |
my $author = MARC::Field->new( |
| 49 |
'100',1,'', |
| 50 |
a => 'Logan, Robert K.', |
| 51 |
d => '1939-' |
| 52 |
); |
| 53 |
$record->append_fields($author); |
| 54 |
|
| 55 |
my $title = MARC::Field->new( |
| 56 |
'245','1','4', |
| 57 |
a => 'The alphabet effect /', |
| 58 |
c => 'Robert K. Logan.' |
| 59 |
); |
| 60 |
$record->append_fields($title); |
| 61 |
|
| 62 |
my $publisher = MARC::Field->new( |
| 63 |
'260','','', |
| 64 |
a => 'Cresskill, N.J. :', |
| 65 |
b => 'Hampton Press,', |
| 66 |
c => '[2004]' |
| 67 |
); |
| 68 |
$record->append_fields($publisher); |
| 69 |
|
| 70 |
my $physical_escription = MARC::Field->new( |
| 71 |
'300','','', |
| 72 |
a => 'xiv, 265 pages :', |
| 73 |
c => '24 cm' |
| 74 |
); |
| 75 |
$record->append_fields($physical_escription); |
| 76 |
|
| 77 |
my $bibliography = MARC::Field->new( |
| 78 |
'504','','', |
| 79 |
a => 'Includes bibliographical references (pages 247-255) and indexes' |
| 80 |
); |
| 81 |
$record->append_fields($bibliography); |
| 82 |
|
| 83 |
my $subject = MARC::Field->new( |
| 84 |
'650','','0', |
| 85 |
a => 'Alphabet', |
| 86 |
x => 'History.' |
| 87 |
); |
| 88 |
$record->append_fields($subject); |
| 89 |
|
| 90 |
ok( defined $record, 'Returned new()' ); |
| 91 |
ok( $record->isa('MARC::Record'), "Right class for creating MARC records" ); |
| 92 |
|
| 93 |
#Koha::Crosswalk::DublinCore object for XML metadata |
| 94 |
my $xml_dc_record = Koha::Crosswalk::DublinCore->new({ |
| 95 |
type => 'xml', |
| 96 |
qualified => 0, |
| 97 |
get_marc_record => $record |
| 98 |
}); |
| 99 |
|
| 100 |
#Koha::Crosswalk::DublinCore object for RDF metadata |
| 101 |
my $rdf_dc_record = Koha::Crosswalk::DublinCore->new({ |
| 102 |
type => 'rdf', |
| 103 |
qualified => 0, |
| 104 |
get_marc_record => $record, |
| 105 |
}); |
| 106 |
|
| 107 |
#OAI-DC |
| 108 |
my $test4 = qq(<?xml version="1.0" encoding="utf-8"?> |
| 109 |
<oai_dc:dc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> |
| 110 |
<dc:title>The alphabet effect / Robert K. Logan.</dc:title> |
| 111 |
<dc:creator>Logan, Robert K. 1939-</dc:creator> |
| 112 |
<dc:subject>Alphabet History.</dc:subject> |
| 113 |
<dc:description>Includes bibliographical references (pages 247-255) and indexes</dc:description> |
| 114 |
<dc:publisher>Cresskill, N.J. : Hampton Press,</dc:publisher> |
| 115 |
<dc:type>Text</dc:type> |
| 116 |
<dc:language>eng</dc:language> |
| 117 |
</oai_dc:dc> |
| 118 |
); |
| 119 |
|
| 120 |
#OAI-DC Data |
| 121 |
$xml_dc_record->get_xml_data({ |
| 122 |
root => 'oai_dc:dc', |
| 123 |
xsi_schemaLocation => 'http://www.openarchives.org/OAI/2.0/oai_dc/' . |
| 124 |
' http://www.openarchives.org/OAI/2.0/oai_dc.xsd', |
| 125 |
entities => 0, |
| 126 |
opt_namespace => 'oai_dc', |
| 127 |
opt_namespace_url => 'http://www.openarchives.org/OAI/2.0/oai_dc/' |
| 128 |
}); |
| 129 |
|
| 130 |
is ($xml_dc_record->write_xml(), $test4, "testing OAI-DC"); |
| 131 |
|
| 132 |
#SRW-DC |
| 133 |
my $test5 = qq(<?xml version="1.0" encoding="utf-8"?> |
| 134 |
<srw_dc:dc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/resources/dc-schema.xsd"> |
| 135 |
<dc:title>The alphabet effect / Robert K. Logan.</dc:title> |
| 136 |
<dc:creator>Logan, Robert K. 1939-</dc:creator> |
| 137 |
<dc:subject>Alphabet History.</dc:subject> |
| 138 |
<dc:description>Includes bibliographical references (pages 247-255) and indexes</dc:description> |
| 139 |
<dc:publisher>Cresskill, N.J. : Hampton Press,</dc:publisher> |
| 140 |
<dc:type>Text</dc:type> |
| 141 |
<dc:language>eng</dc:language> |
| 142 |
</srw_dc:dc> |
| 143 |
); |
| 144 |
|
| 145 |
# SRW-DC Data |
| 146 |
$xml_dc_record->get_xml_data({ |
| 147 |
root => 'srw_dc:dc', |
| 148 |
xsi_schemaLocation => 'info:srw/schema/1/dc-schema' . |
| 149 |
' http://www.loc.gov/standards/sru/resources/dc-schema.xsd', |
| 150 |
entities => 0, |
| 151 |
opt_namespace => 'srw_dc', |
| 152 |
opt_namespace_url => 'info:srw/schema/1/dc-schema' |
| 153 |
}); |
| 154 |
|
| 155 |
is ($xml_dc_record->write_xml(), $test5, "testing SRW-DC"); |
| 156 |
|
| 157 |
#Simple RDF-DC |
| 158 |
$rdf_dc_record->get_rdf_data({ |
| 159 |
rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#', |
| 160 |
rdf_format => 'rdfxml', |
| 161 |
entities => 0 |
| 162 |
}); |
| 163 |
|
| 164 |
my $test6 = qq(<?xml version="1.0" encoding="utf-8"?> |
| 165 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> |
| 166 |
<rdf:Description rdf:about="http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#"> |
| 167 |
\t<dc:creator>Logan, Robert K. 1939-</dc:creator> |
| 168 |
\t<dc:description>Includes bibliographical references (pages 247-255) and indexes</dc:description> |
| 169 |
\t<dc:language>eng</dc:language> |
| 170 |
\t<dc:publisher>Cresskill, N.J. : Hampton Press,</dc:publisher> |
| 171 |
\t<dc:subject>Alphabet History.</dc:subject> |
| 172 |
\t<dc:title>The alphabet effect / Robert K. Logan.</dc:title> |
| 173 |
\t<dc:type>Text</dc:type> |
| 174 |
</rdf:Description> |
| 175 |
</rdf:RDF> |
| 176 |
); |
| 177 |
|
| 178 |
is ($rdf_dc_record->write_rdf(), $test6, "testing Simple RDF-DC"); |
| 179 |
|
| 180 |
#RDF-DC (Recommendation)-rdfxml |
| 181 |
|
| 182 |
my $test7 = qq(<?xml version="1.0" encoding="utf-8"?> |
| 183 |
<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/"> |
| 184 |
<rdf:Description rdf:nodeID="DCMIType"> |
| 185 |
\t<dcam:memberOf rdf:resource="http://purl.org/dc/terms/DCMIType"/> |
| 186 |
\t<rdf:value>Text</rdf:value> |
| 187 |
</rdf:Description> |
| 188 |
<rdf:Description rdf:nodeID="LCSH"> |
| 189 |
\t<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/> |
| 190 |
\t<rdf:value>Alphabet History.</rdf:value> |
| 191 |
</rdf:Description> |
| 192 |
<rdf:Description rdf:nodeID="language"> |
| 193 |
\t<dcam:memberOf rdf:resource="http://purl.org/dc/terms/ISO639-2"/> |
| 194 |
\t<rdf:value>eng</rdf:value> |
| 195 |
</rdf:Description> |
| 196 |
<rdf:Description rdf:about="http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#"> |
| 197 |
\t<dcterms:created>[2004]</dcterms:created> |
| 198 |
\t<dcterms:creator>Logan, Robert K. 1939-</dcterms:creator> |
| 199 |
\t<dcterms:description>Includes bibliographical references (pages 247-255) and indexes</dcterms:description> |
| 200 |
\t<dcterms:extent>xiv, 265 pages :</dcterms:extent> |
| 201 |
\t<dcterms:issued>2004</dcterms:issued> |
| 202 |
\t<dcterms:issued>[2004]</dcterms:issued> |
| 203 |
\t<dcterms:language rdf:nodeID="language"/> |
| 204 |
\t<dcterms:publisher>Cresskill, N.J. : Hampton Press,</dcterms:publisher> |
| 205 |
\t<dcterms:subject rdf:nodeID="LCSH"/> |
| 206 |
\t<dcterms:title>The alphabet effect / Robert K. Logan.</dcterms:title> |
| 207 |
\t<dcterms:type rdf:nodeID="DCMIType"/> |
| 208 |
</rdf:Description> |
| 209 |
</rdf:RDF> |
| 210 |
); |
| 211 |
|
| 212 |
$rdf_dc_record->qualified(1); |
| 213 |
|
| 214 |
is ($rdf_dc_record->write_rdf(), $test7, "testing RDF-DC (Recommendation)"); |
| 215 |
|
| 216 |
my $test8 = qq(\@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
| 217 |
\@prefix dcterms: <http://purl.org/dc/terms/> . |
| 218 |
\@prefix dcam: <http://purl.org/dc/dcam/> . |
| 219 |
|
| 220 |
_:DCMIType dcam:memberOf dcterms:DCMIType ; |
| 221 |
\trdf:value "Text" . |
| 222 |
_:LCSH dcam:memberOf dcterms:LCSH ; |
| 223 |
\trdf:value "Alphabet History." . |
| 224 |
_:language dcam:memberOf dcterms:ISO639-2 ; |
| 225 |
\trdf:value "eng" . |
| 226 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> dcterms:created "[2004]" ; |
| 227 |
\tdcterms:creator "Logan, Robert K. 1939-" ; |
| 228 |
\tdcterms:description "Includes bibliographical references (pages 247-255) and indexes" ; |
| 229 |
\tdcterms:extent "xiv, 265 pages :" ; |
| 230 |
\tdcterms:issued "2004", "[2004]" ; |
| 231 |
\tdcterms:language _:language ; |
| 232 |
\tdcterms:publisher "Cresskill, N.J. : Hampton Press," ; |
| 233 |
\tdcterms:subject _:LCSH ; |
| 234 |
\tdcterms:title "The alphabet effect / Robert K. Logan." ; |
| 235 |
\tdcterms:type _:DCMIType . |
| 236 |
); |
| 237 |
|
| 238 |
$rdf_dc_record->rdf_format('turtle'); |
| 239 |
|
| 240 |
is ($rdf_dc_record->write_rdf(), $test8, "testing RDF-DC (Recommendation) in turtle format"); |
| 241 |
|
| 242 |
my $test9 = qq(_:DCMIType <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/DCMIType> . |
| 243 |
_:DCMIType <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "Text" . |
| 244 |
_:LCSH <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/LCSH> . |
| 245 |
_:LCSH <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "Alphabet History." . |
| 246 |
_:language <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/ISO639-2> . |
| 247 |
_:language <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "eng" . |
| 248 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/created> "[2004]" . |
| 249 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/creator> "Logan, Robert K. 1939-" . |
| 250 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/description> "Includes bibliographical references (pages 247-255) and indexes" . |
| 251 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/extent> "xiv, 265 pages :" . |
| 252 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/issued> "2004" . |
| 253 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/issued> "[2004]" . |
| 254 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/language> _:language . |
| 255 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/publisher> "Cresskill, N.J. : Hampton Press," . |
| 256 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/subject> _:LCSH . |
| 257 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/title> "The alphabet effect / Robert K. Logan." . |
| 258 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/type> _:DCMIType . |
| 259 |
); |
| 260 |
|
| 261 |
$rdf_dc_record->rdf_format('nquads'); |
| 262 |
|
| 263 |
is ($rdf_dc_record->write_rdf(), $test9, "testing RDF-DC (Recommendation) in nquads format"); |
| 264 |
|
| 265 |
my $test10 = qq({"_:LCSH":{"http://www.w3.org/1999/02/22-rdf-syntax-ns#value":[{"value":"Alphabet History.","type":"literal"}],"http://purl.org/dc/dcam/memberOf":[{"value":"http://purl.org/dc/terms/LCSH","type":"uri"}]},"http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#":{"http://purl.org/dc/terms/title":[{"value":"The alphabet effect / Robert K. Logan.","type":"literal"}],"http://purl.org/dc/terms/issued":[{"value":"2004","type":"literal"},{"value":"[2004]","type":"literal"}],"http://purl.org/dc/terms/type":[{"value":"_:DCMIType","type":"bnode"}],"http://purl.org/dc/terms/subject":[{"value":"_:LCSH","type":"bnode"}],"http://purl.org/dc/terms/description":[{"value":"Includes bibliographical references (pages 247-255) and indexes","type":"literal"}],"http://purl.org/dc/terms/publisher":[{"value":"Cresskill, N.J. : Hampton Press,","type":"literal"}],"http://purl.org/dc/terms/creator":[{"value":"Logan, Robert K. 1939-","type":"literal"}],"http://purl.org/dc/terms/language":[{"value":"_:language","type":"bnode"}],"http://purl.org/dc/terms/extent":[{"value":"xiv, 265 pages :","type":"literal"}],"http://purl.org/dc/terms/created":[{"value":"[2004]","type":"literal"}]},"_:language":{"http://www.w3.org/1999/02/22-rdf-syntax-ns#value":[{"value":"eng","type":"literal"}],"http://purl.org/dc/dcam/memberOf":[{"value":"http://purl.org/dc/terms/ISO639-2","type":"uri"}]},"_:DCMIType":{"http://www.w3.org/1999/02/22-rdf-syntax-ns#value":[{"value":"Text","type":"literal"}],"http://purl.org/dc/dcam/memberOf":[{"value":"http://purl.org/dc/terms/DCMIType","type":"uri"}]}}); |
| 266 |
|
| 267 |
$rdf_dc_record->rdf_format('rdfjson'); |
| 268 |
|
| 269 |
is ($rdf_dc_record->write_rdf(), $test10, "testing RDF-DC (Recommendation) in rdfjson format"); |
| 270 |
|
| 271 |
my $test11 = qq(_:DCMIType <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/DCMIType> . |
| 272 |
_:DCMIType <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "Text" . |
| 273 |
_:LCSH <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/LCSH> . |
| 274 |
_:LCSH <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "Alphabet History." . |
| 275 |
_:language <http://purl.org/dc/dcam/memberOf> <http://purl.org/dc/terms/ISO639-2> . |
| 276 |
_:language <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "eng" . |
| 277 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/created> "[2004]" . |
| 278 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/creator> "Logan, Robert K. 1939-" . |
| 279 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/description> "Includes bibliographical references (pages 247-255) and indexes" . |
| 280 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/extent> "xiv, 265 pages :" . |
| 281 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/issued> "2004" . |
| 282 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/issued> "[2004]" . |
| 283 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/language> _:language . |
| 284 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/publisher> "Cresskill, N.J. : Hampton Press," . |
| 285 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/subject> _:LCSH . |
| 286 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/title> "The alphabet effect / Robert K. Logan." . |
| 287 |
<http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=#> <http://purl.org/dc/terms/type> _:DCMIType . |
| 288 |
); |
| 289 |
|
| 290 |
$rdf_dc_record->rdf_format('ntriples'); |
| 291 |
|
| 292 |
is ($rdf_dc_record->write_rdf(), $test11, "testing RDF-DC (Recommendation) in ntriples format"); |
| 293 |
|