thanatos
2007-Nov-08 15:33 UTC
to_xml follows different path for collections than for individual objects
For example: I have an item and in script/console of my project I do: item.to_xml This executes through an elaborate path of modules and methods something like this: to_xml --> XmlSerializer --> which calls to_s, which is an alias in xml_serialization.rb for the method serialize. Serialize calls a method "builder" to make a new Builder::XmlMarkup (which extends from XmlBase). With this, the builder tags the attributes as needed. However, if I try it with an array of items I can''t figure out where it goes to and in what order. By putting out little notices in the different methods I mentioned above it would seem that to_xml with a collection goes in a nearly reverse order from a single item. The purpose of all of this is an attempt to add on option for to_xml that would allow it to skip escaping the xml unicode into html entities (using _escape --> Xchar#to_xs). Thanks for any hints. It would be nice to learn how to actually debug something like this. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Nov-08 15:37 UTC
Re: to_xml follows different path for collections than for individual objects
On 8 Nov 2007, at 15:33, thanatos wrote:> > > However, if I try it with an array of items I can''t figure out where > it goes to and in what order. > > By putting out little notices in the different methods I mentioned > above it would seem that to_xml with a collection goes in a nearly > reverse order from a single item. >check out to_xml in activesupport/lib/active_support/core_ext/array/ conversions.rb> The purpose of all of this is an attempt to add on option for to_xml > that would allow it to skip escaping the xml unicode into html > entities (using _escape --> Xchar#to_xs). > > Thanks for any hints. It would be nice to learn how to actually debug > something like this. >step through it with rdebug ? Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---