[xsd-users] Messages and its sub types in the message body

Boris Kolpackov boris at codesynthesis.com
Tue Apr 21 09:32:24 EDT 2020


Shiao, Renfu <Renfu.Shiao at navcanada.ca> writes:

> I have a general message definition which has a header and a body, within
> the body, it could be any one of the sub message types:
> 
> <foo:Message>
> <foo:header></foo:header>
> <foo:body>
> <foo:flight>...</foo:flight>  (Could be a different message type  <foo:weather>...</foo:weather>)
> </foo:body>
> </foo:Message>
> 
> I can access Message.body(), but how can I access the flight or weather
> object within the message body?

You didn't say how this is arranged in your schema (as xs:any,
polymorphism, etc). If it's done with wildcards (xs:any), see the
`wildcard` example for how handle this. If it's via polymorphism,
then see the `polymorphism` example. There is also an ad hoc
approach that can be used with either as shown in the `messaging`
example.



More information about the xsd-users mailing list