diff --git includes/common.inc includes/common.inc
index 3e58960..4626597 100644
--- includes/common.inc
+++ includes/common.inc
@@ -254,9 +254,8 @@ function drupal_get_breadcrumb() {
  * XHTML output.
  */
 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) {
+  foreach (rdf_get_rdf_namespaces() as $prefix => $uri) {
+    // Serializes each RDF namespace for use in XML.
     $xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
   }
   return implode("\n  ", $xml_rdf_namespaces);
diff --git modules/rdf/rdf.module modules/rdf/rdf.module
index 1aca14d..88f2aab 100644
--- modules/rdf/rdf.module
+++ modules/rdf/rdf.module
@@ -95,6 +95,32 @@ function rdf_rdf_namespaces() {
 }
 
 /**
+ * Returns an array of RDF namespaces defined via hook_rdf_namespaces().
+ */
+function rdf_get_rdf_namespaces() {
+  $rdf_namespaces = module_invoke_all('rdf_namespaces');
+  // module_invoke_all() uses array_merge_recursive() which might return nested
+  // arrays if several modules redefine the same prefix multiple times.
+  // We need to ensure the array of namespaces is flat and only contains
+  // strings as URIs.
+  foreach ($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 them all
+        // into a single namespace.
+        $rdf_namespaces[$prefix] = $uri[0];
+      }
+      else {
+        // There are conflicting namespaces for this prefix, do not include it
+        // in order to avoid asserting any inaccurate RDF statement.
+        unset($rdf_namespaces[$prefix]);
+      }
+    }
+  }
+  return $rdf_namespaces;
+}
+
+/**
  * Returns the mapping for attributes of a given type/bundle pair.
  *
  * @param $type
diff --git modules/rdf/rdf.test modules/rdf/rdf.test
index eec6ffb..a4a16ab 100644
--- modules/rdf/rdf.test
+++ modules/rdf/rdf.test
@@ -39,7 +39,7 @@ class RdfMappingHookTestCase extends DrupalWebTestCase {
   }
 }
 
-class RdfMarkupTestCase extends DrupalWebTestCase {
+class RdfRdfaMarkupTestCase extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'RDFa markup',
@@ -55,7 +55,7 @@ class RdfMarkupTestCase extends DrupalWebTestCase {
   /**
    * Test rdf_rdfa_attributes().
    */
-  function testDrupalRdfaAtributes() {
+  function testDrupalRdfaAttributes() {
     // Same value as the one in the HTML tag (no callback function).
     $expected_attributes = array(
       'property' => array('dc:title'),
@@ -509,3 +509,30 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
     $this->assertTrue(!empty($tracker_activity), t('Latest activity date found when there are comments on @user content. Latest activity date content is correct.', array('@user'=> $user)));
   }
 }
+
+/**
+ * Tests for RDF namespaces declaration with hook_rdf_namespaces().
+ */
+class RdfGetRdfNamespacesTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'RDF namespaces',
+      'description' => 'Test hook_rdf_namespaces() and ensure only "safe" namespaces are returned.',
+      'group' => 'RDF',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('rdf', 'rdf_test');
+  }
+
+  function testGetRdfNamespaces() {
+    // Get all RDF namespaces.
+    $ns = rdf_get_rdf_namespaces();
+
+    $this->assertEqual($ns['owl'], 'http://www.w3.org/2002/07/owl#', t('A prefix declared once is included.'));
+    $this->assertEqual($ns['foaf'], 'http://xmlns.com/foaf/0.1/', t('The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.'));
+    $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', t('Two prefixes can be assigned the same namespace.'));
+    $this->assertTrue(!isset($ns['dc']), t('A prefix with conflicting namespaces is discarded.'));
+  }
+}
diff --git modules/rdf/tests/rdf_test.module modules/rdf/tests/rdf_test.module
index 823c165..09b89af 100644
--- modules/rdf/tests/rdf_test.module
+++ modules/rdf/tests/rdf_test.module
@@ -54,3 +54,14 @@ function rdf_test_rdf_mapping() {
     ),
   );
 }
+
+/**
+ * Implements hook_rdf_namespaces().
+ */
+function rdf_test_rdf_namespaces() {
+  return array(
+    'dc'       => 'http://purl.org/conflicting/namespace',
+    'foaf'     => 'http://xmlns.com/foaf/0.1/',
+    'foaf1'    => 'http://xmlns.com/foaf/0.1/',
+  );
+}
diff --git modules/simpletest/tests/common.test modules/simpletest/tests/common.test
index c8d4a4f..533e239 100644
--- modules/simpletest/tests/common.test
+++ modules/simpletest/tests/common.test
@@ -1886,3 +1886,32 @@ class DrupalJSONTest extends DrupalUnitTestCase {
     $this->assertIdentical($source, $json_decoded, t('Encoding structured data to JSON and decoding back results in the original data.'));
   }
 }
+
+/**
+ * Tests for RDF namespaces XML serialization.
+ */
+class DrupalGetRdfNamespacesTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'RDF namespaces XML serialization tests',
+      'description' => 'Confirm that the serialization of RDF namespaces via drupal_get_rdf_namespaces() is output and parsed correctly in the XHTML document.',
+      'group' => 'System',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('rdf', 'rdf_test');
+  }
+
+  function testGetRdfNamespaces() {
+    // Fetches the front page and extracts XML namespaces.
+    $this->drupalGet('');
+    $xml = new SimpleXMLElement($this->content);
+    $ns = $xml->getDocNamespaces();
+
+    $this->assertEqual($ns['owl'], 'http://www.w3.org/2002/07/owl#', t('A prefix declared once is displayed.'));
+    $this->assertEqual($ns['foaf'], 'http://xmlns.com/foaf/0.1/', t('The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.'));
+    $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', t('Two prefixes can be assigned the same namespace.'));
+    $this->assertTrue(!isset($ns['dc']), t('A prefix with conflicting namespaces is discarded.'));
+  }
+}
