From 9311a8da7b4101968e7d50b2d225941f605709f2 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Wed, 1 Dec 2010 15:18:29 -0400 Subject: [PATCH] Added MODS to DC transform to book ingest. --- ilives/book.inc | 28 ++- ilives/fedora_ilives.module | 8 +- ilives/xsl/MODS3-22simpleDC.xsl | 409 ++++++++++++++++++++++++++++++++ 3 files changed, 441 insertions(+), 4 deletions(-) create mode 100644 ilives/xsl/MODS3-22simpleDC.xsl diff --git a/ilives/book.inc b/ilives/book.inc index d05f41d4..086a883a 100644 --- a/ilives/book.inc +++ b/ilives/book.inc @@ -121,10 +121,14 @@ class IslandoraBook { $new_item->add_datastream_from_string($form_values['mods']['mods_record'], 'MODS', 'MODS Metadata', 'text/xml', 'X'); + $dc = transform_mods_to_dc($form_values['mods']['mods_record']); + if ($dc) { + $new_item->modify_datastream_by_value($dc, 'DC', 'Dublin Core XML Metadata', 'text/xml'); + } $new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI); $new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']); } - + public function buildAddPagesForm($form = array()) { } @@ -248,3 +252,25 @@ function ilives_add_single_page_object($book_pid, $page_file, $page_num = 1, $pa $page_item->add_relationship('isMemberOf', $book_pid); $page_item->add_datastream_from_file($page_file, 'TIFF', 'Archival TIFF', 'image/tiff', 'M'); } + +function transform_mods_to_dc($mods) { + $xp = new XsltProcessor(); + // create a DOM document and load the XSL stylesheet + $xsl = new DomDocument; + $xsl->load(drupal_get_path('module', 'fedora_ilives').'/xsl/MODS3-22simpleDC.xsl'); + + // import the XSL styelsheet into the XSLT process + $xp->importStylesheet($xsl); + + // create a DOM document and load the XML datat + $xml_doc = new DomDocument; + $xml_doc->loadXML($mods); + + // transform the XML into HTML using the XSL file + if ($dc = $xp->transformToXML($xml_doc)) { + return $dc; + } + else { + return FALSE; + } +} \ No newline at end of file diff --git a/ilives/fedora_ilives.module b/ilives/fedora_ilives.module index 1e40ce7b..84a4b4a5 100644 --- a/ilives/fedora_ilives.module +++ b/ilives/fedora_ilives.module @@ -203,9 +203,11 @@ function fedora_ilives_create_book_view($pid, $query = NULL) { $simpleDCxml = simplexml_load_string($dc_xml); $types = $simpleDCxml->xpath('//dc:type'); $ingested = 'false'; - foreach ($types as $type) { - if ($type == 'ingested') { - $ingested = 'true'; + if (!empty($types)) { + foreach ($types as $type) { + if ($type == 'ingested') { + $ingested = 'true'; + } } } diff --git a/ilives/xsl/MODS3-22simpleDC.xsl b/ilives/xsl/MODS3-22simpleDC.xsl new file mode 100644 index 00000000..4a4eff8d --- /dev/null +++ b/ilives/xsl/MODS3-22simpleDC.xsl @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + . + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + -- + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + + + + + + + + + + + - + + + + + + + + + -- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Collection + + + DataSet + + + Service + + + Software + + + Image + + + InteractiveResource + + + MovingImage + + + PhysicalObject + + + Sound + + + StillImage + + + Text + + + Text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + + + + + + + -- + + + + + + + + + + + + + + + + + + + + + + , + + + + , + + + + + ( + + ) + + + ( + + ) + + + + + + + + + - + + + + + - + + + + + + + + + + + +