Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml_name - missing letter s #19

Closed
cwhiteley opened this issue Jan 12, 2010 · 4 comments
Closed

xml_name - missing letter s #19

cwhiteley opened this issue Jan 12, 2010 · 4 comments

Comments

@cwhiteley
Copy link

I have found that the last letter s is dropped from the XML produced when the xml_name ends with the letter s.

xml_name 'Address' --> xml Addres
xml_name 'Demographics' --> xml Demographic

to fix this i have added a space and the s shows along with the space.

on a side note your library is awesome - thanks.

Thanks

@Empact
Copy link
Owner

Empact commented Jan 12, 2010

I'm using ActiveSupport's Inflector, which does this as a default behavior:

>> require 'rubygems'
=> true
>> require 'active_support'
=> true
>> 'address'.pluralize
=> "addresses"
>> 'address'.singularize
=> "addres"

So to solve this issue, you'll need to pre-register this special case with ActiveSupport ala:

# Add new inflection rules using the following format 
# (all these examples are active by default):
ActiveSupport::Inflector.inflections do |inflect|
  inflect.plural(/rion$/ ,'ria') # criterion => criteria
  inflect.singular(/ria$/, 'rion') # criteria => criterion
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
end

@Empact
Copy link
Owner

Empact commented Jan 12, 2010

Or at least, that's my best guess at what's going on. Could you try this out and let me know how it goes?

@aburtnett
Copy link

Thanks for posting this solution it is working for me on a similar issue. I've been using ROXML for several years and it's a great library. Would you consider adding an option to turn the inflector off for ROXML all together or at least on xml_name? This behavior is great on ActiveRecord, but for XML seems to be problematic since in general you are coding to a schema that has fixed names that can't change.

Thanks,
Andy

@Empact
Copy link
Owner

Empact commented Mar 24, 2010

Thanks Andy, but as I've just noted in the README, unfortunately I don't have the time to maintain ROXML at the moment. I'm hard at work on a legislative accountability website VoteReports (the site is in it's early stages at the moment, but due to be awesome in time for November)

I hope you'll consider taking a crack at any issues you run into yourself; the library is pretty well tested (given the large space of possible combinations), so you'll have those to keep you on the right track with any changes you make.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants