aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/xml_md_oai_pmh_dc.rb
blob: 1d7008a125d4b3f062531cf71083d1dc4afa564e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
=begin

 * Name: SiSU

 * Description: a framework for document structuring, publishing and search

 * Author: Ralph Amissah

 * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
   2007 Ralph Amissah All Rights Reserved.

 * License: GPL 3 or later:

   SiSU, a framework for document structuring, publishing and search

   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
   2007 Ralph Amissah

   This program is free software: you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   Software Foundation, either version 3 of the License, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.

   You should have received a copy of the GNU General Public License along with
   this program. If not, see <http://www.gnu.org/licenses/>.

   If you have Internet connection, the latest version of the GPL should be
   available at these locations:
   <http://www.fsf.org/licenses/gpl.html>
   <http://www.gnu.org/copyleft/gpl.html>
   <http://www.jus.uio.no/sisu/gpl.fsf>

 * SiSU uses:
   * Standard SiSU markup syntax,
   * Standard SiSU meta-markup syntax, and the
   * Standard SiSU object citation numbering and system

 * Hompages:
   <http://www.jus.uio.no/sisu>
   <http://www.sisudoc.org>

 * Download:
   <http://www.jus.uio.no/sisu/SiSU/download.html>

 * Ralph Amissah
   <ralph@amissah.com>
   <ralph.amissah@gmail.com>

 ** Description: summary of generated outputs and metadata

=end
module SiSU_XML_metadata
  require "#{SiSU_lib}/sysenv"
  include SiSU_Env
  require "#{SiSU_lib}/param"
  include SiSU_Param
  class OAI_PMH
    def initialize(opt)
      @md=SiSU_Param::Parameters.new(opt).get
      @oai_pmh=[]
    end
    def read
      output
    end
    def pre
<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc
  xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
  http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
WOK
    end
    def body
      if @md.dc_title                                                            # DublinCore 1 - title
        @oai_pmh << %{  <dc:title xml:lang="en">#{@md.dc_title}</dc:title>\n}
        #@oai_pmh << %{  <dc:title xml:lang="en">#{seg_name}#{@md.dc_title}</dc:title>\n}
      end
      if @md.dc_creator                                                          # DublinCore 2 - creator/author (author)
        txt=meta_content_clean(@md.dc_creator)
        @oai_pmh << %{  <dc:creator>#{txt}</dc:creator>\n}
      end
      if @md.dc_subject                                                          # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
        txt=meta_content_clean(@md.dc_subject)
        @oai_pmh << %{  <dc:subject>#{txt}</dc:subject>\n}
      end
      if @md.dc_description                                                      # DublinCore 4 - description
        txt=meta_content_clean(@md.dc_description)
        @oai_pmh << %{  <dc:description>#{txt}</dc:description>\n}
      end
      if @md.dc_publisher                                                        # DublinCore 5 - publisher (current copy published by)
        txt=meta_content_clean(@md.dc_publisher)
        @oai_pmh << %{  <dc:publisher>#{txt}</dc:publisher>\n}
      end
      if @md.dc_contributor                                                      # DublinCore 6 - contributor
        txt=meta_content_clean(@md.dc_contributor)
        @oai_pmh << %{  <dc:contributor>#{txt}</dc:contributor>\n}
      end
      if @md.dc_date                                                             # DublinCore 7 - date year-mm-dd
        @oai_pmh << %{  <dc:date>#{@md.dc_date}</dc:date>\n}
      end
      if @md.dc_date_created                                                     # DublinCore 7 - date.created
        @oai_pmh << %{  <dc:date_created>#{@md.dc_date_created}</dc:date_created>\n}
      end
      if @md.dc_date_issued                                                      # DublinCore 7 - date.issued
        @oai_pmh << %{  <dc:date_issued>#{@md.dc_date_issued}</dc:date_issued>\n}
      end
      if @md.dc_date_available                                                   # DublinCore 7 - date.available
        @oai_pmh << %{  <dc:date_available>#{@md.dc_date_available}</dc:date_available>\n}
      end
      if @md.dc_date_valid                                                       # DublinCore 7 - date.valid
        @oai_pmh << %{  <dc:date_valid>#{@md.dc_date_valid}</dc:date_valid>\n}
      end
      if @md.dc_date_modified                                                    # DublinCore 7 - date.modified
        @oai_pmh <<  %{  <dc:date_modified>#{@md.dc_date_modified}</dc:date_modified>\n}
      end
      if @md.dc_type                                                             # DublinCore 8 - type
        txt=meta_content_clean(@md.dc_type)
        @oai_pmh << %{  <dc:type>#{txt}</dc:type>\n}
      end
      if @md.dc_format                                                           # DublinCore 9 - format
        txt=meta_content_clean(@md.dc_format)
        @oai_pmh << %{  <dc:format>#{txt}</dc:format>\n}
      end
      if @md.dc_identifier                                                       # DublinCore 10 - identifier
        txt=meta_content_clean(@md.dc_identifier)
        @oai_pmh << %{  <dc:identifier>#{txt}</dc:identifier>\n}
      end
      if @md.dc_source                                                           # DublinCore 11 - source
        txt=meta_content_clean(@md.dc_source)
        @oai_pmh << %{  <dc:source>#{txt}</dc:source>\n}
      end
      if @md.dc_language[:name]                                                  # DublinCore 12 - language (English)
        @oai_pmh << %{  <dc:language>#{@md.dc_language[:name]}</dc:language>\n}
      end
      if @md.language_original[:name]
        @oai_pmh << %{  <dc:language>#{@md.language_original[:name]}</dc:language>\n}
      end
      if @md.dc_relation                                                         # DublinCore 13 - relation
        txt=meta_content_clean(@md.dc_relation)
        @oai_pmh << %{  <dc:relation>#{txt}</dc:relation>\n}
      end
      if @md.dc_coverage                                                         # DublinCore 14 - coverage
        txt=meta_content_clean(@md.dc_coverage)
        @oai_pmh << %{  <dc:coverage>#{txt}</dc:coverage>\n}
      end
      if @md.dc_rights                                                           # DublinCore 15 - rights
        txt=meta_content_clean(@md.dc_rights)
        @oai_pmh << %{  <dc:rights>#{txt}</dc:rights>\n}
      end
      if @md.keywords
        txt=meta_content_clean(@md.keywords)
        @oai_pmh << %{  <dc:keywords>#{txt}</dc:keywords>\n}
      end
      @oai_pmh
    end
    def meta_content_clean(content='')
      unless content.nil?
        content.tr!('"',"'")
      end
      content
    end
    def post
      '</oai_dc:dc>'
    end
    def output
      SiSU_Env::SiSU_file.new(@md).mkdir
      oai_pmh=SiSU_Env::SiSU_file.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param
      oai_pmh << pre
      body.each do |x|
        oai_pmh << x
      end
      oai_pmh << post
    end
  end
end
__END__
http://www.openarchives.org/pmh/
http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
http://es.dublincore.org/documents/usageguide/elements.shtml
http://dublincore.org/documents/dces/
see also http://dublincore.org/documents/dcmes-xml/
#http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
#sample implementation, e.g. 2
<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc
    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
    http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
  <dc:title xml:lang="en">Grassmann's space analysis</dc:title>
  <dc:creator>Hyde, E. W. (Edward Wyllys)</dc:creator>
  <dc:subject>LCSH:Ausdehnungslehre; LCCN QA205.H99</dc:subject>
  <dc:publisher>J. Wiley &amp; Sons</dc:publisher>
  <dc:date>Created: 1906; Available: 1991</dc:date>
  <dc:type>text</dc:type>
  <dc:identifier>http://resolver.library.cornell.edu/math/1796949
     </dc:identifier>
  <dc:language>english</dc:language>
  <dc:rights xml:lang="en">Public Domain</dc:rights>
</oai_dc:dc>