Sha256: a36988fd0ad41304268ce24221b1d21ffe1c445ab657f2b4692fc06fcf087e76

Contents?: true

Size: 924 Bytes

Versions: 14

Compression:

Stored size: 924 Bytes

Contents

h1. Setting the XML in a NokogiriDatastream from a file

h2. 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)

<pre>
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
</pre>

h2. 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.

<pre>
ha.datastreams["descMetadata"].save
</pre>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
active-fedora-2.2.0 NG_XML_DATASTREAM.textile
active-fedora-2.1.0 NG_XML_DATASTREAM.textile
active-fedora-2.0.4 NG_XML_DATASTREAM.textile
active-fedora-2.0.3 NG_XML_DATASTREAM.textile
active-fedora-2.0.2 NG_XML_DATASTREAM.textile
active-fedora-2.0.1 NG_XML_DATASTREAM.textile
active-fedora-2.0.0 NG_XML_DATASTREAM.textile
active-fedora-1.2.9 NG_XML_DATASTREAM.textile
active-fedora-1.2.8 NG_XML_DATASTREAM.textile
active-fedora-1.2.7 NG_XML_DATASTREAM.textile
active-fedora-1.2.6 NG_XML_DATASTREAM.textile
active-fedora-1.2.5 NG_XML_DATASTREAM.textile
active-fedora-1.2.4 NG_XML_DATASTREAM.textile
active-fedora-1.2.3 NG_XML_DATASTREAM.textile