On Tuesday 01 March 2011 7:27:16 PM Jason Chaffee wrote: > The question is how to do these things with annotations. That is why > you were given xsd examples because we know how to do them in the XSD. > But in a code-first approach, you would want to specify these in the > annotations and then generate the schema from it. That is the question, > how to do that.
I really don't think you can. JAXB doesn't really have anything for those types of things. I also looked at the EclipseLink Moxy custom annotations and didn't see anything there either. :-( Dan > > Jason > > -----Original Message----- > From: KARR, DAVID (ATTSI) [mailto:[email protected]] > Sent: Tuesday, March 01, 2011 4:19 PM > To: [email protected] > Subject: RE: JAXB: Any way to incorporate restrictions into annotations? > > > -----Original Message----- > > From: Jason Chaffee [mailto:[email protected]] > > Sent: Tuesday, March 01, 2011 4:04 PM > > To: [email protected] > > Subject: RE: JAXB: Any way to incorporate restrictions into > > annotations? > > > > I can give an example, > > > > How do I do either of these with annotations: > > <!-- Custom restriction for name --> > > <xs:simpleType name="name"> > > > > <xs:restriction base="xs:string"> > > > > <xs:pattern value="[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*" /> > > > > </xs:restriction> > > > > </xs:simpleType> > > > > OR a key > > > > <!-- Custom key for address name in user --> > > <xs:element name="user" type="user"> > > > > <xs:key name="nameKey"> > > > > <xs:selector xpath="addresses/address" /> > > <xs:field xpath="name" /> > > > > </xs:key> > > > > </xs:element> > > Yeah. I didn't mean elaborate on the schema, I meant on the > annotations. However, I think I've figured that out in the meantime, at > least for type references. I believe you would use > '@XmlSchemaType(name="nameKey")", for example, correct? > > I have no idea how you could deal with "xs:key" references. > > > -----Original Message----- > > From: KARR, DAVID (ATTSI) [mailto:[email protected]] > > Sent: Tuesday, March 01, 2011 3:49 PM > > To: [email protected] > > Subject: RE: JAXB: Any way to incorporate restrictions into > > annotations? > > > > > -----Original Message----- > > > From: jbradfor [mailto:[email protected]] > > > Sent: Tuesday, March 01, 2011 3:46 PM > > > To: [email protected] > > > Subject: Re: JAXB: Any way to incorporate restrictions into > > > annotations? > > > > > > We use SimpleTypes, range restrictions (which will not gen but will > > > validate, > > > if requested), and Enums for name/value pairs. > > > > Could you please elaborate, for instance range restrictions? -- Daniel Kulp [email protected] http://dankulp.com/blog Talend - http://www.talend.com
