![]() |
|
|
|||||||
![]() |
XML - Re: XSD Regular Expressions and empty content |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi Chris,
this can be acheived using xs:union to join two (or more) simple types together. Normally a truly empty type is created using an empty complexType but this cannot be used in a union AFAIK The schema snippet below is a union of your date type with an empty string type. <xs:element name="date" type="ESimpleDateType"/> <xs:simpleType name="ESimpleDateType"> <xs:union memberTypes="SimpleDateType empty"/> </xs:simpleType> <xs:simpleType name="SimpleDateType"> <xs:restriction base="xs:integer"> <xs </xs:restriction> </xs:simpleType> <xs:simpleType name="empty"> <xs:restriction base="xs:string"> <xs:maxLength value="0"/> </xs:restriction> </xs:simpleType> This seems to validate <date>12345678</date> and <date></date> and even <date/> (in MSXML 4 and XMLSpy) There may be a better way but I cant think of it for the moment. P.S. why are you using your own date type rather than the built in types? Your type will allow a dates including 20030626 and 26032003 not to mention 20039999 and 99992003 Colin "Chris West" <> wrote in message news:bdh0r9$gnv$... > I want to restrict the content of an elements by declaring them of the > following type: > > <xsd:simpleType name="SimpleDateType"> > <xsd:restriction base="xsd:integer"> > <xsd > </xsd:restriction> > </xsd:simpleType> > > but I also want to allow empty content in xml instances, without using the > "nillable" attribute. Any suggestions? > > Thanks > > Chris > > Colin Mackenzie |
|
|