Due to xml:lang="en" present in the html tag of documents generated by Drupal, all RDF plain literals inherit a language tag @en. This is useful for the title and body of the node etc, but someone on the semantic web mailing reported that the username should not inherit this language tag. Add xml:lang="" to the a/span tag wrapping the username should fix this.

Comments

Anonymous’s picture

It seems like it might be helpful to have a language tag on the username in case the username is transliterated into another language.

The foaf project wiki says this:

Expressing a name, sortable or displayable, for use in multiple cultures can be done by means of language tags (xml:lang attributes) on the literal name components - so far there exists no conventions for distinquishing between cultures, but languages seem to some extent to cover the same concepts...

http://wiki.foaf-project.org/w/NamesInFoaf

Anonymous’s picture

Actually, I see... the problem is that it inherits the language tag when it might not be in the same language (if it was not transliterated).

Anonymous’s picture

StatusFileSize
new1.16 KB

Code with comment.

I included a conditional that makes sure that xml:lang for the username is not already set. This is because someone could use Transliterate API on the username, at which point they would might want to use MODULE_preprocess_username to set the xml:lang attribute. The conditional in the patch will ensure that RDF module doesn't overwrite the values set in the other module's preprocess_username implementation.

If I do understand the problem correctly—if the problem is that xml:lang is inherited by the username when the username might not be in the same language—then this would apply to regular XHTML as well, correct? In which case, it seems like its actually an issue with template_preprocess_username. I'm not saying we should try to get this fix in theme.inc, but it seems like it would have the same problem.

I can write a test for this today.

Anonymous’s picture

StatusFileSize
new1.49 KB

+++ modules/rdf/rdf.module 12 Jan 2010 12:42:21 -0000
@@ -475,6 +475,15 @@ function rdf_preprocess_user_profile(&$v
+ if (!isset($variables['attributes_array']['xml:lang'])) {

Whoops! We actually want to set the value if it is not already set.

Changing !isset to empty

I'm on crack. Are you, too?

EDIT: I am seriously having an on crack moment... Patch was fine with !isset, but changed to empty for consistency with the rest of the function.

Anonymous’s picture

StatusFileSize
new3.38 KB

Added a test that makes sure the default user mapping is used on the authored by line on a post (I didn't see a test for this... we do test that in comments and on the tracker page, but I don't think there is one for just a regular post.) In this test, I made sure that xml:lang is explicitly set on the username.

aspilicious’s picture

Status: Active » Needs review

needs review I suppose

scor’s picture

+++ modules/rdf/rdf.module	12 Jan 2010 15:37:44 -0000
@@ -475,6 +475,15 @@ function rdf_preprocess_user_profile(&$v
+  // Because xml:lang is set on the html container that wraps the content, the

'content' is somewhat ambiguous. 'page content' or 'page' might make more sense.

otherwise looks good.

2 days to code freeze. Better review yourself.

Anonymous’s picture

StatusFileSize
new3.38 KB

Thanks for reviewing, changed 'content' to 'page'.

dries’s picture

+++ modules/rdf/rdf.module	12 Jan 2010 15:37:44 -0000
@@ -475,6 +475,15 @@ function rdf_preprocess_user_profile(&$v
+  // Because xml:lang is set on the html container that wraps the page, the

- Can we write HTML instead of html?

- So when it is set to the empty string, it means what? That the language is unknown?

Anonymous’s picture

StatusFileSize
new3.38 KB

- To be more precise, I changed 'html container' to be 'HTML element'

- Here is what the XML specification says:

"In particular, the empty value of xml:lang is used on an element B to override a specification of xml:lang on an enclosing element A, without specifying another language."

scor’s picture

- So when it is set to the empty string, it means what? That the language is unknown?

that there is no language attached to the user name. Core does not allow to specify a language for the username. Why would the language of a given page also carry on the username?

scor’s picture

Status: Needs review » Reviewed & tested by the community

#10 is good to go.

scor’s picture

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Minor stuff, but...

+++ modules/rdf/rdf.module
@@ -487,6 +487,15 @@ function rdf_preprocess_user_profile(&$variables) {
+  // might not be transliterated to the same language that the content is in,

'translated', not 'transliterated', right?

+++ modules/rdf/rdf.test
@@ -290,17 +290,25 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
+    $author_about = $this->xpath("//a[@typeof='sioc:User' and @about='$profile_url' and @property='foaf:name' and contains(@xml:lang, '')]");
+    $this->assertTrue(!empty($author_about), t('RDFa markup found on author information on post. xml:lang is set on username.'));

I'm confused. Wasn't the point of this patch to /not/ set xml:lang on username? Is the assertion message wrong?

Powered by Dreditor.

scor’s picture

right, the second hunk assertion message is confusing. It should say "xml:lang is set to empty on username".

Anonymous’s picture

StatusFileSize
new2.7 KB

1. I believe transliterate is correct here. You translate meaning, you transliterate phonetics. People would use http://drupal.org/project/transliteration to transliterate the names.

2. Changed the comment to be clearer that we are setting a null xml:lang attribute.

scor’s picture

Status: Needs work » Reviewed & tested by the community

looks good.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -RDF, -RDFa

Automatically closed -- issue fixed for 2 weeks with no activity.