W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2004

Re: xml schema Second Edition-regarding substitution group

From: gayathri veerarajan <gaytri_v@yahoo.co.in>
Date: Tue, 23 Mar 2004 11:23:50 +0000 (GMT)
Message-ID: <20040323112350.26004.qmail@web8202.mail.in.yahoo.com>
To: "Henry S. Thompson" <ht@inf.ed.ac.uk>
Cc: xmlschema-dev@w3.org
    I would like to explain the situation with an example.
   I have a substitutable element  price for the element amount.actually I would like it to work both ways, but  u have mentioned earlier that it is not possible . hence I have a reference to the element amount in "PurchaseOrderType" so that the xml documents can contain the element "amount" or "price" as a substitutable element. 
   In the  complextype "Purchase-Derivant" derived from "PurchaseOrderType" ,i would like to restrict the element amount to type "xsd:positiveInteger". I have explained two situations where it is not possible.
 how can this be achieved?
  <xsd:element name="amount" type="xsd:integer"/>
  <xsd:element name="price" type="xsd:integer"
<xsd:complexType name= "PurchaseOrderType">
      <xsd:element name="shipTo" type="xsd:string" />
      <xsd:element ref="amount" />

<xsd:complexType name="Purchase-Derivant">
     <xsd:restriction base="r:PurchaseOrderType" >
  	 <xsd:element name="shipTo" type="xsd:string"/>
                 <!-- (1)this will work only if amount is local in base type-->
                 <xsd:element name="amount" type="xsd:positiveInteger"/>
                  <!-- (2) type cannot be specified along with ref -->
                 <xsd:element ref="amount" type="xsd:positiveInteger"/>

I also found that declaring element "amount" locally inside the complextype also does not achieve interchangeable of elements.  

"Henry S. Thompson" <ht@inf.ed.ac.uk> wrote:

gayathri veerarajan writes:

> I just read the Xml Schema Second Edition .In the section of
> substitution group it has been said that both the head element and
> the substitutable elements must be declared global.

This is not a change.

> If the substitutable element happens to appear in the content model
> of a complexType definition then while deriving a new complex type
> by restriction,this element could not be restricted (by its type) if
> it is declared globally. hence there should be a possibility to
> declare the substitutable element locally also. any comments
> regarding this.

You can reference a global declaration at any point, so there is no
bar to the kind of derivation you describe.

Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]

Win an evening with the Indian cricket captain: Yahoo! India Promos.
Received on Tuesday, 23 March 2004 06:24:14 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:04 UTC