Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 924 Bytes

NG_XML_DATASTREAM.textile

File metadata and controls

25 lines (18 loc) · 924 Bytes

Setting the XML in a NokogiriDatastream from a file

Setting the Datastream’s XML

We will make this smoother soon, but right now you have to manually parse your new xml as a Nokogiri XML Document and then put the Nokogiri Document in the datastream’s ng_xml attribute.

Example (you will have to change the path to point to the xml file you want)

my_path = "../om/spec/fixtures/mods_articles/hydrangea_article1.xml"
f = File.new(my_path)
xml = Nokogiri::XML::Document.parse(f)
ha = HydrangeaArticle.new
ha.datastreams["descMetadata"].to_xml
ha.datastreams["descMetadata"].ng_xml = xml
ha.datastreams["descMetadata"].to_xml

Saving the Datastream

In order to make sure that your updated datastream is saved to fedora, call .save on the datastream. If you call .save on the object, the changes you’ve made to the datastream might not be saved.

ha.datastreams["descMetadata"].save