You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XSD schema's support a way to name an element based on its runtime type through substitution groups. I'm trying to deserialise such a substitution group. Is this supported in some way?
Example. Suppose there is two types of Animals: Cows and Goats. Based on their type, I want their element to be named either cow or goat. This would be modelled as follows:
XSD:
<!-- XML root element -->
<xs:elementname="document">
<xs:complexType>
<xs:sequence>
<xs:elementref="animal"/> <!-- Note that the name of this element is determined by the actual type of animal -->
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Element names: `Cow`s should be serialised as an element named `cow`, `Goat`s should be serialised as an element named `goat`. -->
<xs:elementname="animal"type="Animal"abstract="true" />
<xs:elementname="cow"type="Cow"substitutionGroup="animal" />
<xs:elementname="goat"type="Goat"substitutionGroup="animal" />
<!-- Types: `Cow` and `Goat` extend from `Animal` -->
<xs:complexTypename="Animal">
<xs:attributename="name"type="xs:string" />
</xs:complexType>
<xs:complexTypename="Cow">
<xs:complexContent>
<xs:extensionbase="Animal" />
</xs:complexContent>
</xs:complexType>
<xs:complexTypename="Goat">
<xs:complexContent>
<xs:extensionbase="Animal" />
</xs:complexContent>
</xs:complexType>
This is a known "most wanted feature", not specific to XML Schema (as in, supported by JAXB and other xml tools). Unfortunately such "flattening" (of nested elements) is not really supported by Jackson XML module.
It would be great to support it, but problem is that requires kind of structural transformation that is currently difficult to achieve due to the way Type[De]Serializers and regular Json[De]Serializers interact.
XSD schema's support a way to name an element based on its runtime type through substitution groups. I'm trying to deserialise such a substitution group. Is this supported in some way?
Example. Suppose there is two types of
Animal
s:Cow
s andGoat
s. Based on their type, I want their element to be named eithercow
orgoat
. This would be modelled as follows:XSD:
XML example instances:
Java model:
Is there a way of annotating the classes to get the desired behaviour?
The text was updated successfully, but these errors were encountered: