You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Bruce Rindahl <ri...@lrcwe.com> on 2007/06/19 00:28:20 UTC

FW: items() method in javascript returns array elements in incorrect order

I sent this in February but got no response.  Is it possible for someone to
look at this?
Thanks!
Bruce Rindahl

-----Original Message-----
From: Bruce Rindahl [] 
Sent: Tuesday, February 27, 2007 12:59 PM
To: 'batik-users@xmlgraphics.apache.org'
Subject: items() method in javascript returns array elements in incorrect
order

I obtain a single node with numerous attributes from a server via
XMLHTTPRequest.  I then want add the attributes as text to a SVG group. If
the node is 'list' then each attribute name and value is obtained by:

for (i=1;i<list.attributes.length-1;i++){
	list.attributes.item(i).name
	list.attributes.item(i).value
}


This works perfectly in IE7/ASV, FF, Opera but in Batik the name and value
pairs are in a different order.  It looks like the items() method uses a
hash table ordering instead of the original.  Is this a bug or a design
feature?

Thanks
Bruce Rindahl 



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


Re: FW: items() method in javascript returns array elements in incorrect order

Posted by Archie Cobbs <ar...@awarix.com>.
XML attributes are in general not ordered, so you can't expect ordering to
be preserved when an XML document is read into memory as a DOM.

On 6/18/07, Bruce Rindahl <ri...@lrcwe.com> wrote:
>
> I sent this in February but got no response.  Is it possible for someone
> to
> look at this?
> Thanks!
> Bruce Rindahl
>
> -----Original Message-----
> From: Bruce Rindahl []
> Sent: Tuesday, February 27, 2007 12:59 PM
> To: 'batik-users@xmlgraphics.apache.org'
> Subject: items() method in javascript returns array elements in incorrect
> order
>
> I obtain a single node with numerous attributes from a server via
> XMLHTTPRequest.  I then want add the attributes as text to a SVG group. If
> the node is 'list' then each attribute name and value is obtained by:
>
> for (i=1;i<list.attributes.length-1;i++){
>         list.attributes.item(i).name
>         list.attributes.item(i).value
> }
>
>
> This works perfectly in IE7/ASV, FF, Opera but in Batik the name and value
> pairs are in a different order.  It looks like the items() method uses a
> hash table ordering instead of the original.  Is this a bug or a design
> feature?
>
> Thanks
> Bruce Rindahl
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>


-- 

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

RE: FW: items() method in javascript returns array elements in incorrect order

Posted by Bruce Rindahl <ri...@lrcwe.com>.
My bad.  I never remember seeing this.  Thanks for the clarification.
Bruce

-----Original Message-----
From: Cameron McCormack [mailto:cam@mcc.id.au] 
Sent: Monday, June 18, 2007 5:30 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: FW: items() method in javascript returns array elements in
incorrect order

Hi Bruce.

Bruce Rindahl:
> I sent this in February but got no response.  Is it possible for someone
to
> look at this?

Thomas did respond to this:

 
http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200703.mbox
/%3COFB41871B4.1A328D1F-ON85257291.003B6736-85257291.003BB1EE@knotes.kodak.c
om%3E

Attributes on an element are considered to be unordered, so Batik is
correct in returning them in whatever order it likes.  (Having them in a
hash table makes it faster to look up specific attributes.  Not keeping
the original ordering around saves memory, since the order is not
important.)

Cameron

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ?  ICQ 26955922  ?  MSN cam@mcc.id.au

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





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


Re: FW: items() method in javascript returns array elements in incorrect order

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Bruce.

Bruce Rindahl:
> I sent this in February but got no response.  Is it possible for someone to
> look at this?

Thomas did respond to this:

  http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200703.mbox/%3COFB41871B4.1A328D1F-ON85257291.003B6736-85257291.003BB1EE@knotes.kodak.com%3E

Attributes on an element are considered to be unordered, so Batik is
correct in returning them in whatever order it likes.  (Having them in a
hash table makes it faster to look up specific attributes.  Not keeping
the original ordering around saves memory, since the order is not
important.)

Cameron

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

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