users@jaxb.java.net

RE: How can I specify length constraints?

From: KARR, DAVID (ATTSI) <"KARR,>
Date: Wed, 2 Mar 2011 10:02:56 -0800

Sigh.

 

From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: Wednesday, March 02, 2011 9:54 AM
To: users_at_jaxb.java.net
Subject: Re: How can I specify length constraints?

 

It says "[@XmlSchemaType] maps a Java type to a simple schema built-in
type", so I'd say: no, it won't work.
-W



On 2 March 2011 17:07, KARR, DAVID (ATTSI) <dk068x_at_att.com> wrote:

> -----Original Message-----
> From: KARR, DAVID (ATTSI)
> Sent: Tuesday, March 01, 2011 3:31 PM
> To: users_at_jaxb.java.net
> Subject: RE: How can I specify length constraints?
>
> > -----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?

After more consideration, I'm not sure I could even get this to work. I
could use a "@XmlSchemaType" annotation to specify a type that's defined
in the auxiliary xsd file, and then use either xslt or the xmltask Ant
library to integrate an xs:import or xs:include into the generated xsd
file.

Could this work?