[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
Re: [wml] Handling unknown attributes
- From: Denis Barbier <nospam@thanx>
- Date: Tue, 11 Jul 2000 00:29:46 +0200
On Sun, Jul 09, 2000 at 12:40:48AM +0200, Denis Barbier wrote:
[...]
> Mp4h version 1.0.4 introduces 3 new tags to play with attributes:
> <attributes-remove name1,name2,... %attributes>
> Like %attributes, but remove variables whose name is one of
> name1, name2, and so on.
> <attributes-extract name1,name2,... %attributes>
> Prints only the name=value pair matching names name1, name2,...
> <attributes-quotes %attributes>
> The two macros above gobble quotes like any other mp4h macros.
> This one prints its attributes with value between quotes. It must
> only be used when printing its content on output without any
> further processing.
[...]
> Next step is to add an `image' attribute:
> <define-tag hyperlink whitespace=delete>
> <preserve url text image>
> <set-var <attributes-extract url,text,image %attributes>>
> <defvar text "<get-var url>">
> <a <attributes-quote <attributes-remove url,text,image %attributes>> \
> href="<get-var url>">
> <if <get-var image>
> <img src="<get-var image>" alt="<get-var text>">
> <get-var text>>
> </a>
> <restore url text image>
> </define-tag>
> <hyperlink url="http://..." class=www image=foo.gif>
>
> But there is a trivial flaw in this implementation, we have to choose if
> unknown attributes go into <a> or <img>.
What do you think of this writing?
<define-tag hyperlink whitespace=delete>
<preserve url text image>
<set-var <attributes-extract url,text,image %attributes>>
<a <attributes-quote <attributes-extract :a:(.*) %attributes>> \
href="<get-var url>">
<if <get-var image>
<img <attributes-quote <attributes-extract :img:(.*) %attributes>> \
src="<get-var image>" alt="<get-var text>">
<get-var text>
>
</a>
<restore url text image>
</define-tag>
<hyperlink :a:class=web :img:id=logo :img:border=1 \
url="http://www.foo.com" text="Welcome" image="foo.png">
prints
<a class="web" href="http://www.foo.com"><img id="logo" border="1"
src="foo.png" alt="Welcome"></a>
Wildcards are allowed in first argument of <attributes-*>, and when
there is a subexpression, it is printed instead of the whole expression.
--
Denis Barbier
WML Maintainer
______________________________________________________________________
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List sw-wml@engelschall.com
Automated List Manager majordomo@engelschall.com