summaryrefslogtreecommitdiff
path: root/modules/rdf
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-03-10 15:19:33 -0400
committerDavid Rothstein <drothstein@gmail.com>2013-03-10 15:19:33 -0400
commita9ec210f7a651bdd8dce8c3879f016ed64b429ff (patch)
treed86eb7c15d591ec35204bcf62a3f2716b3d585fe /modules/rdf
parent63fc6b8f75663588327cec1f645a1826c75f4400 (diff)
downloadbrdo-a9ec210f7a651bdd8dce8c3879f016ed64b429ff.tar.gz
brdo-a9ec210f7a651bdd8dce8c3879f016ed64b429ff.tar.bz2
Issue #1848464 by scor | jneubert: Fixed Make RDFa markup upward compatible with RDFa 1.1.
Diffstat (limited to 'modules/rdf')
-rw-r--r--modules/rdf/rdf.module9
-rw-r--r--modules/rdf/rdf.test12
2 files changed, 13 insertions, 8 deletions
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module
index e491c31d1..e22d5a93f 100644
--- a/modules/rdf/rdf.module
+++ b/modules/rdf/rdf.module
@@ -646,10 +646,12 @@ function rdf_preprocess_username(&$variables) {
if (!empty($rdf_mapping['rdftype'])) {
$attributes['typeof'] = $rdf_mapping['rdftype'];
}
- // Annotate the user name in RDFa. The property attribute is used here
- // because the user name is a literal.
+ // Annotate the username in RDFa. A property attribute is used with an empty
+ // datatype attribute to ensure the username is parsed as a plain literal
+ // in RDFa 1.0 and 1.1.
if (!empty($rdf_mapping['name'])) {
$attributes['property'] = $rdf_mapping['name']['predicates'];
+ $attributes['datatype'] = '';
}
// Add the homepage RDFa markup if present.
if (!empty($variables['homepage']) && !empty($rdf_mapping['homepage'])) {
@@ -757,7 +759,10 @@ function rdf_field_attach_view_alter(&$output, $context) {
$element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
}
if (!empty($term->rdf_mapping['name']['predicates'])) {
+ // A property attribute is used with an empty datatype attribute so
+ // the term name is parsed as a plain literal in RDFa 1.0 and 1.1.
$element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
+ $element[$delta]['#options']['attributes']['datatype'] = '';
}
}
}
diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test
index b8aeb90a1..ca2057f2b 100644
--- a/modules/rdf/rdf.test
+++ b/modules/rdf/rdf.test
@@ -195,12 +195,12 @@ class RdfRdfaMarkupTestCase extends DrupalWebTestCase {
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
// Ensures the RDFa markup for the relationship between the node and its
// tags is correct.
- $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and text()=:term-name]', array(
+ $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and @datatype="" and text()=:term-name]', array(
':node-url' => url('node/' . $node->nid),
':term-name' => $tag1,
));
$this->assertTrue(!empty($term_rdfa_meta), t('Property dc:subject is present for the tag1 field item.'));
- $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and text()=:term-name]', array(
+ $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and @datatype="" and text()=:term-name]', array(
':node-url' => url('node/' . $node->nid),
':term-name' => $tag2,
));
@@ -384,7 +384,7 @@ class RdfMappingDefinitionTestCase extends TaxonomyWebTestCase {
$this->drupalGet('node/' . $node->nid);
// Ensures the default bundle mapping for user is used on the Authored By
// information on the node.
- $author_about = $this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and contains(@xml:lang, "")]', array(
+ $author_about = $this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and @datatype="" and contains(@xml:lang, "")]', array(
':account-uri' => $account_uri,
));
$this->assertTrue(!empty($author_about), t('RDFa markup found on author information on post. xml:lang on username is set to empty string.'));
@@ -502,7 +502,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
// Tests comment #2 as anonymous user.
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
// Tests the RDFa markup for the homepage (specific to anonymous comments).
- $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]');
+ $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype="" and @href="http://example.org/" and contains(@rel, "foaf:page")]');
$this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.'));
// There should be no about attribute on anonymous comments.
$comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]');
@@ -513,7 +513,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
$this->drupalGet('node/' . $this->node2->nid);
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
// Tests the RDFa markup for the homepage (specific to anonymous comments).
- $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]');
+ $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype="" and @href="http://example.org/" and contains(@rel, "foaf:page")]');
$this->assertTrue(!empty($comment_homepage), t("RDFa markup for the homepage of anonymous user found."));
// There should be no about attribute on anonymous comments.
$comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]');
@@ -564,7 +564,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
$comment_date = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//*[contains(@property, "dc:date") and contains(@property, "dc:created")]');
$this->assertTrue(!empty($comment_date), t("RDFa markup for the date of the comment found."));
// The author tag can be either a or span
- $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name"]');
+ $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype=""]');
$name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)";
$this->assertEqual((string)$comment_author[0], $name, t("RDFa markup for the comment author found."));
$comment_body = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//div[@class="content"]//div[contains(@class, "comment-body")]//div[@property="content:encoded"]');