- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 14 Feb 2002 11:35:11 +0000
- To: Jeni Tennison <jeni@jenitennison.com>
- Cc: Maikel Jansen <maikel.jansen@asml.com>, xmlschema-dev@w3.org
Jeni Tennison <jeni@jenitennison.com> writes:
> > Consider the following complex type definition:
> >
> > <xs:complexType name="type0">
> > <xs:simpleContent>
> > <xs:extension base="int"/>
> > </xs:simpleContent>
> > <xs:attribute name="description" fixed="a description"/>
> > </xs:complexType>
>
> That isn't a legal complex type definition. The xs:attribute should be
> within the xs:extension element, giving:
>
> <xs:complexType name="type0">
> <xs:simpleContent>
> <xs:extension base="int">
> <xs:attribute name="description" fixed="a description" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> > Now, I want to express a type called type1 in an XML schema, such
> > that type1 is an inheritance type of type0 and type1 overrides the
> > (fixed) value of the attribute 'desc' of type0.
>
> You cannot derive this type by restriction, as you cannot change the
> fixed value constraint of the attribute if you derive by restriction.
> I *think* that you can derive it by extension (I don't see anything
> banning it in the Rec), as follows:
>
> <xs:complexType name="type1">
> <xs:simpleContent>
> <xs:extension base="type0">
> <xs:attribute name="description" fixed="another description" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
That's broken -- it produces a type with two attributes called "description".
> But I think that you would get a cleaner hierarchy if you had a
> general type with the (unfixed) description attribute:
>
> <xs:complexType name="type">
> <xs:simpleContent>
> <xs:extension base="int">
> <xs:attribute name="description" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> And then derive the type0 and type1 from that type by restriction:
>
> <xs:complexType name="type0">
> <xs:simpleContent>
> <xs:restriction base="type">
> <xs:attribute name="description" fixed="a description" />
> </xs:restriction>
> </xs:simpleContent>
> </xs:complexType>
>
> <xs:complexType name="type1">
> <xs:simpleContent>
> <xs:restriction base="type">
> <xs:attribute name="description" fixed="another description" />
> </xs:restriction>
> </xs:simpleContent>
> </xs:complexType>
That looks good to me.
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, 14 February 2002 06:37:19 UTC