ZF-10796: Add XHTML1 RDFA doctype to Zend_View_Helper_Doctype

Description

This doctype allows a developer to use the Resource Description Framework:

http://www.w3.org/TR/xhtml-rdfa-primer/

Using this doctype is necessary if you wish to specify the property or rel component of a tag.

This allows labeling items to be picked up by the browser:

  1. Set the title and creator - uses Dublin Core (dc from purl.org)

The trouble with Bob

Alice

...
  1. You can also attribute a license:

All content on this site is licensed under a Creative Commons License .

  1. This is also needed to get pages to validate when using the Open Graph Protocol:

http://opengraphprotocol.org/

This is used for Facebook enhanced pages.

Comments

Here is the diff to the DocTypeTest:


svn diff tests/Zend/View/Helper/DoctypeTest.php

Index: tests/Zend/View/Helper/DoctypeTest.php
===================================================================
--- tests/Zend/View/Helper/DoctypeTest.php  (revision 23481)
+++ tests/Zend/View/Helper/DoctypeTest.php  (working copy)
@@ -122,7 +122,7 @@
 
     public function testIsXhtmlReturnsTrueForXhtmlDoctypes()
     {
-        foreach (array('XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET', 'XHTML5') as $type) {
+        foreach (array('XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET', 'XHTML1_RDFA', 'XHTML5') as $type) {
             $doctype = $this->helper->doctype($type);
             $this->assertEquals($type, $doctype->getDoctype());
             $this->assertTrue($doctype->isXhtml());

Here is the diff to the view helper


svn diff library/Zend/View/Helper/Doctype.php

Index: library/Zend/View/Helper/Doctype.php
===================================================================
--- library/Zend/View/Helper/Doctype.php    (revision 23481)
+++ library/Zend/View/Helper/Doctype.php    (working copy)
@@ -43,6 +43,7 @@
     const XHTML1_STRICT       = 'XHTML1_STRICT';
     const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
     const XHTML1_FRAMESET     = 'XHTML1_FRAMESET';
+    const XHTML1_RDFA         = 'XHTML1_RDFA';
     const XHTML_BASIC1        = 'XHTML_BASIC1';
     const XHTML5              = 'XHTML5';
     const HTML4_STRICT        = 'HTML4_STRICT';
@@ -87,6 +88,7 @@
                     self::XHTML1_STRICT       => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                     self::XHTML1_TRANSITIONAL => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
                     self::XHTML1_FRAMESET     => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
+                    self::XHTML1_RDFA         => 'ofollow" href="www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
                     self::XHTML_BASIC1        => 'ofollow" href="www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
                     self::XHTML5              => '',
                     self::HTML4_STRICT        => 'ofollow" href="www.w3.org/TR/html4/strict.dtd">www.w3.org/TR/html4/strict.dtd">',
@@ -117,6 +119,7 @@
                 case self::XHTML1_TRANSITIONAL:
                 case self::XHTML1_FRAMESET:
                 case self::XHTML_BASIC1:
+                case self::XHTML1_RDFA:
                 case self::XHTML5:
                 case self::HTML4_STRICT:
                 case self::HTML4_LOOSE:

Hi Jeremy, I like this idea of building in convenience for implementing RDFa, especially since Facebook implements opengraph.

A few questions -

1) Doesn't adding the namespace as an attribute to the tag also accomplish the same thing without adding a new doctype? (The opengraph site documents this approach). It would allow this to apply to more than one version of HTML (i.e. HTML5).


2) If approaching it like this via adding a DOCTYPE, why not add an HTML5 RDFa doctype as well? (i.e. Zend_View_Helper_Doctype::HTML5_RDFA) - see [http://dev.w3.org/html5/rdfa/]

Hi Marc, you do not need to have the RDFa doctype to implement Open Graph. Using RDFa ensures your page will validate. If you use any other doctype, you will get flagged by a validator for using "property"


ofollow" href="www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">

HTML5_RFDA

test

Revised patch attached which consolidates Jeremy's changes, adds documentation and adds an isRdfa1() method to allow view helpers to differentiate behavior.

I attached another patch.

This includes the previous patch with the test and code. It also adds documentation in English on how to use the doctype with Open Graph.

Committed code in r23525

isRdfa() method of Zend_View_HelperDoctype added in r23538, merged to 1.11 release branch in r23539

It is in there:

http://framework.zend.com/svn/framework/…

I did forget to include your patch the first time I checked it in.

I am not sure which revision.