Forum: JRuby pls test and comment on rails patch to use jdom backend for Hash.to_xml

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Stephen B. (Guest)
on 2009-04-25 00:49
(Received via mailing list)
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/tick...

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/tick...

and

http://github.com/stepheneb/rails_hash_from_xml/tree/master


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ikai L. (Guest)
on 2009-04-25 02:37
(Received via mailing list)
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." <removed_email_address@domain.invalid>
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
This topic is locked and can not be replied to.