After struggling for a few hour, I was able to generate JAXB source codes from Collada Schema v1.5.
Here is how I did and it is for anybody who may have the problem I was having.
I got the Collada schema file from here.
At my first try, I got errors:
> xjc.exe -p collada collada_schema_1_5.txtThis error is due to name conflict. The name "source" is defined for an attribute and inner element. It can be like this:
[ERROR] Property "Source" is already defined. Use <jaxb:property> to resolve this conflict.
[ERROR] The following location is relevant to the above error
<skin_type source="somekindofURL"> <source></source> </skin_type>The generated Java source code from JAXB will have a member method "getSource()" for both the element and the attribute so does the conflict happens.
This issue can be resolved by providing "binding" information that simply rename one of them from "source" to something else. The binding information looks like this:
<bindings br="" xmlns="http://java.sun.com/xml/ns/jaxb"> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"But this solves only half of the problem.
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.1">
<bindings schemalocation="collada_schema_1_5.xsd" version="1.0">
<!-- rename the value element -->
<bindings node="//xs:complexType[@name='skin_type']">
<bindings node=".//xs:attribute[@name='source']">
<property name="source_attr">
</property></bindings>
</bindings>
<bindings node="//xs:complexType[@name='morph_type']">
<bindings node=".//xs:attribute[@name='source']">
<property name="source_attr">
</property></bindings>
</bindings>
</bindings></bindings>
> xjc.exe -b collada_binding.xjc -p collada collada_schema_1_5.xsdThis error was easier to resolve by internet searching.
[ERROR] Property "MiOrMoOrMn" is already defined. Use <jaxb:property> to resolve this conflict.
https://jaxb.java.net/guide/Dealing_with_errors.html
https://weblogs.java.net/blog/kohsuke/archive/2006/03/simple_and_bett.html
This issue can be solved by having an extension file:
<xs:schema br="" targetnamespace="no-such-thing"> xmlns:xs="http://www.w3.org/2001/XMLSchema"Now JXB should be able to generate the Java source files from Collada schema.
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
<xs:annotation>
<xs:appinfo>
<jaxb:globalbindings>
<xjc:simple>
</xjc:simple></jaxb:globalbindings>
</xs:appinfo>
</xs:annotation></xs:schema>
> xjc.exe -extension simpleMode.xjc -b collada_binding.xjc -p collada collada_schema_1_5.xsdI am not sure what kind of magic this extension file is playing but it works for me for now...