ZF-10796: Add XHTML1 RDFA doctype to Zend_View_Helper_Doctype

Issue Type: New Feature Created: 2010-12-08T12:48:16.000+0000 Last Updated: 2010-12-18T12:53:25.000+0000 Status: Resolved Fix version(s): - 1.11.2 (30/Dec/10)

Reporter: Jeremy Postlethwaite (gammamatrix) Assignee: Jeremy Postlethwaite (gammamatrix) Tags: - Zend_View

Related issues: - ZF-9743

Attachments: - ZF-10796-docs-code-tests.patch


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.


Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T12:50:16.000+0000

Here is the diff to the DocTypeTest:

<pre class="highlight">
svn diff tests/Zend/View/Helper/DoctypeTest.php

<pre class="highlight">
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());

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T12:55:16.000+0000

Here is the diff to the view helper

<pre class="highlight">
svn diff library/Zend/View/Helper/Doctype.php

<pre class="highlight">
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:

Posted by Marc Hodgins (mjh_ca) on 2010-12-08T14:22:31.000+0000

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 []

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T14:50:55.000+0000

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"

<pre class="highlight">
ofollow" href="">">" xmlns:og="" xmlns:fb="http://<a href=""></a>">

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T14:54:59.000+0000



Posted by Marc Hodgins (mjh_ca) on 2010-12-08T20:29:10.000+0000

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

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-10T10:27:44.000+0000

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.

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-16T14:49:40.000+0000

Committed code in r23525

Posted by Marc Hodgins (mjh_ca) on 2010-12-17T22:38:06.000+0000

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

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-18T12:53:25.000+0000

It is in there:…

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

I am not sure which revision.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.