W3C home > Mailing lists > Public > www-html@w3.org > June 2003

ID and NAME tokens (CDATA problems)

From: Peter Foti (PeterF) <PeterF@SystolicNetworks.com>
Date: Wed, 4 Jun 2003 14:16:43 -0400
Message-ID: <A10A983C9DFBD4119F0300104B2EA6B72602D1@ZIPPY>
To: "'www-html@w3.org'" <www-html@w3.org>

The HTML 4 recommendation states that:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods ("."). 

http://www.w3.org/TR/html4/types.html#type-cdata

However, I question whether the period should be allowed, as this is the
character used to access properties in JavaScript/ECMAScript:

http://www.ecma-international.org/publications/standards/ECMA-262.HTM

Thus, if a form is defined as follows:

<form action="" name="myform">
   <input name="readme.txt-title">
   <input name="readme.txt-author">
</form>

There does not seem to be any way to access those input items using their
names, because the dot notation:

document.myform.readme.txt-title

causes the script interpreter to look for input named "readme", because the
period is seen as the indicator of the next property.  In this case, the
only way to access the item is through the array notation, which can be
expensive if the index of the input item is not known (could require
iterating through all of the input items in the array).

I have not found any other mention of this limitation in either the ECMA-262
specification or the HTML recommendations, but it seems to me like it's
either an oversight in the HTML recommendations, or else there must be some
other hard-to-find documentation that discusses a workaround for this
shortcoming.

Peter Foti
Granite Stream
Phone: (603) 870-8170
Fax: (603) 870-8170
Received on Wednesday, 4 June 2003 14:03:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:55 GMT