- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 18 Dec 2002 16:29:35 +0000
- To: "Hanna" <lhnhanna@hotmail.com> (by way of "C. M. Sperberg-McQueen" <cmsmcq@acm.org>)
- Cc: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>
"Hanna" <lhnhanna@hotmail.com> (by way of "C. M. Sperberg-McQueen" <cmsmcq@acm.org>) writes: > I am new to xml schema. I would like to ask how i can define a data > type which is integer but can allow empty element. > > e.g. <B>6</B> , <B/> are both allowed. > if B contains integer value, then schema validates it. > if B is an empty element, the schema will let it go. One way is as follows: <xs:simpleType> <xs:union memberTypes="xs:integer"> <xs:simpleType> <xs:restriction base="xs:token"> <xs:enumeration value=""/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> ht -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh W3C Fellow 1999--2002, part-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged spam]
Received on Wednesday, 18 December 2002 11:30:13 UTC