0

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>
Xstian
  • 8,184
  • 10
  • 42
  • 72
  • I suggest you to extract an `XSD` from your `XML` and generate the classes using it by `maven-jaxb2-plugin`. – Xstian Dec 10 '15 at 10:36

1 Answers1

0

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.

Community
  • 1
  • 1
kirsty
  • 267
  • 1
  • 2
  • 14