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


Help: OASIS Mailing Lists Help | MarkMail Help



   xml schema question: subst group example in Primer?

[ Lists Home | Date Index | Thread Index ]
  • To: XML Developers List <xml-dev@lists.xml.org>
  • Subject: xml schema question: subst group example in Primer?
  • From: Burak Emir <Burak.Emir@epfl.ch>
  • Date: Thu, 02 Dec 2004 14:28:22 +0100
  • Organization: EPFL
  • User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

Hello, xml-dev,

I try it here because I have not received an answer on xmlschema-dev.

Could someone give me an answer on this please?

I always thought there was nothing difficult substitution, but stumbling
again over this example in the primer confused me.

The instances <items>...</items> with the *two* comments will surely
never validate?? Because its *two* comments, not one?

Isnt the default maxOccurs="1"? Does the example try to say "you can use
either one of these" ?

Thanks in advance,

Hello all,

The XML Schema Part 0, Section 4.6 "Substitution groups" reads

Declaring Elements Substitutable for comment

<element name="shipComment" type="string"
<element name="customerComment" type="string"

When these declarations are added to the international purchase order
schema, |shipComment| and |customerComment| can be substituted for
|comment| in the instance document, for example:

Snippet of ipo.xml <http://www.w3.org/TR/xmlschema-0/#ipo.xml> with
Substituted Elements

  <item partNum="833-AA">
    <productName>Lapis necklace</productName>
      Use gold wrap if possible
      Want this for the holidays!


But if you check ipo.xsd elsewhere, you find:

<complexType name="Items">
      <element name="item" minOccurs="0" maxOccurs="unbounded">
            <element name="productName" type="string"/>
            <element name="quantity">
                <restriction base="positiveInteger">
                  <maxExclusive value="100"/>
            <element name="USPrice"    type="decimal"/>
            <element ref="ipo:comment" minOccurs="0"/> <!-- HERE -->
            <element name="shipDate"   type="date" minOccurs="0"/>
          <attribute name="partNum" type="ipo:SKU" use="required"/>

Why would it be allowed to include a customerComment AND a shipComment
?!? My thinking goes, there should be up to one.
Have I overlooked something?


Burak Emir



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS