>> in the DOM order has relevance. Attributes are stored as a list, not a map. 
>> Pivot's org.apache.pivot.xml.Element class provides both keyed and indexed 
>> access to attributes.
> 
> Huh?  What language/implementation of the DOM are you referencing?  I'm 
> looking at Java's org.w3c.dom.Node, in which an element's attributes are 
> represented by a org.w3c.dom.NamedNodeMap.

An element's child nodes are also accessible via Node#getChildNodes(), which 
returns an ordered list of children.

> Anyway, a list is a map.  Or to put it another way, any collection can be 
> represented by a list simply by enumerating the elements of that collection 
> in some way.  That does not imply that that collection has some kind of 
> innate or natural ordering.

It depends on the implementation of the map. Some have an implicit order, while 
others do not. For example, the JDK supports a SortedMap interface that imposes 
a strict ordering on key enumeration. A Pivot map can be ordered by setting the 
comparator property.

> There is nothing in the StAX spec that states that Attributes are indexed by 
> the order in which they are written.

Actually, there is. XMLStreamReader#getAttributeCount() returns the number of 
attributes associated with the current element, and the following methods 
return information about an attribute at a given index:

getAttributeLocalName(int index) 
getAttributeName(int index) 
getAttributeNamespace(int index) 
getAttributePrefix(int index) 
getAttributeType(int index) 
getAttributeValue(int index) 

Thus, attributes in StAX have a specific ordering applied. BXMLSerializer takes 
advantage of this feature to ensure that attributes are processed in the 
correct order. Regardless, you can later access the properties in an unordered 
way if the deserialized element is a Dictionary or a bean that can be wrapped 
in a BeanAdapter.

I'll ask you again to try to be a bit less aggressive and arrogant-sounding 
with your posts. I have already explained why attribute ordering is relevant in 
BXMLSerializer. I'm really not interested in continuing to argue with you about 
it.


Reply via email to