OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML Schemas: Best Practices



> >   What if we wanted to extend
> >     <Book> by adding elements to the beginning (before <Title>), or in
> >     the middle, etc?  We can't do it with this mechanism.
>
> Whats wrong with
>
>     <complexType name="BookTypePlusReviewer">
>        <complexContent>
>             <extension base="c:BookType" >
>                 <sequence>
>                     <element name="Reviewer" type="string"/>
>                     <element name="Title" type="string"/>
>                     <element name="Author" type="string"/>
>                    <element name="Date" type="year"/>
>                    <element name="ISBN" type="string"/>
>                  <element name="Publisher" type="string"/>
>               </sequence>
>            </extension>
>        </complexContent>
>    </complexType>
>
> It still conforms to the type definition and adds the required new element.
> As far as I am aware there is no restriction on you redefining the existing
> elements if you need to reorder the elements. (This is the way restrictions
> work.)

I may be on thin ice here but I don't think this is correct. If you use
derivation using the above syntax you're not reordering the elements. Instead
you are extending the type to allow for all the elements in the base type
(Title, Author, Date, ISBN, Publisher) plus all the above elements in the new
group (Reviewer, Title, Author, Date, ISBN, Publisher). This means that a valid
instance document using the above type (BookTypePlusReviewer) would have to be:

<Book>
      <Title>The First and Last Freedom</Title>
      <Author>J. Krishnamurti</Author>
      <Date>1954</Date>
      <ISBN>0-06-064831-7</ISBN>
      <Publisher>Harper &amp; Row</Publisher>
      <Reviewer>Alan Rickman</Reviewer>
      <Title>The First and Last Freedom</Title>
      <Author>J. Krishnamurti</Author>
      <Date>1954</Date>
      <ISBN>0-06-064831-7</ISBN>
      <Publisher>Harper &amp; Row</Publisher>
</Book>

I don't think this is was Roger intended to achive. Is this correct?

Regards,
/Eddie