[Twisted-web] Re: [Nevow-commits] Replace ID generator values
with IDs based on context.key. Group
Matt Goodall
twisted-web@twistedmatrix.com
Tue, 02 Mar 2004 09:25:23 +0000
On Tue, 2004-03-02 at 01:13, James Y Knight wrote:
> On Feb 29, 2004, at 6:19 PM, mg CVS wrote:
> > +def keyToXMLID(key):
> > + """Convert a key into an XML-style ID """
> > + if not key:
> > + print 'keyToXMLID: no key, but why?'
> > + return None
> > + return '-'.join(key.split('.'))
>
> Did you run into a specific problem forcing the translation of . to -?
> The HTML spec says:
> - 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 (".").
>
> The XHTML spec seems to be even more open, allowing many many
> characters to be used in names. It says you should only use names
> matching [A-Za-z][A-Za-z0-9:_.-]* if you want to be compatible with
> HTML4.
Not a specific problem as such. I replaced '.' with '-' to make the
elements selectable by ID in the CSS, as well as useful within the
document itself. JavaScript should also have no trouble getting a
reference to the elements using either the DOM or form.elements[] API.
Is this ok, can you think of any problems with doing this?
Cheers, Matt
--
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt@pollenation.net
Any views expressed are my own and do not necessarily reflect
the views of my employer.