Class: Dor::DublinCoreService
- Inherits:
-
Object
- Object
- Dor::DublinCoreService
- Defined in:
- lib/dor/services/dublin_core_service.rb
Defined Under Namespace
Classes: CrosswalkError
Constant Summary collapse
- MODS_TO_DC_XSLT =
Nokogiri::XSLT(File.new(File.(File.dirname(__FILE__) + '/mods2dc.xslt')))
- XMLNS_OAI_DC =
'http://www.openarchives.org/OAI/2.0/oai_dc/'
Instance Method Summary collapse
-
#initialize(work, include_collection_as_related_item: true) ⇒ DublinCoreService
constructor
A new instance of DublinCoreService.
-
#to_xml ⇒ Nokogiri::Doc
Generates Dublin Core from the MODS in the descMetadata datastream using the LoC mods2dc stylesheet Should not be used for the Fedora DC datastream.
Constructor Details
#initialize(work, include_collection_as_related_item: true) ⇒ DublinCoreService
Returns a new instance of DublinCoreService.
9 10 11 12 |
# File 'lib/dor/services/dublin_core_service.rb', line 9 def initialize(work, include_collection_as_related_item: true) @work = work @include_collection = end |
Instance Method Details
#to_xml ⇒ Nokogiri::Doc
Generates Dublin Core from the MODS in the descMetadata datastream using the LoC mods2dc stylesheet
Should not be used for the Fedora DC datastream
18 19 20 21 22 23 24 25 |
# File 'lib/dor/services/dublin_core_service.rb', line 18 def to_xml dc_doc = MODS_TO_DC_XSLT.transform(desc_md) dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]', oai_dc: XMLNS_OAI_DC).remove # Remove empty nodes raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no root):\n#{dc_doc.to_xml}" if dc_doc.root.nil? raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no children):\n#{dc_doc.to_xml}" if dc_doc.root.children.size == 0 dc_doc end |