users@jaxb.java.net

RE: How can I specify length constraints?

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

It might be interesting to consider some sort of postprocessor for
schemagen that has knowledge of the "javax.validation.constraints"
annotations to dynamically augment elements and types associated with
the fields with those annotations.

 

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

 

But if you consider using XSLT, a relatively simple stylesheet should be
able to replace the type on certain <xs:element> elements with whatever
you specify. Input would be the definition of the replacements and the
XML schema derived by schemagen.
-W

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

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?