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

Re: complexType names

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Fri, 01 Dec 2000 11:33:01 +0100
Message-ID: <3A277E5D.C40FAF9D@dyomedea.com>
To: xmlschema-dev@w3.org

Daniel Acton wrote:
> The two instances will have the same elements, but with a different root
> element. Do I have to write two seperate schemas for this? The examples
> I've been looking at have this kind of definition of the root element:

You have many ways to do it, the only common point being that you'll
have to use a xsd:choice at some point...

One of them is to define a complexType that will be used to define both
dogs and cats:

<xsd:complexType name="animal">
    <xsd:element name="height" .../>
    <xsd:element name="weight" .../>

and to use a xsd:choice in the definition of your root element:

<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  <xsd:element type="someComplexType" name="xmlRootElement"/>
  <xsd:complexType name="someComplexType">
    <xsd:choice minOccurs="..." maxOccurs="...">
	<xsd:element name="Dog" type="animal" .../>
	<xsd:element name="Cat" type="animal" .../>
  <!-- Rest of schema definition here -->

You'll find another example of xsd:choice in the tutorial that we've
recently published on XML.com

Hope this helps.

See you at XML 2000
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
Received on Friday, 1 December 2000 05:30:12 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:50 UTC