I want to bind the incoming XML to a JavaType
<?xml version="1.0" encoding="UTF-8"?>
<apiKeys uri="http://api-keys">
<apiKey uri="http://api-keys/1933"/>
<apiKey uri="http://api-keys/19334"/>
</apiKeys>
I wish to use JAXB, so I have defined an XSD. My XSD is incorrect, and the created objects – whilst being created – are empty.
My XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="apiKeys" type="ApiKeysResponseInfo2" />
<xsd:complexType name="ApiKeysResponseInfo2">
<xsd:sequence>
<xsd:element name="uri" type="xsd:anyURI" minOccurs="1" maxOccurs="1">
</xsd:element>
<xsd:element name="apiKey" type="xsd:anyURI" minOccurs="1" maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Obviously my element definitions are wrong. Any help much appreciated. Thanks.
JAXB does not require an XML schema. We designed it to start from Java objects, the ability to generate an annotated model from an XML schema was added as a convenience mechanism.
You could use the object model below:
ApiKeys
ApiKey
Demo