Re: xsd restriction / facets

"Uriel Nusenbaum" <nusen@arnet.com.ar> writes:

> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

> <xsd:element name="XMLMODIFY">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="CUPID" type="cupid"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> 
> <xsd:simpleType name="cupid">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="[a-z0-9A-Z]*"/>
> </xsd:restriction>
> </xsd:simpleType>
> 
> </xsd:schema>
> 
> when I make the xml, i have 2 ways , one with the CUPID node empty,
> and a second with the CUPID node completed.
> 
> If the node cupid is completed i need to validate that the value
> must be minium of four character and maximum of ten character .

You can either use a union of a cupid restricted to the empty string
and one restricted to max=10, min=4, or, if the semantics seems right
to you, just do the length restriction, make the element nillable and
require xsi:nil when it's empty.

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 Thursday, 14 November 2002 04:38:56 UTC