Seems to work but I made a bunch of syntax errors in my original post
<?xml version="1.0" encoding="utf-8"?>
<svg id="rects"
width="100%" height="100%"
xmlns="http://www.w3.org/2000/svg"
xmlns:swap="http://www.xxx.com/ns">
<rect swap:title="R1" swap:y1="20" swap:y2="35" x="14" y="50"
width="3" height="31"/>
<rect swap:title="R2" swap:y1="30" swap:y2="35" x="12" y="20"
width="3" height="11"/>
<rect swap:title="r1" swap:y1="20" swap:y2="30" x="140" y="20"
width="3" height="21"/>
<rect swap:title="R3" swap:y1="40" swap:y2="30" x="21" y="10"
width="3" height="1"/>
<rect swap:title="Rn" swap:y1="20" swap:y2="30" x="140" y="20"
width="3" height="21"/>
</svg>
var r=document.getElementById('rects')
var coll=r.getElementsByTagNameNS
('http://www.w3.org/2000/svg', 'rect')
var i=0;
var elm;
while(elm=coll.item(i++)){
elm.setAttributeNS(null,'y',elm.getAttributeNS
('http://www.xxx.com/ns','y1'));
}
--- In [email protected], "simonshutter" <[EMAIL PROTECTED]>
wrote:
>
> Hi,
>
> I have a scenario where I need to plot hundreds of rectangles and
> each rectangle has two possible y values but all other attributes
are
> static. To save space I was hoping to add two attributes that
could
> be swapped in response to events. Does this make sense and what do
> you suggest as a method for swapping the two y attribute values?
> Would I have to loop over each element sequentially or is there a
> faster way?
>
> Thanks, Simon
>
> The markup would be something like this :
>
> <?xml version="1.0" encoding="utf-8"?>
> <svg id="rects"
> width="100%" height="100%"
> xmlns="http://www.w3.org/2000/svg"
> xmlns:swap="http://www.xxx.com/ns">
> <rect attrib:title="R1" attrib:y1="20" attrib:y2="35" x="14"
y="50"
> width="3" height="31"/>
> <rect attrib:title="R2" attrib:y1="30" attrib:y2="35" x="12"
y="20"
> width="3" height="11"/>
> <rect attrib:title="r1" attrib:y1="20" attrib:y2="30" x="140"
> y="20" width="3" height="21"/>
> <rect attrib:title="R3" attrib:y1="40" attrib:y2="30" x="21"
y="10"
> width="3" height="1"/>
> <rect attrib:title="Rn" attrib:y1="20" attrib:y2="30" x="140"
> y="20" width="3" height="21"/>.
> </svg>
>
>
> The script could be something like :
>
> var r=document.getElementById('rects')
> var coll=r.getElementsByTagNameNS
> ('http://www.w3.org/2000/svg', 'rect')
> var i=0
> var elm;
> while(elm=coll.item(i++)){
> elm.setAttributeNS(null,'y',elm.getAttributeNS
> ('http://www.xxx.com/ns,'y'));
> }
>
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/