- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 22 Oct 2001 11:51:24 +0100
- To: "Tim Galle" <timgalle@cyberdude.com>
- Cc: <xmlschema-dev@w3.org>
"Tim Galle" <timgalle@cyberdude.com> writes:
> Hello everyone,
> Is the following possible with XML-schemas:
>
> In Schema A I define a structure (element construction) and 2 kinds of
> attributes: a kind that can not be redefined (Final) and one that can be
> redifined (Overridable)
>
> Now Schema B must take everything from A, structure and attributes. It may
> extend the structure with new elements, and add new attributes to elements
> defined in A. It may redefine overridable attributes from A (Polymorhing),
> but it may not redefine final attributes.
In brief, yes, you can do this.
You have to do it attribute-by-attribute, however:
A:
<xs:schema targetNamespace="urn:foo1" xmlns:my="urn:foo1">
<xs:complexType name="struct1">
<xs:sequence>
...
</xs:sequence>
<xs:attribute name="final1" type="my:ft1"/>
<xs:attribute name="final2" type="my:ft2"/>
<xs:attribute name="final3" type="my:ft3"/>
<xs:attribute name="over1" type="xs:decimal"/>
<xs:attribute name="over2" type="xs:string"/>
</xs:complexType>
<xs:simpleType name="ft1" final="#all">
<xs:restriction base="xs:decimal"/>
</xs:simpleType>
<xs:simpleType name="ft2" final="#all">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="ft3" final="#all">
<xs:restriction base="xs:boolean"/>
</xs:simpleType>
</xs:schema>
<xs:schema targetNamespace="urn:foo2" xmlns:core="urn:foo1"
xmlns:ym="urn:foo2">
<xs:import "urn:foo1"/>
<xs:complexType name="extStruct1">
<xs:complexContent>
<xs:extension base="core:struct1">
<xs:sequence>
. . .
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="xyzzy">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="ym:extStruct1">
<xs:attribute name="over1" type="xs:integer"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
This is OK. If you tried to restrict "final1" instead of "over1",
you'd get an error.
Hope this helps,
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 Monday, 22 October 2001 06:50:38 UTC