ray9898
ray9898

Reputation: 101

How to generate element in xsd file as jaxb classes

I need help to figure out how to generate type as class.

This is the xsd file I have.

<xsd:element name="GetPatient" type="c:GetPatientType" />
<xsd:complexType name="GetPatientType">
   <xsd:sequence>
   <xsd:element name="fieldA" type="xsd:string" />
   <xsd:element name="fieldB" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

However, the result is - I got GetPatientType with the fields, but there is no GetPatient class. My goal is to generate GetPatient with all the three fields as its field. So, GetPatient with field A and field B. Is that possible?

Thanks all for your help!

Upvotes: 1

Views: 736

Answers (1)

lexicore
lexicore

Reputation: 43671

See this question:

wrapper class missing when using xjc on xsd

You don't get a class for GetPatient because JAXB handles it via the JAXBElement<GetPatientType> construct.

You can, however, customize GetPatient to generate a class via the <jaxb:class name="GetPatient"/> customization. But still, that class will not have the fields, it will be just a wrapper class.

See also:

How to generate @XmlRootElement Classes for Base Types in XSD?

Upvotes: 1

Related Questions