Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1125
diff -u -p -r1.1125 common.inc
--- includes/common.inc	7 Mar 2010 23:14:20 -0000	1.1125
+++ includes/common.inc	8 Mar 2010 16:48:17 -0000
@@ -256,8 +256,12 @@ function drupal_get_breadcrumb() {
 function drupal_get_rdf_namespaces() {
   // Serialize the RDF namespaces used in RDFa annotation.
   $xml_rdf_namespaces = array();
-  foreach (module_invoke_all('rdf_namespaces') as $prefix => $uri) {
-    $xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
+  foreach (rdf_get_rdf_namespaces_array() as $prefix => $uri) {
+    // Do not include prefixes that are defined for more than one URI.
+    // Otherwise we may make inaccurate statements in RDF.
+    if (!is_array($uri)) {
+      $xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
+    }
   }
   return implode("\n  ", $xml_rdf_namespaces);
 }
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1245
diff -u -p -r1.1245 node.module
--- modules/node/node.module	8 Mar 2010 02:41:46 -0000	1.1245
+++ modules/node/node.module	8 Mar 2010 16:48:17 -0000
@@ -765,41 +765,43 @@ function node_type_set_defaults($info = 
  * Implements hook_rdf_mapping().
  */
 function node_rdf_mapping() {
+  $ns = rdf_rdf_namespaces();
+  
   return array(
     array(
       'type' => 'node',
       'bundle' => RDF_DEFAULT_BUNDLE,
       'mapping' => array(
-        'rdftype' => array('sioc:Item', 'foaf:Document'),
+        'rdftype' => array(rdf_get_curie($ns['sioc'], 'Item'), rdf_get_curie($ns['foaf'], 'Document')),
         'title' => array(
-          'predicates' => array('dc:title'),
+          'predicates' => array(rdf_get_curie($ns['dc'], 'title')),
         ),
         'created' => array(
-          'predicates' => array('dc:date', 'dc:created'),
+          'predicates' => array(rdf_get_curie($ns['dc'], 'date'), rdf_get_curie($ns['dc'], 'created')),
           'datatype' => 'xsd:dateTime',
           'callback' => 'date_iso8601',
         ),
         'changed' => array(
-          'predicates' => array('dc:modified'),
+          'predicates' => array(rdf_get_curie($ns['dc'], 'modified')),
           'datatype' => 'xsd:dateTime',
           'callback' => 'date_iso8601',
         ),
         'body' => array(
-          'predicates' => array('content:encoded'),
+          'predicates' => array(rdf_get_curie($ns['content'], 'encoded')),
         ),
         'uid' => array(
-          'predicates' => array('sioc:has_creator'),
+          'predicates' => array(rdf_get_curie($ns['sioc'], 'has_creator')),
           'type' => 'rel',
         ),
         'name' => array(
-          'predicates' => array('foaf:name'),
+          'predicates' => array(rdf_get_curie($ns['foaf'], 'name')),
         ),
         'comment_count' => array(
-          'predicates' => array('sioc:num_replies'),
+          'predicates' => array(rdf_get_curie($ns['sioc'], 'num_replies')),
           'datatype' => 'xsd:integer',
         ),
         'last_activity' => array(
-          'predicates' => array('sioc:last_activity_date'),
+          'predicates' => array(rdf_get_curie($ns['sioc'], 'last_activity_date')),
           'datatype' => 'xsd:dateTime',
           'callback' => 'date_iso8601',
         ),
Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.30
diff -u -p -r1.30 rdf.module
--- modules/rdf/rdf.module	7 Mar 2010 07:08:41 -0000	1.30
+++ modules/rdf/rdf.module	8 Mar 2010 16:48:17 -0000
@@ -799,3 +799,57 @@ function theme_rdf_metadata($variables) 
   }
   return $output;
 }
+
+function rdf_get_curie($uri, $term_name) {
+  $rdf_namespaces = rdf_get_rdf_namespaces_array();
+
+  foreach($rdf_namespaces as $prefix => $ns_uri) {
+    // If rdf_get_rdf_namespaces_array() has returned an array value for the
+    // prefix, at least two namespaces have been defined for the prefix. Set a
+    // message and return an empty string so the term is not saved in the
+    // mapping.
+    if (is_array($ns_uri)) {
+      for ($i=0; $i < count($ns_uri); $i++) {
+        if ($uri == $ns_uri[$i]) {
+          drupal_set_message(t('The namespace prefix for @uri is defined with two or more unique URIs. Term @term has not been saved. Changing the prefix for @uri2 is recommended.', array('@uri' => $uri, '@term' => $prefix . ':' . $term_name, '@uri2' => $ns_uri[1])), 'warning');
+          return '';
+          // @todo Since the term was not saved in the mapping, the user will
+          // need to redefine the prefix and reinstall the module that defined
+          // the mapping. Because rdf_get_curie handles prefixes dynamically,
+          // we could probably solve this clunky user interaction as well.
+        }
+      }
+    }
+    // If the current URI matches the URI passed in as a parameter, then this is
+    // the prefix to use. Set the CURIE.
+    else if ($uri == $ns_uri) {
+      $curie = $prefix . ':' . $term_name;
+    }
+  }
+  if (isset($curie)) {
+    return $curie;
+  }
+  // If the URI was not found in the list of namespaces, a prefix has not yet
+  // been defined. Set a message and return an empty string so the term is not
+  // saved in the mapping.
+  else {
+    drupal_set_message(t('The namespace prefix for @uri is not defined. Term @term has not been saved', array('@uri' => $uri, '@term' => $prefix . ':' . $term_name)), 'warning');
+    return '';
+  }
+}
+
+function rdf_get_rdf_namespaces_array() {
+  $ns = array();
+
+  foreach (module_invoke_all('rdf_namespaces') as $prefix => $uri) {
+    if (is_array($uri)) {
+      if (count(array_unique($uri)) == 1) {
+        // All namespaces declared for this prefix are the same, merge all
+        // duplicates.
+       $uri = $uri[0];
+      }
+    }
+    $ns[$prefix] = $uri;
+  }
+  return $ns;
+}
\ No newline at end of file
