[Zope3-dev] Re: idea: attr:foo addition to tal
Philipp von Weitershausen
philipp at weitershausen.de
Fri Jul 23 08:45:18 EDT 2004
Philipp von Weitershausen wrote:
> Tonico Strasser wrote:
>
>> Steve Alexander wrote:
>>
>>> I was writing yet another tal:attributes expression, when I had the
>>> following idea.
>>>
>>> How about if there were an 'attr' namespace that the tales
>>> interpreter understands that replaces attributes?
>>>
>>> So, instead of
>>>
>>> <a tal:attributes="href item/url" tal:content="item/description" />
>>>
>>> we get
>>>
>>> <a attr:href="item/url" tal:content="item/description" />
>>
>>
>>
>> -1 for me.
>>
>> <a attr:xml:lang="here/lang"/>
>
>
> Using namespaces in XHTML is a rare case; however, we don't want to
> limit Page Templates to non-namespaced XML templates. But since it's a
> rare case, it wouldn't hurt falling back to tal:attributes there.
>
> Or, we could have a different separate, e.g.:
>
> <a attr:xml#lang="here/lang" />
>
> Then again, I would have to read the spec to see if # or similar are
> allowed in attribute names...
Even if it would, we shouldn't make the assumption that nobody would use
it for their own attributes. So, this was a bad idea of mine. HOWEVER, I
have an idea for the namespaced attribute problem:
<div
xmlns:attr="http://xml.zope.org/tal-attr"
xmlns:xmlattr="http://xml.zope.org/tal-attr#http://www.w3.org/XML/1998/namespace">
<a attr:href="context/@@absolute_url"
xmlattr:lang="request/locale/id/language" />
</div>
Basically, for every namespace that you need to define dynamic
attributes in, you define a new namespace prefix with the URI
<tal-attr-URI>#<ns-uri>. This way, the TAL parser will pick it up and
know in which XML namespace to put the attribute in.
Philipp
More information about the Zope3-dev
mailing list