Hi I have just started learning about xsd as I want to use it with JAXB.
I was wondering I may have an XML tag that started with the same element but could have completely different child elements every time.
Here is an example1:
<service>Hotel
<request>location
<currentLongitude>100</currentLongitude>
<currentLatitude>100</currentLatitude>
</request>
</service>
example2:
<service>Hotel
<request>Price
<Single>130</Single>
<Double>140</Double>
</request>
</service>
Basically how do I write this in xsd that "request" being asked can have completely different elements
Or if it is applicable is their a better way for me to process this xml then JAXB?
Thanks
The whole point of XSD is to constrain the XML message so that it is easier to process by the applications. I suggest you rethink the approach to have a separate element for each type of request. For e.g.
You can define your
request
element as:This will cause JAXB to generate a field/property that is annotated like:
FULL EXAMPLE
any.xsd
XJC Call
Service
Request