W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2002

Re: integer and empty element

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>
Message-ID: <f5bd6nz9tow.fsf@erasmus.inf.ed.ac.uk>

"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:union memberTypes="xs:integer">
   <xs:restriction base="xs:token">
    <xs:enumeration value=""/>

  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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:50:00 UTC