Author: sevein
Date: Sun Oct 16 00:42:29 2011
New Revision: 10118

Log:
Parse METS.xml correctly, get files and dir metadata

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

Modified: trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php
==============================================================================
--- trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php        Fri Oct 
14 16:40:27 2011        (r10117)
+++ trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php        Sun Oct 
16 00:42:29 2011        (r10118)
@@ -57,7 +57,7 @@
       $informationObject = new QubitInformationObject;
     }
 
-    foreach ($xml->xpath('mdWrap/xmlData/dublincore/dcterms:*') as $item)
+    foreach ($xml->xpath('.//mdWrap/xmlData/dublincore/dcterms:*') as $item)
     {
       switch($item->getName())
       {
@@ -156,8 +156,8 @@
     $this->informationObject->setPublicationStatus($publicationStatus);
 
     // Main object
-    $main = $this->getMainDmdSec();
-    $this->processDmdSec($main, $this->informationObject);
+    $dmdSec = $this->getMainDmdSec();
+    $this->processDmdSec($dmdSec, $this->informationObject);
 
     foreach ($this->getFilesFromDirectory() as $item)
     {
@@ -168,9 +168,9 @@
       $child = new QubitInformationObject;
       $child->setPublicationStatus($publicationStatus);
 
-      if (null !== $fptr = $this->searchFptr($uuid) && isset($fptr['DMID']))
+      if (null !== ($dmdSec = $this->searchFileDmdSec($uuid)))
       {
-        // processDmdSec()
+        $this->processDmdSec($dmdSec, $child);
       }
 
       $digitalObject = new QubitDigitalObject;
@@ -192,36 +192,27 @@
 
   protected function getMainDmdSec()
   {
-    $items = $this->document->xpath('/mets/structMap/div/div');
+    $items = $this->document->xpath('//mets/structMap/div/div');
 
-    $id = $items[0]['DMID']; $id = 'SIP-description';
+    $id = $items[0]['DMDID'];
 
-    $dmdSec = $this->document->xpath("/mets/dmdSec[@ID='$id']");
+    $dmdSec = $this->document->xpath('//mets/dmdSec[@ID="'.$id.'"]');
 
-    return $dmdSec['0'];
+    return $dmdSec[0];
   }
 
-  protected function searchFptr($uuid, $node = null)
+  protected function searchFileDmdSec($uuid)
   {
-    if (!isset($node))
-    {
-      $node = $this->document->xpath('/mets/structMap/div/div');
-      $node = $node[0];
-    }
+    $node = $this->document->xpath('//mets/fileSec/fileGrp[@USE="original"]');
 
-    foreach ($node->children() as $item)
+    foreach ($node[0] as $item)
     {
-      $name = $item->getName();
-
-      if ('div' == $name)
-      {
-        return $this->searchFptr($uuid, $item);
-      }
-      else if ('fptr' == $name)
+      if (false !== strstr($item['ID'], $uuid))
       {
-        if (false !== strstr($item['FILEID'], $uuid))
+        $dmdSec = 
$this->document->xpath('//mets/dmdSec[@ID="'.$item['DMDID'].'"]');
+        if (0 < count($dmdSec))
         {
-          return $item;
+          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