{"id":16102354,"url":"https://github.com/sshaw/jaxb2ruby","last_synced_at":"2025-08-16T16:33:06.595Z","repository":{"id":10759980,"uuid":"13022279","full_name":"sshaw/jaxb2ruby","owner":"sshaw","description":"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.","archived":false,"fork":false,"pushed_at":"2023-07-14T04:04:46.000Z","size":111,"stargazers_count":12,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-27T18:56:42.367Z","etag":null,"topics":["erb","jaxb","jruby","object-mapping","ruby","xml","xml-format","xml-schema","xml-serialization"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"br-adam-newman/raml-jsonschema-expander","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-22T22:40:59.000Z","updated_at":"2024-04-03T03:03:27.000Z","dependencies_parsed_at":"2022-09-13T17:51:27.342Z","dependency_job_id":null,"html_url":"https://github.com/sshaw/jaxb2ruby","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fjaxb2ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fjaxb2ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fjaxb2ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fjaxb2ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshaw","download_url":"https://codeload.github.com/sshaw/jaxb2ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229788101,"owners_count":18124187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erb","jaxb","jruby","object-mapping","ruby","xml","xml-format","xml-schema","xml-serialization"],"created_at":"2024-10-09T18:53:37.048Z","updated_at":"2024-12-17T00:44:32.689Z","avatar_url":"https://github.com/sshaw.png","language":"Ruby","readme":"# jaxb2ruby\n\n[![Build Status](https://travis-ci.org/sshaw/jaxb2ruby.svg)](https://travis-ci.org/sshaw/jaxb2ruby)\n[![Code Climate](https://codeclimate.com/github/sshaw/jaxb2ruby/badges/gpa.svg)](https://codeclimate.com/github/sshaw/jaxb2ruby)\n\nGenerate pure Ruby classes from an XML schema using [JAXB](https://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding) and JRuby\n\n### Usage\n\n    usage: jaxb2ruby [options] schema\n        -c, --classes=MAP1[,MAP2,...]    XML Schema type to Ruby class mappings\n                                         MAP can be a string in the form type=class or a YAML file of type/class pairs\n        -h, --help                       Show this message\n        -I, --include=DIRECTORY          Add DIRECTORY to the load path, usefull for using custom template helpers\n        -J, --jvm=[ARG1[,ARG2,...]]      Options to pass to the JVM when calling XJC\n        -n, --namespace=MAP1[,MAP2,...]  XML namespace to ruby class mappings\n                                         MAP can be a string in the form namespace=class or a YAML file of namespace/class pairs\n        -o, --output=DIRECTORY           Directory to output the generated ruby classes, defaults to ruby\n        -t, --template=NAME              Template used to generate the ruby classes\n                                         Can be a path to an ERB template or one of: roxml (default), happymapper, ruby\n        -v, --version                    jaxb2ruby version\n        -w, --wsdl                       Treat the schema as a WSDL\n                                         Automatically set if the schema has a `.wsdl' extension\n        -x, --xjc=PATH                   Path to the XJC executable to use; defaults to xjc\n\n### Instalation\n\n    gem install jaxb2ruby\n\n`jaxb2ruby` must be installed and ran under JRuby. The generated classes *will not* depend on JRuby.\n\nIf your underlying JDK version is \u003e= 9 you must use JRuby \u003e= 9.2.12.0.\n\nIf your underlying JDK version is \u003e= 11, you must [manually install JAXB](https://github.com/eclipse-ee4j/jaxb-ri).\nIn this case you'll likely run `jaxb2ruby` using the following (on *nix):\n\n    CLASSPATH=path/to/jaxb-ri/mod/jakarta.xml.bind-api.jar jaxb2ruby -x path/to/xjc.sh schema.xsd\n\n### Ruby Class Mappings\n\n#### XML Schema Built-in Types\n\nCertain XML schema types are converted to `Symbol`s.\nYou can specify your own XML Schema to Ruby type mapping(s) via the `-c` option.\n\nFor a complete list of mappings see [the `SCHEMA_TO_RUBY` constant](https://github.com/sshaw/jaxb2ruby/blob/master/lib/jaxb2ruby/type_util.rb).\n\n#### XML Schema Complex Types\n\nComplex schema types will `camelized` and turned into Ruby classes. If a type has a namespace\nthe namespace will be converted into a module and the resulting class will be placed inside.\n\nNamespaces are turned into modules using a slightly modified version of the rules outlined in the [The Java Architecture for XML Binding (JAXB) 2.0](http://download.oracle.com/otndocs/jcp/jaxb-2.0-fr-eval-oth-JSpec) Section D.5.1 _Mapping from a Namespace URI_. The differences being:\n\n* The list of module/package strings are joined on `\"::\"`\n* A module/package string beginning with `\"_\"` is replaced with `\"V\"`\n* Nested, anonymous XML schema types become Ruby inner classes\n\nSome examples:\n\n`{http://example.com}User` becomes `Com::Example::User`\n\n`{http://example.com/api/15}User` becomes `Com::Example::Api::V15::User`\n\nAn XML schema type `{http://example.com}User` that contains the nested complex type\n`Addresses`, which itself contains the type `Address` will result in the creation\nof 3 classes: `User`, `User::Addresses` and `User::Addresses::Address`, all within\nthe `Com::Example` namespace.\n\nYou can specify your own namespace to class mapping(s) via the `-n` option.\nNamespace mappings have a lower precedence than type mappings.\n\n### Code Templates\n\n`jaxb2ruby` uses ERB templates to create Ruby classes. You can use one of the bundled templates\nor [create your own](#rolling-out-your-own-templates). Use the `-t` option to specify the path to a custom\ntemplate or one of the following bundled ones:\n\n* `roxml` the default ([ROXML](https://github.com/Empact/roxml))\n* `happymapper` ([Nokogiri HappyMapper](https://github.com/dam5s/happymapper))\n* `ruby` - plain 'ol Ruby classes\n\nNote that \"plain 'ol Ruby classes\" does not perform XML serialization.\n\n#### Rolling out your own templates\n\nUse the `-t` option to specify the path to your template. This *must* be a path else it will be interpreted as a [jaxb2ruby template](#Code-Templates).\nTwo variables will be provided to your template:\n\n1. `@class`, an instance of [`RubyClass`](http://www.rubydoc.info/gems/jaxb2ruby/JAXB2Ruby/RubyClass)\n2. `VERSION` the version of `jaxb2ruby`\n\nSee `lib/templates` for some examples.\n\nYou can use helper functions in your templates by providing the helper file's directory to the `-I` option.\n\n### TODO\n\n* Map java.util.Hash\n* Do something with org.w3c.dom.*\n* Don't treat XML Schema types as elements\n* Circular dependencies, currently can be resolved by manually adding forward declarations\n* Fix other things that surely don't work\n\n### See Also\n\n* [class2](https://github.com/sshaw/class2) - easily create class\n  hierarchies that support nested attributes, type conversion,\n  equality, and more, all from a hash specification\n\n### Author\n\nSkye Shaw [sshaw AT gmail.com]\n\n### License\n\nReleased under the MIT License: www.opensource.org/licenses/MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fjaxb2ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshaw%2Fjaxb2ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fjaxb2ruby/lists"}