Pls test and comment on rails patch to use jdom backend for Hash.to_xml

Rails normally uses REXML to implement this class method
activesupport adds to Hash:

Hash.to_xml

This is used when Rails needs to process data in XML form such as
when ActiveResource consumes an external resource.

Rails 2.3 added support for using LibXML and Nokogiri as backends for
from_xml if these gems are installed which can speed up the process.

I’ve created a patch for rails that adds support for using jdom as a
backend if rails is running under jruby.

I’m sure my implementation could be sped up considerably but as it is
now it’s about 3x faster than rexml when processing a large (1.8MB)
xml document.

Normally Hash.from_xml will just use REXML.

You can set an alternate backend like this:

ActiveSupport::XmlMini.with_backend(‘JDOM’) {
Hash.from_xml({:a => “foo”,:b => “bar”}.to_xml)
}

Within the block the from_xml method will use the JDOM backend
instead of REXML.

I’d love some other eye’s on the patch. Unless it gets some '+1’s
from other JRuby developers it won’t get applied.

The patch is attached here:

https://rails.lighthouseapp.com/projects/8994/tickets/2238-add-jdom-jruby-as-xmlmini-backend

It applies cleanly to 2.3.2 and to 2-3-stable.

I haven’t tested it yet on master (which is heading off to rails3-land).

This patch relates to more general work I’m doing benchmarking the
alternate from_xml backends and generalizing the tests.

See:

https://rails.lighthouseapp.com/projects/8994/tickets/2258-libxml-xml_mini-backend-producing-incorrect-hashes

and


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Wow, this would be AWESOME as a GitHub gem for general JRuby work! Hide
all
that ugly Java-ness under a sweet Ruby wrapper.

Ikai

On 4/24/09 1:20 PM, “Stephen B.” [email protected]
wrote:

The patch is attached here:
alternate from_xml backends and generalizing the tests.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email