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

What do I put in the class mappings YAML file? #5

Closed
edward-ellis opened this issue Apr 14, 2017 · 3 comments
Closed

What do I put in the class mappings YAML file? #5

edward-ellis opened this issue Apr 14, 2017 · 3 comments

Comments

@edward-ellis
Copy link

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.

@edward-ellis
Copy link
Author

BuildingSync.zip

@sshaw
Copy link
Owner

sshaw commented Apr 15, 2017

[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

This is coming from JAXB (xjc). Two ways to resolve this:

1. Specify a mapping via an JAXB config file

Currently jaxb2ruby does not provide a "friendly" way to do this, nor does it allow one to specify a JAXB config file as it may conflict with the one it uses. So I guess at this time this is just a theoretical option that would make a nice feature 😃. The latter may be trivial (pull requests welcome!), but testing would be needed to ensure the internal config had priority.

You can see how to do this under the Fix Collides Example section in the JAXB docs.

2. Modify the schema

Change the ScenarioType complex type to something like ScenarioDataType. This will not affect XML to object mapping; it will just result in a class named ScenarioDataType being created instead of one named ScenarioType.

Really you'll probably want to use the -n option to rid yourself of the ugly Ruby namespaces that will be created. You can use a file of mappings too. See how the DDEX library does it.

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

This command line option (or file) is for mapping XSD data types to Ruby classes. E.g., xsd:boolen to TrueClass.

@sshaw
Copy link
Owner

sshaw commented Apr 19, 2017

Closing.

If you have any suggestions on how to improve the docs for this let me know or open a pull request.

Thanks

@sshaw sshaw closed this as completed Apr 19, 2017
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