You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@basistech.com> on 2007/10/22 14:58:04 UTC

arrays of nil versus nil array

Dan,

 

XML schema-wise, say that we started, code-first, with

 

   String bleep[];

 

So, bleep could be null, and then each of the strings inside bleep could
be nil.

 

If the nillable attribute for the schema element for bleep refers to the
entire array, where's the one for the array elements? Does there need to
be a complex type in this case?

 

I guess I better haul out my XML Schema book.

 

--benson

 


RE: arrays of nil versus nil array

Posted by Benson Margulies <bi...@basistech.com>.
For the javascript generator, the question is what I do when I see a
sequence element with arrayNature (maxOccurs > 1) that also says
nillable. The javascript element could be nil, or it could be an array
with elements that are nil.

As I now look at it, if I spit out 

<elementItem xsi:nil='true'/>

That's going to read in as 'an array of a single null', not as 'a null
array', so I have to assume that anyone who wanted a single top-level
nil to mean 'no array' will have done like Aegis and added an extra
level of complex type. So, if the javascript variable for the array is
absolutely nil, I'll just emit nothing at all.


> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Monday, October 22, 2007 10:35 AM
> To: cxf-dev@incubator.apache.org
> Cc: Benson Margulies
> Subject: Re: arrays of nil versus nil array
> 
> 
> Benson,
> 
> This depends on if you are using Aegis or JAXB (and is one area where
> Aegis has the advantage).     JAXB maps this to:
> 
> <element type="string" maxOccurs="unbounded" minOccurs="1"
> nillable="true" name="bleep"/>
> 
> In that case, the nillable does NOT apply to the entire array.   Just
the
> elements in the array.   (the nillable applies for each "bleep"
element
> written out.) With the jaxb mapping, there is no way to distinguish
> between:
> 
> bleep = null;
> and
> bleep = new String[0];
> 
> Both cases would result in no "bleep" elements being written on the
wire.
> I think CXF maps both to "null" on the receiving side of the wire.
> 
> 
> bleep = new String[] {null};
> would result in a single bleep element with nil="true" set.
> 
> 
> Aegis, on the other hand, maps it to:
> <element type="ArrayOfString" nillable="true" name="bleep"/>
> which does allow the distinction as the array itself is represented by
> the bleep element, and the array items are represented by the element
> inside of the ArrayOfString type.
> 
> 
> Dan
> 
> 
> 
> On Monday 22 October 2007, Benson Margulies wrote:
> > XML schema-wise, say that we started, code-first, with
> >    String bleep[];
> > So, bleep could be null, and then each of the strings inside bleep
> > could be nil.
> >
> > If the nillable attribute for the schema element for bleep refers to
> > the entire array, where's the one for the array elements? Does there
> > need to be a complex type in this case?
> >
> > I guess I better haul out my XML Schema book.
> > --benson
> 
> 
> 
> --
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog

Re: arrays of nil versus nil array

Posted by Daniel Kulp <dk...@apache.org>.
Benson,

This depends on if you are using Aegis or JAXB (and is one area where 
Aegis has the advantage).     JAXB maps this to:

<element type="string" maxOccurs="unbounded" minOccurs="1" 
nillable="true" name="bleep"/>

In that case, the nillable does NOT apply to the entire array.   Just the 
elements in the array.   (the nillable applies for each "bleep" element 
written out.) With the jaxb mapping, there is no way to distinguish 
between:

bleep = null;
and 
bleep = new String[0];

Both cases would result in no "bleep" elements being written on the wire.  
I think CXF maps both to "null" on the receiving side of the wire.


bleep = new String[] {null};
would result in a single bleep element with nil="true" set.


Aegis, on the other hand, maps it to:
<element type="ArrayOfString" nillable="true" name="bleep"/>
which does allow the distinction as the array itself is represented by 
the bleep element, and the array items are represented by the element 
inside of the ArrayOfString type.


Dan



On Monday 22 October 2007, Benson Margulies wrote:
> XML schema-wise, say that we started, code-first, with
>    String bleep[];
> So, bleep could be null, and then each of the strings inside bleep
> could be nil.
>
> If the nillable attribute for the schema element for bleep refers to
> the entire array, where's the one for the array elements? Does there
> need to be a complex type in this case?
>
> I guess I better haul out my XML Schema book.
> --benson



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog