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

Schema to classes conversion fails if XML elements has an "invalid" character #21

Open
jairojunior opened this issue Aug 31, 2015 · 2 comments

Comments

@jairojunior
Copy link

If I have an XML element with a dash (-) within its name (e.g. buffer-cache), schema.to :ruby_classes fails with the following error:

ruby-1.9.3-p551/gems/rxsd-0.5.2/lib/rxsd/builders/ruby_class.rb:39:inconst_set': wrong constant name Buffer-cache (NameError)`

Does anyone have any thoughts regarding this issue?

@movitto
Copy link
Owner

movitto commented Sep 7, 2015

It's been a while but grepping through the code, we seem to invoking "camelize" on attribute, element, simple type, and complex type names and setting that to the ClassBuilder.klass_name, which gets passed onto Object.const_set

https://github.com/movitto/RXSD/blob/master/lib/rxsd/xsd/element.rb#L139
https://github.com/movitto/RXSD/blob/master/lib/rxsd/builders/ruby_class.rb#L39

String#camelize defined in active support will convert "foo-bar" into "Foo-bar" which is an invalid const name, hence the issue.

Perhaps swapping dashes (-) with underscores (_) before invoking camlize is invoked may work. Don't currently have time for this, but pr's / other thoughts are more than welcome.

@jairojunior
Copy link
Author

Thank you. I will work on a PR as soon I can, just wanted a hint before dig into the code.

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

2 participants