axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Sosnoski <...@sosnoski.com>
Subject Re: Axis Serialization Behavior
Date Wed, 02 Mar 2011 07:48:42 GMT
On 03/02/2011 07:54 PM, Buddhike de Silva wrote:
>
> Thanks Dennis.
>
> We thought about providing a xs:any element for extensibility.
> However, this poses a few other problems as you mentioned below. I
> wonder whether it's possible to do xs:any with maxOccurs="unbounded"
> as a way of providing multiple arbirerary elements without violating
> XML schema.
>

Yes, xs:any with maxOccurs="unbounded" is fine - but the problem is that
it only works for one extended schema, unless your extended schema ends
with a new required element. So you could go from schema1:

  <xs:element name='a' type='xs:string'/> <!-- required element -->
  <xs:any maxOccurs='unbounded'/>

to schema2:

  <xs:element name='a' type='xs:string'/> <!-- required element -->
  <xs:element name='b' type='xs:string' minOccurs='0'/>
  ...
  <xs:element name='c' type='xs:string' /> <!-- required element -->
  <xs:any maxOccurs='unbounded'/>

to schema3:

  <xs:element name='a' type='xs:string'/> <!-- required element -->
  <xs:element name='b' type='xs:string' minOccurs='0'/>
  ...
  <xs:element name='c' type='xs:string' /> <!-- required element -->
  <xs:element name='d' type='xs:string' minOccurs='0'/>
  ...
  <xs:element name='e' type='xs:string' /> <!-- required element -->
  <xs:any maxOccurs='unbounded'/>

all while maintaining compatibility (providing the new required elements
were always present in the server response). But you have to add a new
required element with each update.

Attributes are a much cleaner solution for working with simple values.

> /<quote>/
>
> /"So there's no easy way to get the kind of flexibility you want
> whilestaying compatible with XML schema. JAXB will give you the
> client-sideflexibility, but it does this by basically ignoring the
> schema and onlyprocessing the elements it understands. Clients using
> tools which takethe schema more seriously will fail with your added
> data."/
>
> /</quote>/
>
> Very true. This is why we started investigating whether all mainstream
> stacks have an option to do lax versioning.
>

It's not a good idea to count on users working with stacks which ignore
the schema message description. If you take this approach it will work
ok with WCF or JAXB developers, but you're likely to run into groups
using other tools - and when they point out you're violating your own
schema they'll be correct, which might be hard to explain to your
management.

  - Dennis

Mime
View raw message