Open siarheul opened 2 years ago
Running into the same issue, but with types as well.
At first I was using class references which is not supported. But I still can't evade that error you're having, even though I'm now sticking to type
s.
I am seeing this without using class references too- when we are using the annotation on choice rather than on complexType, and two or more elements in the parent type share a type, so like e.g. this worked:
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property/>
</xs:appinfo>
</xs:annotation>
<xs:element name="sProp" type="xs:string"></xs:element>
<xs:element name="fProp" type="xs:float"></xs:element>
<xs:element name="bProp" type="xs:byte"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
but this did not:
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property/>
</xs:appinfo>
</xs:annotation>
<xs:element name="sProp" type="xs:string"></xs:element>
<xs:element name="sTwoProp" type="xs:string"></xs:element> <!-- Adding this line breaks it -->
<xs:element name="fProp" type="xs:float"></xs:element>
<xs:element name="bProp" type="xs:byte"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
However, in that case it seemed like annotating the type element instead of choice did work:
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<simplify:property name="sPropOrSTwoPropOrFProp">
<simplify:as-element-property/>
</simplify:property>
</xs:appinfo>
</xs:annotation>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="sProp" type="xs:string"></xs:element> <!-- We can coexist! -->
<xs:element name="sTwoProp" type="xs:string"></xs:element> <!-- Yay! -->
<xs:element name="fProp" type="xs:float"></xs:element>
<xs:element name="bProp" type="xs:byte"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
According to the documentation one of the xs:element
has to be customized and not the xs:choice
:
https://github.com/highsource/jaxb2-basics/wiki/JAXB2-Simplify-Plugin#as-element-properties
The same to the bindings file:
<jaxb:bindings schemaLocation="<schema>" node="<path-to-comlex-type>/xs:choice/xs:element[1]">
<simplify:as-element-property/>
</jaxb:bindings>
Hi @Ceshion / @imitbn / @AddisonSnyder / @siarheul
@imitbn : I guess you're right, you can only customize an element
in xsd
file.
In addition, jaxb2-basics have moved to jaxb-tools repository (former maven-jaxb2-plugin) and jakarta is on it's way. We also did reimport all wiki pages of this repo (and added some restored from previous highsource's confluence)
If documentation is not clear enough, please let me know so we can fix it there.
Also @Everyone : if you have any problems regarding this plugin usage, feel free also to post a project sample to illustrate.
Regards
Hello!
I try to generate JAXB sources from the XSD schema My JAXB generated sources contain infamous 'fooOrBarOrBaz' looking property. In my case it is 'actualRemoteSectorIndexOrActualLocalSectorIndexOrRemoteMacAddr' property. In order to get rid of it I try to use 'simplify' plugin. Unfortunately, I can't make it work. What is get is an error
This is my XSD:
This is my XJB file:
This is my pom.xml file: