Class: UWDC::XML
- Inherits:
-
Object
- Object
- UWDC::XML
- Extended by:
- HTTPClient::IncludeClient
- Defined in:
- lib/uwdc/xml.rb
Overview
Read or Fetch METS XML files
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#status ⇒ Object
Returns the value of attribute status.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #http_xml(xml, status) ⇒ Object
-
#initialize(id, xml = nil, status = nil) ⇒ XML
constructor
A new instance of XML.
- #nokogiri_parse(xml) ⇒ Object
Constructor Details
#initialize(id, xml = nil, status = nil) ⇒ XML
Returns a new instance of XML.
9 10 11 12 |
# File 'lib/uwdc/xml.rb', line 9 def initialize(id, xml=nil, status=nil) @id ||= id @xml,@status = http_xml(xml,status) end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
7 8 9 |
# File 'lib/uwdc/xml.rb', line 7 def nodes @nodes end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/uwdc/xml.rb', line 7 def status @status end |
#xml ⇒ Object
Returns the value of attribute xml.
7 8 9 |
# File 'lib/uwdc/xml.rb', line 7 def xml @xml end |
Instance Method Details
#http_xml(xml, status) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/uwdc/xml.rb', line 14 def http_xml(xml,status) unless xml begin # http://depot.library.wisc.edu:9090/fedora/objects/1711.dl:33QOBSVPJLWEM8S/methods/1711.dl:SDefineFirstClassObject/viewMets #response = http_client.get("http://depot.library.wisc.edu/uwdcutils/METS/1711.dl:#{@id}") response = http_client.get("http://depot.library.wisc.edu:9090/fedora/objects/1711.dl:#{@id}/methods/1711.dl:SDefineFirstClassObject/viewMets") xml = response.body status = response.status rescue TimeoutError, HTTPClient::ConfigurationError, HTTPClient::BadResponseError, Nokogiri::SyntaxError => error exception = error end end [xml,status] end |
#nokogiri_parse(xml) ⇒ Object
33 34 35 36 |
# File 'lib/uwdc/xml.rb', line 33 def nokogiri_parse(xml) nodes = Nokogiri::XML.parse(xml) nodes.remove_namespaces! end |