=== modified file 'sites/all/modules/feeds_xpathparser/FeedsXPathParser.inc'
--- sites/all/modules/feeds_xpathparser/FeedsXPathParser.inc	2010-09-16 13:14:32 +0000
+++ sites/all/modules/feeds_xpathparser/FeedsXPathParser.inc	2010-09-16 20:24:49 +0000
@@ -38,9 +38,12 @@ class FeedsXPathParser extends FeedsPars
    */
   public function parse(FeedsImportBatch $batch, FeedsSource $source) {
 
-    $mappings = feeds_importer($this->id)->processor->config['mappings'];
-    if (empty($mappings)) {
-      throw new Exception(t('FeedsXPathParser: No mappings were defined.'));
+    $mappings = array();
+    if (empty(feeds_importer($this->id)->processor->config['mapping_on_import'])) {
+      $mappings = feeds_importer($this->id)->processor->getMappings();
+      if (empty($mappings)) {
+        throw new Exception(t('FeedsXPathParser: No mappings were defined.'));
+      }
     }
     $source_config = $source->getConfigFor($this);
 
@@ -61,7 +64,10 @@ class FeedsXPathParser extends FeedsPars
    * Define defaults.
    */
   public function sourceDefaults() {
-    return array('XML' => 0);
+    return array(
+      'parser_type' => 'HTML',
+      'context' => '',
+    );
   }
 
   /**
@@ -71,7 +77,8 @@ class FeedsXPathParser extends FeedsPars
     $form = array();
     $form['#weight'] = -10;
 
-    $mappings = feeds_importer($this->id)->processor->config['mappings'];
+    $mappings = feeds_importer($this->id)->processor->getMappings();
+    $mapping_on_import = !empty(feeds_importer($this->id)->processor->config['mapping_on_import']);
     $sources = $uniques = array();
 
     foreach ($mappings as $mapping) {
@@ -82,8 +89,13 @@ class FeedsXPathParser extends FeedsPars
     }
 
     if (empty($sources)) {
-      $form['message']['#value'] = 'FeedsXPathParser: No mappings were defined.';
-      return $form;
+      if ($mapping_on_import) {
+        $form['sources']['#value'] = 'FeedsXPathParser: Mappings need to be defined later, based on the parsed context.';
+      }
+      else {
+        $form['message']['#value'] = 'FeedsXPathParser: No mappings were defined.';
+        return $form;
+      }
     }
 
     ctools_include('dependent');
@@ -133,18 +145,20 @@ class FeedsXPathParser extends FeedsPars
       '#default_value' => isset($source_config['context']) ? $source_config['context'] : '',
     );
 
-    $form['sources'] = array(
-      '#type' => 'fieldset',
-    );
-    $items = array(
-      format_plural(count($uniques),
-        t('Field <strong>!column</strong> is mandatory and considered unique: only one item per !column value will be created.',
-          array('!column' => implode(', ', $uniques))),
-        t('Fields <strong>!columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these columns will be created.',
-          array('!columns' => implode(', ', $uniques)))),
-    );
+    if (!empty($sources)) {
+      $form['sources'] = array(
+        '#type' => 'fieldset',
+      );
+      $items = array(
+        format_plural(count($uniques),
+          t('Field <strong>!column</strong> is mandatory and considered unique: only one item per !column value will be created.',
+            array('!column' => implode(', ', $uniques))),
+          t('Fields <strong>!columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these columns will be created.',
+            array('!columns' => implode(', ', $uniques)))),
+      );
 
-    $form['sources']['help']['#value'] = '<div class="help">' . theme('item_list', $items) . '</div>';
+      $form['sources']['help']['#value'] = '<div class="help">' . theme('item_list', $items) . '</div>';
+    }
 
     $form['attrs'] = array(
       '#type' => 'fieldset',
@@ -173,27 +187,30 @@ class FeedsXPathParser extends FeedsPars
       );
     }
 
-    $form['rawXML'] = array(
-      '#type'          => 'checkboxes',
-      '#title'         => t('Select the queries you would like to return raw XML or HTML'),
-      '#options'       => array_combine($sources, $sources),
-      '#process'       => array('ctools_dependent_process', 'expand_checkboxes'),
-      '#prefix'        => '<div id="edit-feeds-FeedsXPathParser-rawXML-wrapper"><div id="edit-feeds-FeedsXPathParser-rawXML">',
-      '#suffix'        => '</div></div>',
-      '#default_value' => isset($source_config['rawXML']) ? $source_config['rawXML'] : array(),
-      '#dependency'    => array(
-        'radio:feeds[FeedsXPathParser][parser_type]' => array(
-          'HTML', 'XML', 'QueryPath',
-        )
-      ),
-    );
+    if (!empty($sources)) {
+      /// NOTE: haven't thought about how to implement this with 'mapping on import'
+      $form['rawXML'] = array(
+        '#type'          => 'checkboxes',
+        '#title'         => t('Select the queries you would like to return raw XML or HTML'),
+        '#options'       => array_combine($sources, $sources),
+        '#process'       => array('ctools_dependent_process', 'expand_checkboxes'),
+        '#prefix'        => '<div id="edit-feeds-FeedsXPathParser-rawXML-wrapper"><div id="edit-feeds-FeedsXPathParser-rawXML">',
+        '#suffix'        => '</div></div>',
+        '#default_value' => isset($source_config['rawXML']) ? $source_config['rawXML'] : array(),
+        '#dependency'    => array(
+          'radio:feeds[FeedsXPathParser][parser_type]' => array(
+            'HTML', 'XML', 'QueryPath',
+          )
+        ),
+      );
+    }
 
     return $form;
   }
 
   /**
-  * Override parent::getMappingSources().
-  */
+   * Override parent::getMappingSources().
+   */
   public function getMappingSources() {
     return FALSE;
   }

=== modified file 'sites/all/modules/feeds_xpathparser/FeedsXPathParserHTML.inc'
--- sites/all/modules/feeds_xpathparser/FeedsXPathParserHTML.inc	2010-08-16 22:17:20 +0000
+++ sites/all/modules/feeds_xpathparser/FeedsXPathParserHTML.inc	2010-08-26 18:10:56 +0000
@@ -48,8 +48,17 @@ class FeedsXPathParserHTML {
       throw new Exception(t('There was an error with the XPath query: %query',
                             array('%query' => $this->sourceConfig['context'])));
     }
+    elseif (!$all_items) {
+      drupal_set_message(t("The XPath query: '%query' returned zero results", array('%query' => $this->sourceConfig['context'])), 'warning');
+    }
     unset($xml);
 
+    // If we did not predefine any mappings (which is possible if the processor
+    // is set to 'mapping on import'), then $this->sources is empty. We're done.
+    if (!$this->sources) {
+      return $all_items;
+    }
+
     $parsed_items = array();
     foreach ($all_items as $item) {
       $item = $item->asXML();

