简体   繁体   中英

How to Creating Nested xml in Jaxb. I need to create xml as below

I need to create xml as below using jaxb. I know how to create simle xml.But I have no idea regarding this nested xml.Please help me out with this. Thank you all

<whens>
    <when>
        <whenEntity1_Rule1>
            <whenAttribute1_Rule1>
                <whenCondition1_Rule1/>
                <whenValue1_Rule1>
                    <literalvalue1_Rule1/>
                    <whenEntity1_expression1_Rule1/>
                    <whenAttribute1_expression1_Rule1/>
                </whenValue1_Rule1>
            </whenAttribute1_Rule1>
            <whenAttribute2_Rule1>
                <whenCondition2_Rule1/>
                <whenValue2_Rule1>
                    <literalvalue2_Rule1/>
                    <whenEntity2_expression1_Rule1/>
                    <whenAttribute2_expression1_Rule1/>
                </whenValue2_Rule1>
            </whenAttribute2_Rule1>
            <whenAttribute3_Rule1>
                <whenCondition3_Rule1/>
                <whenValue3_Rule1>
                    <literalvalue3_Rule1/>
                    <whenEntity3_expression1_Rule1/>
                    <whenAttribute3_expression1_Rule1/>
                </whenValue3_Rule1>
            </whenAttribute3_Rule1>
        </whenEntity1_Rule1>
    </when> 
<whens>

You can use an XSD generator to extract the schema that describes the structure you've mentioned above.

You will then be add to add this schema to a JAXB marshaller or unmarshaller to generate JAXB objects and XML that is valid against the above structure. You can see how to do this in the answer to this question.

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