Re: XML Events

> Hi Sigurd,
> On Sun, 02 Feb 2003, Sigurd Lerstad wrote:
> > 1.
> >
> > <listener ev:handler="#somehandler"
> >
> > how is a XHTML/SVG document supposed to deal with that, what if e.g
> >
> > <p id="somehandler">
> >
> > What should happen when listener gets an event, what should it do to the
> > element?
> I believe that is left up to the host language. In this case, the
> <p> element (I assume it is an HTML <p>) has no way of handling
> the event so the event just disappears.

Yes, It's up to the host language, and in this(my) case SVG.. but it makes
sense that <p> (in XHTML) can't handle it. What elements CAN handle it?
<script> elements?

> > Is javascript allowed inside the ev:handler attribute?
> No. Only a URI reference.

Yes, I found that out shortly after.

> > 3.
> >
> > In this example from the XML Events spec:
> > <script type="application/x-javascript"
> >         ev:event="submit" ev:observer="form1">
> >    return docheck(event);
> > </script>
> >
> > where is the event variable inside docheck coming from, is this a global
> > object fetched from the global 'window' object, or is an object named
> > 'event' always passed in?
> Welcome to the big mess that is scripting.
> In SVG, most implementations just load all the code in
> the script element into a single shared namespace (I'm not sure if
> that is specified, but that is how it is done).

This is another problem. if you have the above script meant to be a handler,
older viewers will just execute the script right after loading, which
obviously isn't supposed to happen. But wasn't there a 'for' and 'event'
attribute on the script element in HTML to attach a handler to the script
element? these 'for' / 'event' attribute now seems to be replaced with
ev:event. So A viewer, when traversing all the script elements on the page,
must check for the ev:event attribute and only execute the script if it
isn't there?

But how about..

<script id="doit">
return docheck(event)

<ellipse ev:event="mousedown" ev:handler="#doit">

Now, there's no ev:event on the script, but it's obviously meant to be a

What to do here?

> So, in this case the above example doesn't really make
> sense (since there is no enclosing function, and no way
> to enter the code at that point). (Again, it's likely that
> I'm wrong here).

My understanding was that scripts with no enclosing function were to execute
immediately after loading the page (or in old HTML, execute as the page is

> As for the magic "event" variable, it seems that most
> scripting implementations define a variable called "event"
> or "evt" to be used in a handler attribute
> (e.g. onmousedown="docheck(evt)").
> To me it is unclear what's supposed to happen here.
> Anyone have any ideas?

The way IE gets events from ActiveX controls is to have <script
for="someobject" event="someevent(arg1,arg2)">

Or something like that. So you must know the number of parameters passed in
from the event, but you can name them what you like, so maybe having
something like

<script ev:event="mousemove(event)">


Sigurd Lerstad

Received on Thursday, 6 February 2003 07:52:26 UTC