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

RE: SVG12: get/setAttribute

From: <Suresh.Chitturi@nokia.com>
Date: Mon, 23 May 2005 19:27:44 -0500
Message-ID: <27593A2B3CEFFB47931AD9D6A8C62A0687F0AB@daebe101.NOE.Nokia.com>
To: <Ola.Andersson@ikivo.com>, <derhoermi@gmx.net>
Cc: <www-svg@w3.org>, <w3c-svg-wg@w3.org>

Hi Ola,
 
For attirbutes/properties in SVG namespace (in particular for SVGT 1.2) , we must use the trait methods and such as getXXXTrait() and not getAttribtue/setAttributeNS. For elements in other namespaces, it is okay to use getAttributeNS/setAttributeNS.
 
Please fix them.
 
Thanks,
-Suresh

________________________________

From: w3c-svg-wg-request@w3.org on behalf of ext Ola Andersson
Sent: Mon 5/23/2005 6:40 AM
To: Bjoern Hoehrmann
Cc: www-svg@w3.org; WG SVG
Subject: RE: SVG12: get/setAttribute






> -----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 Saturday, 28 May 2005 07:59:35 GMT

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