7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/eac.rb', line 7
def parse(content)
xml_doc = Nokogiri::XML(content)
entity_types = xml_doc.xpath("//ns:cpfDescription/ns:identity/ns:entityType",
ns:'urn:isbn:1-931666-33-4')
if entity_types.nil? || entity_types.length < 1
raise ArgumentError.new("entityType not found")
end
if entity_types.length > 1
puts "unexpected multiple entity types:#{entity_types.length} (choosing first)"
end
type = entity_types[0].text
entity = case type
when "person"
Person.new(xml_doc)
else
Doc.new(xml_doc)
end
end
|