How to parse anyType tag into respective java class object using JAXB

Viewed 60

How would I parse below 2 xmls using JAXB when the XSD defines the body tag of type anyType, and can have either type Cust or Acc depending on the namespace prefix how can they be parsed to respective Class types.

body tag have Cust type in the below example

<Doc:request xmlns:Doc="xyz.com/root" xmlns:Cust="xyz.com/cust" xmlns:Acc="xyz.com/acc">
<Doc:header>
    <Doc:to>maxi@fic.com</Doc:to>
    <Doc:from>maxi@fic2.com</Doc:from>
</Doc:header>
<Doc:body>
    <Cust:cust_details>
        <Cust:name>pnndnd</Cust:name>
        <Cust:address>pnndnd</Cust:address>
    </Cust:cust_details>
</Doc:body>
</Doc:request>

body tag have Acc type in the below example

<Doc:request xmlns:Doc="xyz.com/root" xmlns:Cust="xyz.com/cust" xmlns:Acc="xyz.com/acc">
<Doc:header>
    <Doc:to>maxi@fic.com</Doc:to>
    <Doc:from>maxi@fic2.com</Doc:from>
</Doc:header>
<Doc:body>
    <Acc:acc_details>
        <Acc:number>988788y</Acc:number>
        <Acc:type>DRS</Acc:type>
    </Acc:acc_details>
</Doc:body>
</Doc:request>
0 Answers
Related