Index: content_taxonomy.inc
===================================================================
--- content_taxonomy.inc	(revision 9190)
+++ content_taxonomy.inc	(working copy)
@@ -15,8 +15,11 @@
  *  $this->addFieldMapping('field_content_taxonomy', 'term');
  *
  *  // Import source field "content_taxonomy" containing names into
- *  // destination field field_content_taxonomy:
- *  $arguments = MigrateContentTaxonomyFieldHandler::arguments('name');
+ *  // destination field field_content_taxonomy and optionally telling which 
+ *  // vocabulary to search in (in case you have equal terms name in several
+ *  // vocabularies):
+ *  $arguments = MigrateContentTaxonomyFieldHandler::arguments('name', 4);
+ *  // 4 is the vid of the vocabulary to serach in
  *  $this->addFieldMapping('field_content_taxonomy', 'term')
  *    ->arguments($arguments);
  */
@@ -29,22 +32,40 @@
     $this->registerTypes(array('content_taxonomy'));
   }
 
-  static function arguments($mode = 'tid') {
-    return array('mode' => $mode);
+  static function arguments($mode = 'tid', $vid = 0) {
+    return array('mode' => $mode, 'vid' => $vid);
   }
 
   public function prepare($entity, array $instance, array $values) {
     $mode = $values['arguments']['mode'];
+    $vid = $values['arguments']['vid'];
 
+    //remove arguments else they will be searched too
+    unset($values['arguments']);
+    $values = array_values($values);
+
+    $return = array();
+
     // Setup the standard Field API array for saving.
     $delta = 0;
     foreach ($values as $value) {
-      if ( $mode == 'name' ) {
-        $query = db_select('term_data', 'td')
-          ->fields('td', array('tid'))
-          ->condition('name', $value, '=');
+      if ($mode == 'name') {
+        if ($vid > 0) {
+          $query = db_select('term_data', 'td')
+                  ->fields('td', array('tid'))
+                  ->condition('name', $value, '=')
+                  ->condition('vid', $vid, '=');
+        } else {
+          $query = db_select('term_data', 'td')
+                  ->fields('td', array('tid'))
+                  ->condition('name', $value, '=');
+        }
         $result = $query->execute();
         $record = $result->fetchAssoc();
+        if ($record['tid'] == 0) {
+          //dvm('Term not found: '.$value);
+          continue;
+        }
         $value = $record['tid'];
       }
       $item = array();
@@ -53,7 +74,7 @@
       $return[$delta] = $item;
       $delta++;
     }
+    return empty($return) ? NULL : $return;
+  }
 
-    return isset($return) ? $return : NULL;
-  }
 }
\ No newline at end of file
