lib/om/xml/container.rb in om-0.1.7 vs lib/om/xml/container.rb in om-0.1.8
- old
+ new
@@ -7,16 +7,22 @@
module ClassMethods
# @xml String, File or Nokogiri::XML::Node
# @tmpl ActiveFedora::MetadataDatastream
# Careful! If you call this from a constructor, be sure to provide something 'ie. self' as the @tmpl. Otherwise, you will get an infinite loop!
- def from_xml(xml, tmpl=self.new) # :nodoc:
- if xml.kind_of? Nokogiri::XML::Node
+ def from_xml(xml=nil, tmpl=self.new) # :nodoc:
+ if xml.nil?
+ tmpl.ng_xml = self.xml_template
+ elsif xml.kind_of? Nokogiri::XML::Node
tmpl.ng_xml = xml
else
tmpl.ng_xml = Nokogiri::XML::Document.parse(xml)
end
return tmpl
+ end
+
+ def xml_template
+ Nokogiri::XML::Document.parse("")
end
end
# Instance Methods -- These methods will be available on instances of classes that include this module
\ No newline at end of file