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

multiple choice element that implement thesame base class #79

Open
bolemeus opened this issue Feb 17, 2017 · 1 comment
Open

multiple choice element that implement thesame base class #79

bolemeus opened this issue Feb 17, 2017 · 1 comment

Comments

@bolemeus
Copy link

I have a question.

I've got the following xsd element

<xsd:complexType name="Types">
    <xsd:sequence>
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="TypeA" type="TypeA"/>
            <xsd:element name="TypeB" type="TypeB"/>
            <xsd:element name="TypeC" type="TypeC"/>
        </xsd:choice>
    </xsd:sequence>
</xsd:complexType>

and in my bindings file

<jaxb:bindings schemaLocation="types/typeA-v2.xsd" node="/xsd:schema">
	...
	<jaxb:bindings node="xsd:complexType[@name='TypeA']">
		<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
	</jaxb:bindings>
</jaxb:bindings>

<jaxb:bindings schemaLocation="types/typeB-v1.xsd" node="/xsd:schema">
	...
	<jaxb:bindings node="xsd:complexType[@name='TypeB']">
		<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
	</jaxb:bindings>
</jaxb:bindings>

<jaxb:bindings schemaLocation="types/typeC-v1.xsd" node="/xsd:schema">
	...
	<jaxb:bindings node="xsd:complexType[@name='TypeC']">
		<inheritance:extends>nl.jaxb2-basics.example.dto.AbstractType</inheritance:extends>
	</jaxb:bindings>
</jaxb:bindings>

The generated code now creates a List of Serializables, which is not really what I want. The Simplify plugin looks promising, but would give me three seperate lists.

Is there a way for me to make it a generated list of AbstractTypes using the inheritance plugin.

PS: I simplified the code a bit.

@manstis
Copy link

manstis commented May 26, 2021

This type of construct works for me

<jaxb:bindings node="x-path-to-where-Types-is-used">
  <jaxb:property>
    <jaxb:baseType name="nl.jaxb2-basics.example.dto.AbstractType"/>
  </jaxb:property>
</jaxb:bindings>

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