Keith Fahlgren
6/7/2007 5:50:00 PM
On 6/7/07, Arunprabu Durairaju <arunprabu@gmail.com> wrote:
> Hi Johnson,
>
> I understand that it is not specified in the XML specification and it is
> not a requirement generally.
>
> I also checked with REXML and it has the same behaviour as Builder.
Yeah, I'm sure they both use Hashes internally for attributes (and
Hashes are unordered in Ruby). However, it'd be easy to modify the
attribute insertion in Builder to take an Array instead. This is what
you'll have to change:
gems/builder-2.0.0/lib/builder/xmlmarkup.rb
# Insert the attributes (given in the hash).
def _insert_attributes(attrs, order=[])
return if attrs.nil?
order.each do |k|
v = attrs[k]
@target << %{ #{k}="#{_attr_value(v)}"} if v
end
attrs.each do |k, v|
@target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k)
end
end
Keith