public function doctype($doctype = null)
        {
            if (null !== $doctype) {
                switch ($doctype) {
                    case static::XHTML11:
                    case static::XHTML1_STRICT:
                    case static::XHTML1_TRANSITIONAL:
                    case static::XHTML1_FRAMESET:
                    case static::XHTML_BASIC1:
                    case static::XHTML1_RDFA:
                    case static::XHTML1_RDFA11:
                    case static::XHTML5:
                    case static::HTML4_STRICT:
                    case static::HTML4_LOOSE:
                    case static::HTML4_FRAMESET:
                    case static::HTML5:
                        $this->setDoctype($doctype);
                        break;
                    default:
                        if (substr($doctype, 0, 9) != '<!DOCTYPE') {
                            $e = new Exception('The specified doctype is malformed');
                            throw $e;
                        }
                        if (stristr($doctype, 'xhtml')) {
                            $type = static::CUSTOM_XHTML;
                        } else {
                            $type = static::CUSTOM;
                        }
                        $this->setDoctype($type);
                        $this->_registry['doctypes'][$type] = $doctype;
                        break;
                }
            }

            return $this;
        }