Re: SimpleContent question

Jeff Lowery <jlowery@scenicsoft.com> writes:

> The spec states that simpleContent can restrict an existing simple type, but
> within the context of defining a complex type I can't see how it would be
> used. Since a simple type can't have an attribute, and a complex type with
> simple content would be expected to have at least one, how can restricting a
> simple type be of any use in that case? One would just use an anonymous
> simple type and restrict that.

<xs:complexType name="length">
 <xs:simpleContent>
  <xs:extension base="xs:integer">
   <xs:attribute name="units"/>
  </xs:extension>
 </xs:simpleContent>
</xs:complexType>

<xs:complexType name="posLength">
 <xs:simpleContent>
  <xs:restriction base="length">
   <xs:minExclusive value="0"/>
  </xs:restriction>
 </xs:simpleContent>
</xs:complexType>

Does this help?  Both posLength and length allow a 'units' attribute,
but where length allows an integer as content, posLength requires a
positive one.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, 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/

Received on Thursday, 1 March 2001 14:40:26 UTC