source: gsdl/trunk/runtime-src/src/oaiservr/dublincore.cpp@ 18895

Last change on this file since 18895 was 18895, checked in by kjdon, 15 years ago

added is_valid_element to metaformat, which checks elementSet for the element name. metaformat subclass constructors must set up elementSet. Currently they do this in the code. would be good if it could read in from a file eventually, maybe?? When metaformat is outputting the m,etadata, it checks whether the element is valid before outputting. otherwise it will invalidate the response as it won't conform to the schema. also, changed where we lowercased the entire name to lowercasing only the first letter - some qdc fields have an internal upper case letter.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1
2#include "dublincore.h"
3
4dublin_core::dublin_core() : metaformat() {
5 // These element names taken from the schema
6 // http://www.openarchives.org/OAI/2.0/oai_dc.xsd
7 elementSet.insert("contributor");
8 elementSet.insert("coverage");
9 elementSet.insert("creator");
10 elementSet.insert("date");
11 elementSet.insert("description");
12 elementSet.insert("format");
13 elementSet.insert("identifier");
14 elementSet.insert("language");
15 elementSet.insert("publisher");
16 elementSet.insert("relation");
17 elementSet.insert("rights");
18 elementSet.insert("source");
19 elementSet.insert("subject");
20 elementSet.insert("title");
21 elementSet.insert("type");
22
23
24}
25
26const text_t dublin_core::formatName() {
27 return "oai_dc";
28}
29
30const text_t dublin_core::formatPrefix() {
31 return "dc";
32}
33
34bool dublin_core::output_record(ostream &output, recptproto *protocol, const text_t &collection,
35 const text_t &record_OID)
36{
37 return metaformat::output_record(output, protocol, collection, record_OID);
38}
39
40void dublin_core::output_metadata_header(ostream &output)
41{
42 output << " <metadata>\n";
43
44 if (this->oaiConfigure->getOAIVersion() <= 110){
45 // output dublin core wrapper for OAI v1.1
46 output << " <dc xmlns=\"http://purl.org/dc/elements/1.1/\"\n"
47 << " xmlns:xsi=\"http://www.w3c.org/2001/XMLSchema-instance\"\n"
48 << " xsi:schemaLocation=\"http://purl.org/dc/elements/1.1/\n"
49 << " http://www.openarchives.org/OAI/1.1/dc.xsd\">\n";
50 }
51 else {
52 output << " <oai_dc:dc\n"
53 << " xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\"\n"
54 << " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
55 << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
56 << " xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/\n"
57 << " http://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n";
58 }
59}
60
61void dublin_core::output_metadata_footer(ostream &output)
62{
63 if (this->oaiConfigure->getOAIVersion() <= 110) {
64 output << " </dc>" << endl;
65 }
66 else {
67 output << " </oai_dc:dc>" << endl;
68 }
69
70 output << " </metadata>" << endl;
71 output.flush();
72}
73
74bool dublin_core::output_formatdata(ostream &output)
75{
76 output << " <metadataPrefix>oai_dc</metadataPrefix>" << endl;
77
78 if (this->oaiConfigure->getOAIVersion() <= 110) {
79 output << " <schema>http://www.openarchives.org/OAI/1.1/dc.xsd</schema>" << endl
80 << " <metadataNamespace>http://purl.org/dc/elements/1.1/</metadataNamespace>" << endl;
81 }
82 else {
83 output << " <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>" << endl
84 << " <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>"
85 << endl;
86 }
87 return true;
88}
89
Note: See TracBrowser for help on using the repository browser.