Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
See roadmap on enabling RDFa in Drupal 7.
This first patch implements a simple RDF namespace registry which is serialized in the XHTML output. Only garland has been modified for now, changes can be applied to the other themes once this patch has matured enough. In case of conflicting prefixes, it displays an error which targets module developers. No security measure needs to be taken when outputting the namespaces since the prefixes and URIs come from the modules only (no direct user input).
Some common namespaces are defined in system.module.
Comment | File | Size | Author |
---|---|---|---|
#44 | rdf_changelog.patch | 682 bytes | scor |
#36 | rdfa_xmlns_xsi_fix.patch | 745 bytes | scor |
#27 | rdfa_ns_registry-332980-20.patch | 3.06 KB | scor |
#24 | rdfa_ns_registry-332980-19.patch | 3.05 KB | scor |
#22 | rdfa_ns_registry-332980-18.patch | 3.05 KB | scor |
Comments
Comment #1
chx CreditAttribution: chx commentedThe
rdf_get_namespaces
and the proposed structure is not something I am very happy with. If modules are to define arbitrary prefixes ( they are totally arbitrary arent they? ) then why should any module define the prefix? Why not justEdit: even if I am wrong, checking whether other modules have defined things, and producing an error totally should not be there -- why include code that is only relevant at coding time for every single request Drupal serves? Or to put it more succint, we do not babysit broken code.
Comment #2
Dries CreditAttribution: Dries commented1. The GRDDL one could use more documentation for those not familiar with it. They might wonder why it is singled-out.
2. The hook is called
_rdf_namespaces()
(plural) but the documentation uses_rdf_namespace()
(singular).Comment #3
scor CreditAttribution: scor commented@chx:
prefixes are used to make the URIs shorter in the annotated the XHTML code. There is generally a convention used for prefixes. For instance 'dc' is used for http://purl.org/dc/elements/1.1/
As a result I can write in the body of the page:
where dc:creator is the URI http://purl.org/dc/elements/1.1/creator
Please read http://groups.drupal.org/node/16597 for general overview
module developers could potentially override the prefixes defined by core with a different URI, it's the reason why I had added this check.
Comment #4
scor CreditAttribution: scor commented@Dries:
1. will do
2. the hook in the patch is hook_rdf_namespace() (singular). which documentation line are refering to? I don't see what you mean.
Comment #5
chx CreditAttribution: chx commentedI understand the logic for the shorthands but still -- that getter is not what Drupal does, just use module_invoke_all and be done. if two modules define the same, too bad.
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedI agree with chx. That check is not at all conventional in drupal.
Comment #7
chx CreditAttribution: chx commented2. The hook is called _rdf_namespaces() (plural) but the documentation uses _rdf_namespace() (singular). <= No, the hook is singular, his getter is plural but the next patch wont have the getter I am quite sure of that :)
Comment #8
Dries CreditAttribution: Dries commentedGlad we're all on the same page. Hehe. ;-)
Comment #9
scor CreditAttribution: scor commentedmuch simplified patch addressing the comments above, without the getter and with some more doc on GRDDL.
Comment #10
chx CreditAttribution: chx commentedThis is going to be something great. Are we going to add RDF prefixes to node titles and bodies besides theme item list? Please do in a next patch.
I see that you added space to be flush with the wall of variables a few lines up but that's an exception to the rule and a s you can see for node a line below, once the wall is finished so is the spacing so please remove the extra spaces from theme.inc. Just
$variables['rdf_namespaces'] = implode(' ', $xml_rdf_namespaces);
please. Even more, why not use a \n and a few spaces to implode on? It can't hurt to make the HTML source make readable... otherwise the <html> line will be too long. Sorry for being so picky with this patch.Comment #11
scor CreditAttribution: scor commentedyes, of course, in other separate patches.
Originally I found the xml namespaces to be too verbose that's why I kept them on the same line. The attached patch adds \n and indents the namespaces with 2 spaces. also fixed the wall of variable issue.
That's fine, I can be picky at times too :)
Comment #12
chx CreditAttribution: chx commentedComment #14
scor CreditAttribution: scor commentedrerolling the patch from #11.
Comment #15
lilou CreditAttribution: lilou commentedTest failure : #335122: Test clean HEAD after every commit
Comment #16
pwolanin CreditAttribution: pwolanin commentedWe need to cover other page tpl files and also non-tpl themes. Probably the hook invocation should, for this reason, be moved out to a helper function.
Also, will a normal browser slow down its page load to try to fetch all those name-space documents? Stephane tells me he thinks FF does not fetch all these, but we should verify this and/or find documentation about it to be sure.
Also, the RDFa doctype is "XHTML 1.1 and RDFa". Our existing doctypes are XHTML 1.0 Transitional or Strict. Will using this RDFa doctype make Drupal less likely/able to validate and possibly break theme functions?
Comment #17
pwolanin CreditAttribution: pwolanin commentedhere's a patch that covers other page.tpl.php files, but there are still unanswered questions about the DOCTYPE in my mind.
Also, some sources suggest such a document should have an XML declaration at the top like
Comment #18
scor CreditAttribution: scor commentedre the XML declaration at the top, the RDFa syntax specification says:
Drupal output UTF-8 by default, and specifies
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
in common.inc so in my opinion it's not necessary.Peter asked me on IRC whether the namespaces at the top of the page would slow down the browsers which might try to fetch these URIs. This is not the case. In theory these namespaces don't even need to exist on the web: they are used as common ids across websites. In practice they are often dereferencable in order to provide some information on the vocabulary terms and promote reuse of vocabularies.
Comment #19
Dries CreditAttribution: Dries commentedI've committed this patch to CVS HEAD. Oh my!
I'm marking it 'code needs work' because we'll want to update the theme upgrade instructions in the handbook. Could you update those, scor (or someone else)? Once updated, please mark this issue as 'fixed' so we can move onto the next one.
Keep up the good work, folks.
Comment #20
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedThe patch had a typo for the chameleon theme:
+ $putput .= " $rdf_namespaces>\n";
Comment #21
scor CreditAttribution: scor commentedfixing more typos at the moment, and improving the documentation, patch coming in the next minutes.
Comment #22
scor CreditAttribution: scor commentedfix typos and improve documentation.
Comment #23
keith.smith CreditAttribution: keith.smith commentedExcellent!
We usually capitalize HTML.
"allows to annotate" is still weird, though annotate is spelled correctly. What about "RDFa allows annotation of XHTML pages with RDF data..."
Comment #24
scor CreditAttribution: scor commented@keith: thanks for the feedback. "We usually capitalize HTML. " -> here we don't mean the HTML language, but the html tag
<html>
which is spelt in lower case per XHTML standards.fixed "RDFa allows annotation of XHTML pages with RDF data..."
Comment #25
keith.smith CreditAttribution: keith.smith commentedLooks good to me.
Comment #26
keith.smith CreditAttribution: keith.smith commentedActually, as scor and I discussed on #drupal, this would be even more clear if we just put <> brackets around html.
"Return a string containing RDF namespaces for the tag of an XHTML page."
Comment #27
scor CreditAttribution: scor commentedhere is the patch
Comment #28
keith.smith CreditAttribution: keith.smith commentedThose brackets make all the difference. Thanks!
Comment #29
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #30
xmacinfoThere are white-space issues in the tag with this fix.
The closing ">" is sent to the next line with 2 spaces in front of it.
Comment #31
scor CreditAttribution: scor commentedthe double space it there to indent the namespaces. I cannot reproduce exactly what you pasted above, since there should be a list of namespaces in the html tag. Can you elaborate please?
Comment #32
drewish CreditAttribution: drewish commentedi tried running HEAD's front page through http://validator.w3.org/check and it didn't seem to care about the white space but it did give the following errors:
perhaps that should be moved into a new issue?
Comment #33
scor CreditAttribution: scor commentedsee #338429: XHTML 1.1 compatibility (RDFa) for the lang issue.
Comment #34
xmacinfoHi!
I'm running a bare-bone Drupal CVS install updated so see the results of this commit.
When I do a view source I get this:
The last ">" character is sent to a new line with 2 spaces before it.
Normally we would expect no space between the last attribute and the closing ">" character:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
Comment #35
xmacinfoOk. Now I see alll namespaces.
Forgot to update.php.
Cheers.
Comment #36
scor CreditAttribution: scor commentedre #32: in fact we don't need xsi which is used for rather specific use cases. This patch removes it. It also removes the # in the end of the xsd prefix to match with the official XML Schema namespace.
Comment #37
Dries CreditAttribution: Dries commentedCommitted to CVS. Thanks!
Comment #38
xmacinfoGreat. Please add an entry in the changelog file.
From my point of view it looks like a big change since I'll have to modify the way I do themes.
Cheers.
Comment #39
webchickBump. Need those docs. I'd add them myself, but I don't quite grok what the heck this patch has enabled. :)
Comment #40
webchickComment #41
scor CreditAttribution: scor commentedIt's best to wait for more RDF patches to land as the bigger RDF picture might slightly change (and the RDF docs as a result). This patch doesn't enable much on its own, but simply prepares Drupal for the next patches.
Comment #42
drewish CreditAttribution: drewish commentedscor, we're trying to keep the documentation current for each UNSTABLE release. if changes happen to the next release then they'd be documented in that section. when the final release occurs we'll distill it all down to one set of docs.
Comment #43
drewish CreditAttribution: drewish commentedSo it looks like this really needs a couple of things:
Comment #44
scor CreditAttribution: scor commentedHow about:
Comment #45
scor CreditAttribution: scor commentedre #38: I added an entry to Converting 6.x themes to 7.x
Comment #46
catchCHANGELOG.txt entry looks good to me - we can add more later.
Comment #47
webchickGreat! :) Thanks!
Comment #49
JohnAlbinYou guys didn't add the variables to modules/system/page.tpl.php.
Comment #50
JohnAlbinwebchick opened a follow-up issue in #387218: Default page.tpl.php needs to print RDF variables. So let's go fix it over there. :-)