I have xsd:
<xs:complexType name="RobZmenObyvateleDataType">
<xs:annotation>
<xs:documentation xml:lang="cs">Oprava referenčních údajů fyzické osoby v ROB.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="AdresaPobytu" type="rob:AdresaPobytuStavType" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="AdresaPobytuStavType">
<xs:annotation>
<xs:documentation xml:lang="cs">Adresa místa pobytu v ČR včetně stavu a času poslední změny.
</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="AdresaPobytuType">
<xs:attribute name="stav" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="KodAdresniMistoType">
<xs:annotation>
<xs:documentation xml:lang="cs">Identifikátor adresního místa v RUAIN.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:int">
<xs:minExclusive value="-10"/>
<xs:maxExclusive value="999999999"/>
</xs:restriction>
</xs:simpleType>
this generate class:
public class AdresaPobytuStavType
implements Serializable
{
@XmlValue
protected int value;
@XmlAttribute(name = "stav")
protected String stav;
}
You can see value is int and not Integer. So I add binding to cast it to Integer because I need to recognize null value:
<jaxb:bindings schemaLocation="../MyXsd.xsd">
<jaxb:bindings node="//xs:simpleType[@name='KodAdresniMistoType']">
<jaxb:javaType name="java.lang.Integer" />
</jaxb:bindings>
</jaxb:bindings>
so now It look good:
@XmlValue
@XmlJavaTypeAdapter(Adapter2 .class)
protected Integer value;
problem is that is not working.
when I send xml:
<urn2:RobZmenObyvateleData>
<urn3:AdresaPobytu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" stav="spravny"/>
</urn2:RobZmenObyvateleData>
it return 0 instead of null.
<urn2:RobZmenObyvateleData>
<urn3:AdresaPobytu stav="spravny">0</urn3:AdresaPobytu stav="spravny">
</urn2:RobZmenObyvateleData>
and this also return 0
So now how should I recognize 0 and null value ?
PS: I can not edit XSD. It is public and from other side