[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: W3C Schema Question
Hi Joe, >I have a situation in which I need to anticipate the possibility of 2 different datatypes in a single XML element (I'm thinking xsi:type right now, but I'll continue). I have an element that can either be a date, or an asterisk. The date or asterisk will always appear in the same element - i.e. there are not separate elements for these. So we can have: > ><MyElement>2002-02-02</MyElement> > >in one XML document, and then: > ><MyElement>*</MyElement> > >in another. > >Is there an efficient way to handle this within a single schema, ensuring that invalid dates are detected? > This looks like a perfect scenario where you can use a union type. Something like this would do the trick: <xs:simpleType name="dateAsterisk"> <xs:union memberTypes="xs:date"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="*"/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> Cheers, /Eddie > >Kind Regards, >Joe Chiusano >LMI > > > >>************************************************************************** >> Joseph M. Chiusano >> Logistics Management Institute >> 2000 Corporate Ridge >> McLean, VA 22102 >> Email: jchiusano@l... >> Tel: 571.633.7722 >>************************************************************************** >> >> >> >> > >----------------------------------------------------------------- >The xml-dev list is sponsored by XML.org <http://www.xml.org>, an >initiative of OASIS <http://www.oasis-open.org> > >The list archives are at http://lists.xml.org/archives/xml-dev/ > >To subscribe or unsubscribe from this list use the subscription >manager: <http://lists.xml.org/ob/adm.pl> > > >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|