- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 16 Dec 2000 10:26:31 +0000
- To: "Roger L. Costello" <costello@mitre.org>
- Cc: xmlschema-dev@w3.org
"Roger L. Costello" <costello@mitre.org> writes: > If I have an element that is in a substitutionGroup with a head element, > and it has a type that is derived from the head element's type, then in > an instance document do I need to specify its type using xsi:type? > > Example. > > <complexType name="PublicationType"> > <sequence> > <element name="Title" type="string"/> > <element name="Author" type="string" /> > <element name="Date" type="year"/> > </sequence> > </complexType> > <complexType name="BookType"> > <complexContent> > <extension base="cat:PublicationType" > > <sequence> > <element name="ISBN" type="string"/> > <element name="Publisher" type="string"/> > </sequence> > </extension> > </complexContent> > </complexType> > <element name="Publication" type="a:PublicationType"/> > <element name="Book" substitutionGroup="a:Publication" > type="a:BookType"/> > <element name="Review"> > <complexType> > <sequence> > <element ref="a:Publication""/> > </sequence> > </complexType> > </element> > > Here is an instance document, which uses the Publication element within > <Review>: > > <Review> > <Publication> > <Title>Antiaging Strategies</Title> > <Author>Dr. Herman Fleishman</Author> > <Date>12-04-00</Date> > </Publication> > </Review> > > Here is an alternate instance document, where the Publication element > has been substituted by the Book element: > > <Review> > <Book xsi:type="a:BookType"> > <Title>Illusions</Title> > <Author>Richard Bach</Author> > <Date>05-10-72</Date> > <ISBN>94303-12021-43892</ISBN> > <Publisher>McMillin Publishing</Publisher> > </Book> > </Review> No, it is not necessary. Why should it be? Book has a perfectly good element declaration in the schema telling us its type, the instance doesn't need to do it again. 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 Saturday, 16 December 2000 05:26:34 UTC