You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Randy Leonard <ra...@hotmail.com> on 2003/04/25 07:32:54 UTC

programmatically manipulating DOM tree

Just wondering why I cannot use explicit API's to manipulate DOM trees I am
creating programmatically.  For example, I create a SVGOMRectElement object
as follows:

    SVGOMRectElement rectangle =
(SVGOMRectElement)doc.createElementNS(svgNS, "rect");

Then set it's with ad follows:

    rectangle.setAttributeNS(null, "width", "100");

Which works... but the following does not work, says the object is "read
only"

    SVGRect rect = rectangle.getBBox();
    rect.setWidth(25);

I tried setting the rectangle object as not "read only", but to no avail.  I
prefer explicit API's over methods which take key/value parameters as it
lets the compiler catch my spelling mistakes.  Or should I just not fight
the setAttributeNS method?

Thanks,
Randy

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: programmatically manipulating DOM tree

Posted by Vincent Hardy <vi...@sun.com>.
Hi Randy,

Yes, the getBBox returns a read only value. It is not meant to change 
the geometry of the object whose bounds it describes.

There are strongly typed methods in the SVG DOM. To see what Batik 
supports, refer to:

http://xml.apache.org/batik/SVGDOMstatus.html

Vincent.

Randy Leonard wrote:
> Just wondering why I cannot use explicit API's to manipulate DOM trees I am
> creating programmatically.  For example, I create a SVGOMRectElement object
> as follows:
> 
>     SVGOMRectElement rectangle =
> (SVGOMRectElement)doc.createElementNS(svgNS, "rect");
> 
> Then set it's with ad follows:
> 
>     rectangle.setAttributeNS(null, "width", "100");
> 
> Which works... but the following does not work, says the object is "read
> only"
> 
>     SVGRect rect = rectangle.getBBox();
>     rect.setWidth(25);
> 
> I tried setting the rectangle object as not "read only", but to no avail.  I
> prefer explicit API's over methods which take key/value parameters as it
> lets the compiler catch my spelling mistakes.  Or should I just not fight
> the setAttributeNS method?
> 
> Thanks,
> Randy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-dev-help@xml.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org