axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Williams <ch...@manawiz.com>
Subject Re: [Axis2-0.94] WSDL2Java generates bad code for <choice> complex types
Date Wed, 25 Jan 2006 07:01:50 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Jeff,<br>
<br>
I guess I shoudln't be too surprised that you are on this list, but you
did catch me off guard!&nbsp; Hope you are well.<br>
<br>
You are right of course, but it turns out the patch actually does what
you say, more or less, due to the way Axis2 works (at least as the code
appears to me).&nbsp; It treats &lt;sequence&gt; and &lt;all&gt; in the
same
manner except that &lt;sequence&gt; requires and ensures the specified
ordering.&nbsp; I haven't tried the nested cases; it either doesn't work for
&lt;sequence&gt; or is too liberal for &lt;all&gt;, or some of both (my
guess).&nbsp; All 3 particles are processed by the same method, with the
only difference being whether the ordering is enforced (sequence) or
whether only one value is accepted (choice).<br>
<br>
Thanks for pointing out the constraints on &lt;all&gt;,<br>
<br>
Chuck<br>
<br>
<span>
<div
 style="font-size: smaller; font-style: italic; margin-bottom: -2.4em;"><br>
<span>Jeff Greif <a class="moz-txt-link-rfc2396E" href="mailto:jgreif@alumni.princeton.edu">&lt;jgreif@alumni.princeton.edu&gt;</a></span>
wrote on <span>01/24/2006
08:44:33 PM</span>:<br>
</div>
</span><br>
<blockquote
 cite="mid152f93f50601242244la6e08bx3ef3c6fe8e12f950@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi Chuck,

Just as a point of information, &lt;all&gt; itself can only have maxOccurs=1
and minOccurs=(0,1}, each of its particles has the same restriction,
and all the particles must be &lt;element&gt;.  No nested sequence, choice
or all is allowed.  The main reason for the restrictions, I think, is
that XML Schema requires deterministic parsing with no lookahead.

While I'm not familiiar with the code you patched, it might have
captured more of the semantics of choice to base the patch on the
treatment of &lt;sequence&gt; rather than &lt;all&gt;, initially applying
a
similar trick to the one you described, and eventually properly
rejecting cases where more than one branch appeared.  The same degree
of code reuse may be possible in that approach.

Jeff

On 1/24/06, Chuck Williams <a class="moz-txt-link-rfc2396E" href="mailto:chuck@manawiz.com">&lt;chuck@manawiz.com&gt;</a>
wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap=""> Dims and Ajith,

 I took Dims' advice and created the attached patch to modules/codegen/src
of Axis2 0.94.  This may not be the best implementation of &lt;choice&gt; but it
is very simple and meets my use cases.  The idea is this.  A &lt;choice&gt; is
treated just like an &lt;all&gt; where each enclosed element has minOccurs=0,
except that in the generated code setting any constituent element
automatically unsets all the others.  Thus, whatever choice you set last is
the choice you get and you only get one.  (The code does not enforce what
happens if you don't set any; this, additional error checking, and accessors
to fully determine the state of what has been chosen, could all be
improved.)

 I'm just starting to work with it so have not tested it much yet, but the
generated code looks right to me.  It's very simple because it reuses all
the code that is already there and makes just a few mods.

 I haven't tried complex nesting cases to see if they all work, and probably
wont' because I only need &lt;choice&gt; of &lt;element&gt;'s, although in
principle any
nesting that &lt;all&gt; handles, choice should too.

 I noticed in doing this that none of the particles handle the &lt;element
ref=...&gt; construction.  This is somewhat painful, but livable.  If I had
more time, I'd try to fix that.  It looks like it might be more complex than
this hack due to the way the names are used in the data structures.

    </pre>
  </blockquote>
</blockquote>
<br>
</body>
</html>

Mime
View raw message