Coder Social home page Coder Social logo

sshaw / jaxb2ruby Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 9.0 111 KB

Generate pure Ruby objects from an XML schema (XSD) using JAXB and JRuby. Use your favorite XML to object mapper or a custom ERB template.

Ruby 89.11% HTML 10.89%
ruby xml jruby xml-serialization xml-format jaxb xml-schema erb object-mapping

jaxb2ruby's Issues

Thanks!

@sshaw I wasn't sure how to get in contact with you, but this gem worked brilliantly (inside of a Docker container)! Thanks for making it πŸŽ‰

Support for JRuby > 1.9.3

This looks to be the only problem:

JAXB2Ruby::Template::a class created by the ruby template#test_0003_has singular read/write accessors for attributes:
ArgumentError: wrong number of arguments (1 for 0)
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:75:in `find_namespace'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:93:in `translate_type'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:135:in `extract_class'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:233:in `block in extract_classes'
    org/jruby/RubyArray.java:1733:in `each'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:230:in `extract_classes'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:42:in `create_ruby_classes'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:29:in `convert'
    /Users/sshaw/code/ruby/jaxb2ruby/jaxb2ruby/lib/jaxb2ruby/converter.rb:14:in `convert'
    /Users/sshaw/code/ruby/jaxb2ruby/spec/spec_helper.rb:10:in `convert'
    /Users/sshaw/code/ruby/jaxb2ruby/spec/template_spec.rb:68:in `block in (root)'
    org/jruby/RubyBasicObject.java:1687:in `instance_eval'

What do I put in the class mappings YAML file?

Thank you for releasing jaxb2ruby. I am trying to convert a schema that I don’t control into Ruby classes. However, I get the recommendation:

β€’ [ERROR] Complex type and its child element share the same name "ScenarioType". Use a class customization to resolve this conflict. line 2265 of file:/C:/jaxb/BuildingSync.xsd

I see that I can use the –c option to specify a YAML file, but I’m not really sure what to put in the YAML file. I have attached the full XSD for reference and have also made an excerpt below that illustrates my specific problem. I think a small sample YAML file will allow me to find my way forward on my own.

--- cut out extra ---
<xs:complexType name="ScenarioType">
xs:sequence
<xs:element name="ScenarioName" type="xs:string" minOccurs="0">
xs:annotation
xs:documentationName of the scenario for which energy use data is included. This may include benchmarks, baselines, and improved cases. For retrofits, each package represents a different scenario.</xs:documentation>
</xs:annotation>
</xs:element>
--- cut out extra ---
<xs:element name="ScenarioType" minOccurs="0">
xs:annotation
xs:documentationType of scenario for which energy use is presented.</xs:documentation>
</xs:annotation>
xs:complexType
xs:choice
--- cut out extra ---

By the way , I tried to send this request to your email sshaw AT gmail.com and GMail rejected it. Yes, I made the obvious corrections.

Class generation failed: undefined method `split' for nil:NilClass

Error appears while running generator with schema files taken from OpenTravel site:

http://opentravelmodel.net/pubs/content/specifications/downloads/2007A/OTA_1_0/2007A_10_Publication.zip

(this link requires accepting license agreement and some form filling to access)

$ unzip 2007A_10_Publication.zip
$ jaxb2ruby -t roxml _OTA2007A_XML/OTA_VehAvailRateRQ.xsd
outputting classes to ruby
generating: org/opentravel/ota/v2003/v05/acceptable_payment_cards_info_type/acceptable_payment_cards/acceptable_payment_card.rb
generating: org/opentravel/ota/v2003/v05/acceptable_payment_cards_info_type/acceptable_payment_cards.rb
generating: org/opentravel/ota/v2003/v05/acceptable_payment_cards_info_type.rb
generating: org/opentravel/ota/v2003/v05/accepted_payments_type.rb
generating: org/opentravel/ota/v2003/v05/address_info_type.rb
generating: org/opentravel/ota/v2003/v05/address_pref_type.rb
generating: org/opentravel/ota/v2003/v05/address_type/bldg_room.rb
generating: org/opentravel/ota/v2003/v05/address_type/street_nmbr.rb
generating: org/opentravel/ota/v2003/v05/address_type.rb
generating: org/opentravel/ota/v2003/v05/bank_acct_type.rb
generating: org/opentravel/ota/v2003/v05/blackout_date_type.rb
generating: org/opentravel/ota/v2003/v05/cancel_info_rq_type.rb
generating: org/opentravel/ota/v2003/v05/cancel_info_rs_type/cancel_rules.rb
generating: org/opentravel/ota/v2003/v05/cancel_info_rs_type.rb
generating: org/opentravel/ota/v2003/v05/cancel_rule_type.rb
generating: org/opentravel/ota/v2003/v05/comment_type/comment.rb
generating: org/opentravel/ota/v2003/v05/comment_type.rb
generating: org/opentravel/ota/v2003/v05/commission_type/commission_payable_amount.rb
generating: org/opentravel/ota/v2003/v05/commission_type/commissionable_amount.rb
generating: org/opentravel/ota/v2003/v05/commission_type/flat_commission.rb
generating: org/opentravel/ota/v2003/v05/commission_type/prepaid_amount.rb
generating: org/opentravel/ota/v2003/v05/commission_type.rb
generating: org/opentravel/ota/v2003/v05/common_pref_type.rb
class generation failed: undefined method `split' for nil:NilClass
backtrace: 
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/lib/jaxb2ruby/classes.rb:171:in `requires'
org/jruby/RubyArray.java:2412:in `map'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/lib/jaxb2ruby/classes.rb:171:in `requires'
(erb):8:in `result'
org/jruby/RubyKernel.java:1101:in `eval'
/home/dev/.rvm/rubies/jruby-1.7.16/lib/ruby/1.9/erb.rb:838:in `result'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/lib/jaxb2ruby/template.rb:30:in `build'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/bin/jaxb2ruby:81:in `(root)'
org/jruby/RubyIO.java:1181:in `open'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/bin/jaxb2ruby:81:in `(root)'
org/jruby/RubyArray.java:1613:in `each'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/gems/jaxb2ruby-0.0.1-java/bin/jaxb2ruby:78:in `(root)'
org/jruby/RubyKernel.java:1081:in `load'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/bin/jaxb2ruby:1:in `(root)'
org/jruby/RubyKernel.java:1101:in `eval'
/home/dev/.rvm/gems/jruby-1.7.16@jaxb/bin/jruby_executable_hooks:15:in `(root)'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.