W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2000

Substituting by an element with a derived type

From: Roger L. Costello <costello@mitre.org>
Date: Fri, 15 Dec 2000 13:59:34 -0500
Message-ID: <3A3A6A16.23826A83@mitre.org>
To: xmlschema-dev@w3.org, costello@mitre.org
Hi Folks,

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?


    <complexType name="PublicationType">
            <element name="Title" type="string"/>
            <element name="Author" type="string" />
            <element name="Date" type="year"/>
    <complexType name="BookType">
            <extension base="cat:PublicationType" >
                    <element name="ISBN" type="string"/>
                    <element name="Publisher" type="string"/>
    <element name="Publication" type="a:PublicationType"/>
    <element name="Book" substitutionGroup="a:Publication"
    <element name="Review">
                <element ref="a:Publication""/>

Here is an instance document, which uses the Publication element within

            <Title>Antiaging Strategies</Title>
            <Author>Dr. Herman Fleishman</Author>

Here is an alternate instance document, where the Publication element
has been substituted by the Book element:

        <Book xsi:type="a:BookType">
            <Author>Richard Bach</Author>
            <Publisher>McMillin Publishing</Publisher>

Is it necessary to use xsi:type on the Book element?  I believe that it
is necessary, but just want to be sure.  /Roger
Received on Friday, 15 December 2000 13:59:13 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:48 UTC