[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xml schema question: subst group example in Primer?

  • To: XML Developers List <xml-dev@l...>
  • Subject: xml schema question: subst group example in Primer?
  • From: Burak Emir <Burak.Emir@e...>
  • Date: Thu, 02 Dec 2004 14:28:22 +0100
  • Organization: EPFL
  • User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

xml schema group example
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,
Burak

=======
Hello all,

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

Example
Declaring Elements Substitutable for comment

<element name="shipComment" type="string"
         substitutionGroup="ipo:comment"/>
<element name="customerComment" type="string"
         substitutionGroup="ipo:comment"/>

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:

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

....
<items>
  <item partNum="833-AA">
    <productName>Lapis necklace</productName>
    <quantity>1</quantity>
    <USPrice>99.95</USPrice>
    <ipo:shipComment>
      Use gold wrap if possible
    </ipo:shipComment>
    <ipo:customerComment>
      Want this for the holidays!
    </ipo:customerComment>
    <shipDate>1999-12-05</shipDate>
  </item>
</items>
....

=====

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

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

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?

Thanks,

Burak Emir

http://lamp.epfl.ch/~buraq




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.