Author: sevein
Date: Fri Jan  6 18:00:19 2012
New Revision: 10596

Log:
Update Archivematica METS document processor to match with new namespaces (see 
archivematica:issue879)

Modified:
   
trunk/plugins/qtSwordPlugin/lib/qtPackageExtractorMETSArchivematicaDIP.class.php

Modified: 
trunk/plugins/qtSwordPlugin/lib/qtPackageExtractorMETSArchivematicaDIP.class.php
==============================================================================
--- 
trunk/plugins/qtSwordPlugin/lib/qtPackageExtractorMETSArchivematicaDIP.class.php
    Fri Jan  6 17:33:03 2012        (r10595)
+++ 
trunk/plugins/qtSwordPlugin/lib/qtPackageExtractorMETSArchivematicaDIP.class.php
    Fri Jan  6 18:00:19 2012        (r10596)
@@ -19,9 +19,15 @@
 
 class qtPackageExtractorMETSArchivematicaDIP extends qtPackageExtractorBase
 {
-  protected function processDmdSec($xml)
+  protected function processDmdSec($xml, $informationObject)
   {
-    foreach ($xml->xpath('.//mdWrap/xmlData/dublincore/*') as $item)
+    $xml->registerXPathNamespace("m", "http://www.loc.gov/METS/";);
+
+    $dublincore = $xml->xpath('.//m:mdWrap/m:xmlData/*');
+    $dublincore = end($dublincore);
+    $dublincore->registerXPathNamespace("dc", "http://purl.org/dc/terms/";);
+
+    foreach ($dublincore as $item)
     {
       $value = trim($item->__toString());
       if (0 == strlen($value))
@@ -150,6 +156,8 @@
       throw new sfException('METS document could not be opened.');
     }
 
+    $this->document->registerXPathNamespace('m', 'http://www.loc.gov/METS/');
+
     $dipUUID = $this->getUUID($this->filename);
 
     // Main object
@@ -196,11 +204,11 @@
 
   protected function getMainDmdSec()
   {
-    $items = $this->document->xpath('//mets/structMap/div/div');
+    $items = $this->document->xpath('//m:mets/m:structMap/m:div/m:div');
 
     $id = $items[0]['DMDID'];
 
-    $dmdSec = $this->document->xpath('//mets/dmdSec[@ID="'.$id.'"]');
+    $dmdSec = $this->document->xpath('//m:mets/m:dmdSec[@ID="'.$id.'"]');
     if (0 < count($dmdSec))
     {
       return $dmdSec[0];
@@ -209,7 +217,7 @@
 
   protected function searchFileDmdSec($uuid)
   {
-    $node = $this->document->xpath('//mets/fileSec/fileGrp[@USE="original"]');
+    $node = 
$this->document->xpath('//m:mets/m:fileSec/m:fileGrp[@USE="original"]');
 
     if (empty($node))
     {
@@ -220,7 +228,7 @@
     {
       if (false !== strstr($item['ID'], $uuid))
       {
-        $dmdSec = 
$this->document->xpath('//mets/dmdSec[@ID="'.$item['DMDID'].'"]');
+        $dmdSec = 
$this->document->xpath('//m:mets/m:dmdSec[@ID="'.$item['DMDID'].'"]');
         if (0 < count($dmdSec))
         {
           return $dmdSec[0];

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to