简体   繁体   中英

How to Convert Complex Type in to java.lang.string during class generation from schema(.xsd) using JAXB

I have an schema where a complex element 'LOBCd' is defined of Complex Type 'PC_LINE_OF_BUSINESS'.

Schema :

<xsd:element name="LOBCd" type="PC_LINE_OF_BUSINESS"/>
<xsd:complexType name="PC_LINE_OF_BUSINESS">
    <xsd:simpleContent>
        <xsd:extension base="xsd:string">
        <xsd:attribute name="type" type="xsd:string"/>
        </xsd:extension>
    </xsd:simpleContent>
</xsd:complexType>

Now I want this LOB_Cd in form of string in java model class after model generation using JAXB. But currently there is a java file 'PCLINEOFBUSINESS' is getting generated and 'ClaimsPartyInfo' where lobCd type is 'PCLINEOFBUSINESS'.

I required 'lobCd' in java.lang.String in the generated 'ClaimsPartyInfo' file.

Java:

public class ClaimsPartyInfo {
@XmlElement(name = "LOBCd", required = true)
protected PCLINEOFBUSINESS lobCd;

Please help.

Your " PC_LINE_OF_BUSINESS " is of complex type so JAXB will create a class for it and whatever your root node for this that, this Class " PC_LINE_OF_BUSINESS " will be referenced there.

You can try modifying your XSD if you are designing it.

Or otherwise you have to modify the Classes manually after identifying it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM