users@jaxb.java.net

RE: How can I specify length constraints?

From: KARR, DAVID (ATTSI) <"KARR,>
Date: Tue, 1 Mar 2011 15:47:52 -0800

> -----Original Message-----
> From: Benson Margulies [mailto:bimargulies_at_gmail.com]
> Sent: Tuesday, March 01, 2011 3:43 PM
> To: users_at_jaxb.java.net
> Cc: KARR, DAVID (ATTSI)
> Subject: Re: How can I specify length constraints?
>
> David,
>
> JAX-B is not a complete representation of XML Schema. There are many
> schema constructs that do not correspond to any @nnotation. If you run
> xsd-to-java they get dropped, and of course in the other direction
> they never appear.

I understand that it cannot be a one-to-one mapping. The fact that it's not obvious what the semantics of a length restriction annotation would be in Java doesn't mean that it's not important to have that information in an XML schema.

> On Tue, Mar 1, 2011 at 6:30 PM, KARR, DAVID (ATTSI) <dk068x_at_att.com>
> wrote:
> >> -----Original Message-----
> >> From: KARR, DAVID (ATTSI)
> >> Sent: Tuesday, March 01, 2011 3:17 PM
> >> To: users_at_jaxb.java.net
> >> Subject: How can I specify length constraints?
> >>
> >> When I write pure XML Schema, I can define a simple type based on
> >> string
> >> that has length restrictions, being a minimum and maximum length.  I
> >> don't see a way to do that with JAXB annotations.  Assuming I've
> just
> >> missed it, will schemagen respect that annotation in the generated
> >> schema?
> >
> > Is the only reasonable strategy to have a hand-coded "simple types"
> > schema, and to have your JAXB classes reference those types?
> >