Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.24
diff -u -p -r1.24 rdf.module
--- modules/rdf/rdf.module	12 Feb 2010 06:44:13 -0000	1.24
+++ modules/rdf/rdf.module	14 Feb 2010 16:18:25 -0000
@@ -355,12 +355,27 @@ function rdf_process(&$variables, $hook)
   // @see theme_rdf_template_variable_wrapper()
   if (!empty($variables['rdf_template_variable_attributes_array'])) {
     foreach ($variables['rdf_template_variable_attributes_array'] as $variable_name => $attributes) {
+      $parent_element = &$variables;
+      // Check to see if the element passed in is unrendered. If it is, make
+      // sure that we have reached the lowest child element in the array.
+      while (!is_string($variables[$variable_name]) && !isset($variables[$variable_name]['#markup'])) {
+        $parent_element = &$parent_element[$variable_name];
+        $variable_name = key($attributes);
+        $attributes = $attributes[$variable_name];
+      }
       $context = array(
         'hook' => $hook,
         'variable_name' => $variable_name,
         'variables' => $variables,
       );
-      $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
+      // If this is a rendered element, simply wrap the whole element.
+      if (is_string($parent_element[$variable_name])) {
+        $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
+      }
+      // If this is an unrendered element, wrap its markup value.
+      else if (isset($parent_element[$variable_name]['#markup'])) {
+        $parent_element[$variable_name]['#markup'] = theme('rdf_template_variable_wrapper', array('content' => $parent_element[$variable_name]['#markup'], 'attributes' => $attributes, 'context' => $context));
+      }
     }
   }
   // Handles additional attributes about a template entity that for RDF parsing
