Specifying a doctype
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Specifying a doctype
This is a sort of a poll, but I don't know what the answers are, so it'll be free response. Suppose you were using a library, which could output certain types of HTML. HTML 4 Strict, Transitional, XHTML 1.0, XHTML 1.1, XHTML 2.0, you name it. And you needed to specify which language you wanted the library to output. How would you prefer to identify it? Would it be...
Full doctype: "-//W3C//DTD XHTML 1.0 Transitional//EN"
Totally new short name system: XHTML 1.0 Transitional; XHTML 1.1 + Legacy; HTML 4.01 Strict...
A bunch of little variables: array('type' => 'XHTML', 'version' => '1.1', 'modules' => array('Legacy')); array('type' => 'HTML', 'version' => '4.01', flavor = 'Transitional');
Something else?
Just quick opinions. What you would find to be most convenient.
Full doctype: "-//W3C//DTD XHTML 1.0 Transitional//EN"
Totally new short name system: XHTML 1.0 Transitional; XHTML 1.1 + Legacy; HTML 4.01 Strict...
A bunch of little variables: array('type' => 'XHTML', 'version' => '1.1', 'modules' => array('Legacy')); array('type' => 'HTML', 'version' => '4.01', flavor = 'Transitional');
Something else?
Just quick opinions. What you would find to be most convenient.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
I'd use a bunch of shorthand names, plus have the ability to override with your own full doctype string.
Maybe the shorthand could take standard arguments...
You'd have to match the input args against some preset strings, but it's oh-so friendly to use 
Maybe the shorthand could take standard arguments...
Code: Select all
setDocType('xhtml'); // sets a default for xhtml, like xhtml 1.0 transitional
setDocType('xhtml','1.0'); // sets a default for xhtml 1.0 (probably transitional - seems popular)
setDocType('xhtml','1.0','Transitional'); // sets the whole thing.
setDocType('-//W3C//DTD XHTML 1.0 Transitional//EN'); // set the whole string-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
I used the following in my page generator..
Code: Select all
function _docType($type) {
$docTypes = array();
$docTypes['h4.01s'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
$docTypes['h4.01t'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
$docTypes['h4.01f'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
$docTypes['x1.0s'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$docTypes['xhtml10trans'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
$docTypes['x1.0f'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
$docTypes['x1.1'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
return $docTypes[$type];
}- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
nickvd: I think your short names are too short. h4.01s? 
I'm all for standards compliance, so adhering to the true document type identifiers is nice, but I'm not exactly adhering to the standards. I'm actually using a subset of the functionality that is standard's compliant. So the real name would actually be "XHTML 1.0 Transitional Safe", but I think I'll put safe in another parameter.
Thanks for the input, anyone else have any thoughts?
I'm all for standards compliance, so adhering to the true document type identifiers is nice, but I'm not exactly adhering to the standards. I'm actually using a subset of the functionality that is standard's compliant. So the real name would actually be "XHTML 1.0 Transitional Safe", but I think I'll put safe in another parameter.
Thanks for the input, anyone else have any thoughts?
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
If I throw an error when they pass a bad short name, isn't that just as good? I'd like to stay away from constants, since define() is not very fast and they look ugly.Short names as class constants - why let the user make mistakes?
Not sure what you mean by that.Won't all this have to feed forward into the related HTML syntax?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
why not?
Code: Select all
class DocTypes
{
const XHTML_10_STRICT = '...';
....
}- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US