ZF-10796: Add XHTML1 RDFA doctype to Zend_View_Helper_Doctype


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

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

The trouble with Bob


  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:

This is used for Facebook enhanced pages.


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());

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_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="">">',
                     self::XHTML1_TRANSITIONAL => 'ofollow" href="">">',
                     self::XHTML1_FRAMESET     => 'ofollow" href="">">',
+                    self::XHTML1_RDFA         => 'ofollow" href="">">',
                     self::XHTML_BASIC1        => 'ofollow" href="">">',
                     self::XHTML5              => '',
                     self::HTML4_STRICT        => 'ofollow" href="">">',
@@ -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 []

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="">">" xmlns:og="" xmlns:fb="">



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:…

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

I am not sure which revision.