W3C home > Mailing lists > Public > www-svg@w3.org > May 2005

RE: SVG12: get/setAttribute

From: Ola Andersson <Ola.Andersson@ikivo.com>
Date: Mon, 23 May 2005 13:40:58 +0200
Message-ID: <586AE9F507AF5E4AA45364333D9E2FA201093CAF@sesthsrv02.zoomon.local>
To: "Bjoern Hoehrmann" <derhoermi@gmx.net>
Cc: <www-svg@w3.org>, "WG SVG" <w3c-svg-wg@w3.org>



> -----Original Message-----
> From: Bjoern Hoehrmann [mailto:derhoermi@gmx.net]
> Sent: den 23 maj 2005 13:03
> To: Ola Andersson
> Cc: www-svg@w3.org; WG SVG
> Subject: Re: SVG12: get/setAttribute
> 
> * Ola Andersson wrote:
> >>  In http://www.w3.org/TR/2005/WD-SVGMobile12-20050413/script.html
> >>several of the examples refer to many undefined operations like Element.
> >>setAttribute, Element.getAttribute, even Document.setAttribute is used;
> >>please change the draft to include more reasonable examples.
> >
> >This is now fixed.
> 
> What are the more reasonable examples, which examples do they replace,
> have other changes been made in response to my request?


MyEventListenerInitializer2 has been changed to:

package com.example;

import org.w3c.svg.EventListenerInitializer2;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;

public class MyEventListenerInitializer2 implements EventListenerInitializer2 {
   Document document;
    public void initializeEventListeners(Element scriptElement) {
        document = scriptElement.getOwnerDocument();
    }

    public EventListener createEventListener(final Element handlerElement) {
        return new EventListener() {
            public void handleEvent(Event event) {
                Element myRect = document.getElementById("myRect");
                float width = Float.parseFloat(myRect.getAttributeNS(null, "width"));

                float offest = Float.parseFloat(handlerElement.getAttributeNS("http://www.example.com/foo", "offset");
                myRect.setAttributeNS(null, width, "" + (width + 10));
            }
        };
    }
}

Example SVG 1.1 scripting has been changed to:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
    <rect id="myRect" x="10" y="20" width="200" height="300" fill="red"
        onclick="var width =  parseFloat(
        document.getElementById('myRect').getAttributeNS(null, 'width'));
        document.getElementById('myRect').setAttributeNS(null, 'width', (width+10));"/>
</svg>

No other changes has been made in response to your request. 

> --
> Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
> Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
> 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Received on Monday, 23 May 2005 11:41:05 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:30 GMT