Index: modules/rdf/rdf.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.api.php,v
retrieving revision 1.2
diff -u -p -r1.2 rdf.api.php
--- modules/rdf/rdf.api.php	20 Oct 2009 17:33:43 -0000	1.2
+++ modules/rdf/rdf.api.php	23 Jan 2010 16:54:44 -0000
@@ -73,5 +73,36 @@ function hook_rdf_mapping() {
 }
 
 /**
+ * Allow modules to define namespaces for RDF mappings.
+ *
+ * Many common namespace prefixes are defined in system_rdf_namespaces().
+ * However, if a module implements hook_rdf_mapping() and uses a prefix that is
+ * not defined in system_rdf_namespaces(), this hook should be used to define
+ * the new namespace prefix.
+ *
+ * @return
+ *   An associative array of namespaces where the key is the namespace prefix
+ *   and the value is the namespace URI.
+ */
+function hook_rdf_namespaces() {
+  return array(
+    'admin'    => 'http://webns.net/mvcb/',
+    'content'  => 'http://purl.org/rss/1.0/modules/content/',
+    'dc'       => 'http://purl.org/dc/terms/',
+    'foaf'     => 'http://xmlns.com/foaf/0.1/',
+    'owl'      => 'http://www.w3.org/2002/07/owl#',
+    'rdf'      => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+    'rdfs'     => 'http://www.w3.org/2000/01/rdf-schema#',
+    'rss'      => 'http://purl.org/rss/1.0/',
+    'tags'     => 'http://www.holygoat.co.uk/owl/redwood/0.1/tags/',
+    'sioc'     => 'http://rdfs.org/sioc/ns#',
+    'sioct'    => 'http://rdfs.org/sioc/types#',
+    'ctag'     => 'http://commontag.org/ns#',
+    'skos'     => 'http://www.w3.org/2004/02/skos/core#',
+    'xsd'      => 'http://www.w3.org/2001/XMLSchema#',
+  );
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.20
diff -u -p -r1.20 rdf.module
--- modules/rdf/rdf.module	14 Jan 2010 06:31:45 -0000	1.20
+++ modules/rdf/rdf.module	23 Jan 2010 16:54:45 -0000
@@ -7,7 +7,7 @@
  */
 
 /**
- * Implement hook_help().
+ * Implements hook_help().
  */
 function rdf_help($path, $arg) {
   switch ($path) {
@@ -20,7 +20,7 @@ function rdf_help($path, $arg) {
 }
 
 /**
- * @defgroup rdf RDFa API
+ * @defgroup rdf RDF Mapping API
  * @{
  * Functions to describe entities and bundles for RDFa.
  *
@@ -31,7 +31,7 @@ function rdf_help($path, $arg) {
  * Modules can provide mappings of their bundles' data and metadata to RDFa
  * properties using the appropriate vocabularies. This module takes care of
  * injecting that data into variables available to themers in the .tpl files.
- * Drupal core themes ship with RDFa output enabled.
+ * All Drupal core themes are coded to be RDFa compatible.
  *
  * Example mapping from node.module:
  * @code
@@ -65,8 +65,10 @@ function rdf_help($path, $arg) {
 /**
  * RDF bundle flag: Default bundle.
  *
- * Defines an empty string as the name of the bundle to store default
- * RDF mappings of a type's properties (fields, etc.).
+ * Sets the bundle name to an empty string. This is used to define default RDF
+ * mappings for an entity. Any bundles of the given entity type that are
+ * created will inherit the default mapping unless a bundle specific mapping
+ * is defined.
  */
 define('RDF_DEFAULT_BUNDLE', '');
 
@@ -83,11 +85,13 @@ define('RDF_DEFAULT_BUNDLE', '');
  *   array.
  */
 function rdf_mapping_load($type, $bundle = RDF_DEFAULT_BUNDLE) {
-  // Retrieve the mapping from the entity info.
+  // Retrieve the bundle specific mapping from the entity info.
   $entity_info = entity_get_info($type);
   if (!empty($entity_info['bundles'][$bundle]['rdf_mapping'])) {
     return $entity_info['bundles'][$bundle]['rdf_mapping'];
   }
+  // If there is no mapping defined for this bundle, return the default mapping
+  // that is defined for this entity type.
   else {
     return _rdf_get_default_mapping($type);
   }
@@ -100,7 +104,8 @@ function rdf_mapping_load($type, $bundle
  *   An entity type, e.g. 'node' or 'comment'.
  *
  * @return
- *   The RDF mapping or an empty array.
+ *   The RDF mapping or an empty array if no mapping is defined for this entity
+ *   type.
  */
 function _rdf_get_default_mapping($type) {
   $default_mappings = &drupal_static(__FUNCTION__);
@@ -163,7 +168,8 @@ function _rdf_mapping_load($type, $bundl
  *   Status flag indicating the outcome of the operation.
  */
 function rdf_mapping_save(&$mapping) {
-  // Adds default values for non-existent keys.
+  // If there are any array keys in the default mapping that were not overriden
+  // by the bundle specific mapping, set those to the default value.
   $mapping['mapping'] += _rdf_get_default_mapping($mapping['type']);
 
   $status = db_merge('rdf_mapping')
@@ -182,7 +188,7 @@ function rdf_mapping_save(&$mapping) {
 }
 
 /**
- * Deletes the mapping for the given pair of type and bundle from the database.
+ * Deletes the mapping for the given bundle from the database.
  *
  * @param $type
  *   The entity type the mapping refers to.
@@ -202,7 +208,12 @@ function rdf_mapping_delete($type, $bund
 }
 
 /**
- * Builds an array of RDFa attributes for a given mapping.
+ * Builds an array of RDFa attributes for a given mapping. This array will be
+ * passed through drupal_attributes() to create the attributes variables that
+ * are available to tpl.php template files. These include $attributes,
+ * $title_attributes, $content_attributes and the field specific
+ * $item_attributes variables. For more information, see
+ * theme_rdf_template_variable_wrapper().
  *
  * @param $mapping
  *   An array containing a mandatory 'predicates' key and optional 'datatype',
@@ -262,9 +273,9 @@ function rdf_rdfa_attributes($mapping, $
  *
  * While both default entity mappings and specific bundle mappings can be
  * defined in hook_rdf_mapping(), we do not want to save the default entity
- * mappings in the database because users are not expected to alter these.
- * Instead they should alter specific bundle mappings which are stored in the
- * database so that they can be altered via the RDF CRUD mapping API.
+ * mappings in the database. The default entity mappings can be overriden by
+ * specific bundle mappings which are stored in the database and can be
+ * altered via the RDF CRUD mapping API.
  */
 function rdf_modules_installed($modules) {
   // We need to clear the caches of entity_info as this is not done right
@@ -295,6 +306,12 @@ function rdf_modules_uninstalled($module
  * Implements hook_entity_info_alter().
  *
  * Adds the proper RDF mapping to each entity type, bundle pair.
+ *
+ * @todo May need to move the comment below to another place.
+ * This hook should not be used by modules to alter the bundle mappings.
+ * The UI should always be authoritative. UI mappings are stored in the database
+ * and if hook_entity_info_alter was used to override module defined mappings,
+ * it would override the user defined mapping as well.
  */
 function rdf_entity_info_alter(&$entity_info) {
   // Loop through each entity type and its bundles.
@@ -379,15 +396,17 @@ function rdf_process(&$variables, $hook)
  * Implements MODULE_preprocess_HOOK().
  */
 function rdf_preprocess_node(&$variables) {
-  // Adds RDFa markup to the node container. The about attribute specifies the
-  // URI of the resource described within the HTML element, while the typeof
-  // attribute indicates its RDF type (foaf:Document, or sioc:User, etc.).
+  // Adds RDFa markup to the node container in teaser view. The about attribute
+  // specifies the URI of the resource described within the HTML element, while
+  // the typeof attribute indicates its RDF type (foaf:Document, or sioc:User,
+  // etc.).
   $variables['attributes_array']['about'] = empty($variables['node_url']) ? NULL: $variables['node_url'];
   $variables['attributes_array']['typeof'] = empty($variables['node']->rdf_mapping['rdftype']) ? NULL : $variables['node']->rdf_mapping['rdftype'];
 
-  // Adds RDFa markup to the title of the node. Because the RDFa markup is added
-  // to the h2 tag which might contain HTML code, we specify an empty datatype
-  // to ensure the value of the title read by the RDFa parsers is a literal.
+  // Adds RDFa markup to the title of the node in teaser view. Because the RDFa
+  // markup is added to the h2 tag which might contain HTML code, we specify an
+  // empty datatype to ensure the value of the title read by the RDFa parsers
+  // is a literal.
   $variables['title_attributes_array']['property'] = empty($variables['node']->rdf_mapping['title']['predicates']) ? NULL : $variables['node']->rdf_mapping['title']['predicates'];
   $variables['title_attributes_array']['datatype'] = '';
 
@@ -407,17 +426,19 @@ function rdf_preprocess_node(&$variables
     drupal_add_html_head($element, 'rdf_node_title');
   }
 
-  // Adds RDFa markup for the date.
+  // Adds RDFa markup for the date in teaser view.
   if (!empty($variables['rdf_mapping']['created'])) {
     $date_attributes_array = rdf_rdfa_attributes($variables['rdf_mapping']['created'], $variables['created']);
     $variables['rdf_template_variable_attributes_array']['date'] = $date_attributes_array;
   }
-  // Adds RDFa markup for the relation between the node and its author.
+  // Adds RDFa markup for the relation between the node and its author in
+  // teaser view.
   if (!empty($variables['rdf_mapping']['uid'])) {
     $variables['rdf_template_variable_attributes_array']['name']['rel'] = $variables['rdf_mapping']['uid']['predicates'];
   }
 
-  // Adds RDFa markup annotating the number of comments a node has.
+  // Adds RDFa markup annotating the number of comments a node has in teaser
+  // view.
   if (isset($variables['node']->comment_count) && !empty($variables['node']->rdf_mapping['comment_count']['predicates'])) {
     // Annotates the 'x comments' link in teaser view.
     if (isset($variables['content']['links']['comment']['#links']['comment_comments'])) {
@@ -482,17 +503,17 @@ function rdf_preprocess_username(&$varia
   // users is already known, call rdf_mapping_load() directly.
   $rdf_mapping = rdf_mapping_load('user', 'user');
 
-  // An RDF resource for the user is created with the 'about' attribute and
-  // the profile URI is used to identify this resource. Even if the user
-  // profile is not accessible, we generate its URI regardless in order to
-  // be able to identify the user in RDF. We do not use this attribute for
+  // The profile URI is used to identify the user account. The about attribute
+  // is used to set the URI as the subject of the following predicates. Even if
+  // the user profile is not accessible to the current user, we use its URI in 
+  // order to identify the user in RDF. We do not use this attribute for
   // the anonymous user because we do not have a user profile URI for it (only
   // a homepage which cannot be used as user profile in RDF).
   if ($variables['uid'] > 0) {
     $variables['attributes_array']['about'] = url('user/' . $variables['uid']);
   }
 
-  // The remaining attributes are defined by RDFa as lists
+  // The remaining attributes can have multiple values
   // (http://www.w3.org/TR/rdfa-syntax/#rdfa-attributes). Therefore, merge
   // rather than override, so as not to clobber values set by earlier
   // preprocess functions.
@@ -609,13 +630,13 @@ function rdf_field_attach_view_alter(&$o
  * @param $variables
  *   An associative array containing:
  *   - content: A string of content to be wrapped with attributes.
- *   - attributes: An array of attributes desired on the wrapping element.
+ *   - attributes: An array of attributes to be placed on the wrapping element.
  *   - context: An array of context information about the content to be wrapped:
  *     - hook: The theme hook that will use the wrapped content. This
  *       corresponds to the key within the theme registry for this template.
  *       For example, if this content is about to be used in node.tpl.php or
  *       node-TYPE.tpl.php, then the 'hook' is 'node'.
- *     - variable_name: The name of the variable, by which the template will
+ *     - variable_name: The name of the variable by which the template will
  *       refer to this content. Each template file has documentation about
  *       the variables it uses. For example, if this function is called in
  *       preparing the $author variable for comment.tpl.php, then the
