Report abuse

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
require 'rubygems'
require 'nokogiri'

puts ""

puts "SHOULD NOT BE THIS"

puts ""

record = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
  xml.send("OAI-PMH",
           :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
           :"xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd",
           :"xmlns" => "http://www.openarchives.org/OAI/2.0/") do
    xml.responseDate(Time.now.utc)
    xml.request({ :verb => "GetRecord", :metadataPrefix => "oai_dc" }, 'http://......./')
    xml.GetRecord do
        xml.header do
          xml.identifier
        end
        xml.metadata do
          xml.send("oai_dc:dc",
                   :"xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
                   :"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
                   :"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
                   :"xmlns:dcterms" => "http://purl.org/dc/terms/",
                   :"xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd") do
          end
        end
    end
  end
end
puts record.to_xml


# Gives this output:
#
# <?xml version="1.0" encoding="UTF-8"?>
# <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
#  <responseDate>Wed Dec 16 05:03:35 UTC 2009</responseDate>
#  <request metadataPrefix="oai_dc" verb="GetRecord">http://......./</request>
#  <GetRecord>
#    <header>
#      <identifier/>
#    </header>
#    <metadata>
#      <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"/>
#    </metadata>
#  </GetRecord>
#</OAI-PMH>

puts ""

puts "SHOULD BE THIS"

puts ""

record = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
  xml.send("OAI-PMH",
           "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
           "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd",
           "xmlns" => "http://www.openarchives.org/OAI/2.0/") do
    xml.responseDate(Time.now.utc)
    xml.request({ :verb => "GetRecord", :metadataPrefix => "oai_dc" }, 'http://......./')
    xml.GetRecord do
        xml.header do
          xml.identifier
        end
        xml.metadata do
          xml.send("oai_dc:dc",
                   "xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
                   "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
                   "xmlns:dc" => "http://purl.org/dc/elements/1.1/",
                   "xmlns:dcterms" => "http://purl.org/dc/terms/",
                   "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd") do
          end
        end
    end
  end
end
puts record.to_xml

# Gives this output:
# 
# <?xml version="1.0" encoding="UTF-8"?>
#<OAI-PMH xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
#  <responseDate>Wed Dec 16 05:03:35 UTC 2009</responseDate>
#  <request metadataPrefix="oai_dc" verb="GetRecord">http://......./</request>
#  <GetRecord>
#    <header>
#      <identifier/>
#    </header>
#    <metadata>
#      <oai_dc:dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"/>
#    </metadata>
#  </GetRecord>
#</OAI-PMH>

puts ""