You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Boxiong Ding <bo...@yahoo.com> on 2008/05/17 02:51:06 UTC

Control schema output using JAXB binding

I am trying to generate a schema from some Java classes using JAXB. I can do most of the part using schemagen from Java 1.6, but I also want to control the minOccurs/maxOccurs in the schema. Does any one know how to do that?

Boxiong


      

Re: Control schema output using JAXB binding

Posted by Glen Mazza <gl...@verizon.net>.
I don't know how that can be done automatically using JAXB (maybe the
JAXB forum[1] can answer that for you), but I think what you're looking
for is normally done by the schema validation--i.e., you won't even get
your Java object if the XML object is not schema-valid, nor will you be
able to marshal your Java object into XML if the object is not
schema-valid.

[2] shows how schema validation is done with CXF (both client and
provider).

HTH,
Glen

[1] http://forums.java.net/jive/forum.jspa?forumID=46
[2] http://tinyurl.com/6ggvkf

2008-05-16 Boxiong Ding wrote:
> I am trying to generate a schema from some Java classes using JAXB. I can do most of the part using schemagen from Java 1.6, but I also want to control the minOccurs/maxOccurs in the schema. Does any one know how to do that?
> 
> Boxiong
> 
> 
>       


Re: Control schema output using JAXB binding

Posted by Benson Margulies <bi...@gmail.com>.
To amplify, there are a lot of cases in which JAXB cheefully discards
constraints from the schema, never to be seen again.

On Sun, May 18, 2008 at 10:24 PM, Daniel Kulp <dk...@apache.org> wrote:
>
> This is ONE of the "complaints" I have with JAXB.  There isn't a way to do
> this.   The maxOccurs value is completely lost and you can only control
> whether minOccurs is 0 or 1.     This is actually another reason I keep an
> eye on the SXC project.  Eventually, as it gets closer to a full JAXB
> compliant runtime, if it implements the to schema stuff (currently, it
> delegates that to the RI), we may be able to extend it to accept additional
> annotations or similar to provide these missing gaps.
>
> Dan
>
>
>
> On May 16, 2008, at 8:51 PM, Boxiong Ding wrote:
>
>> I am trying to generate a schema from some Java classes using JAXB. I can
>> do most of the part using schemagen from Java 1.6, but I also want to
>> control the minOccurs/maxOccurs in the schema. Does any one know how to do
>> that?
>>
>> Boxiong
>>
>>
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>

Re: Control schema output using JAXB binding

Posted by Daniel Kulp <dk...@apache.org>.
This is ONE of the "complaints" I have with JAXB.  There isn't a way  
to do this.   The maxOccurs value is completely lost and you can only  
control whether minOccurs is 0 or 1.     This is actually another  
reason I keep an eye on the SXC project.  Eventually, as it gets  
closer to a full JAXB compliant runtime, if it implements the to  
schema stuff (currently, it delegates that to the RI), we may be able  
to extend it to accept additional annotations or similar to provide  
these missing gaps.

Dan



On May 16, 2008, at 8:51 PM, Boxiong Ding wrote:

> I am trying to generate a schema from some Java classes using JAXB.  
> I can do most of the part using schemagen from Java 1.6, but I also  
> want to control the minOccurs/maxOccurs in the schema. Does any one  
> know how to do that?
>
> Boxiong
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog