W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2008

RE: Include multiple complex types into one element ...

From: Michael Kay <mike@saxonica.com>
Date: Tue, 8 Jul 2008 19:55:51 +0100
To: "'Dragon Fly'" <dragon-fly999@hotmail.com>, <xmlschema-dev@w3.org>
Message-ID: <FBD1FBCBFE914A0AA0A83DFDD9622940@Sealion>
You can do this if you define the two content models not as named complex
types but as named model groups (xs:group name="x"). A named model group can
be incorporated by reference into any number of complex types.
Michael Kay


From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Dragon Fly
Sent: 07 July 2008 18:16
To: xmlschema-dev@w3.org
Subject: Include multiple complex types into one element ...


I'm new to XSD and was wondering if I could include multiple complex types
into one element.  For example, I have two complex types NameType and


  <xs:complexType name="NameType">
      <xs:element name="FirstName" type="xs:string" />
      <xs:element name="LastName" type="xs:string" />

  <xs:complexType name="AddressType">
      <xs:element name="Country" type="xs:string" />
      <xs:element name="Zip" type="xs:string" />


I would like to create a root element that includes both the NameType and
AddressType.  I was able to include them if I create "sub-elements" (i.e.
SubA and SubB below).  However, I just want the elements in NameType and
AddressType to be directly under RootInformation (without any sub-elements).
Can that be done? Thank you in advance for your help.

  <xs:element name="RootInformation">
        <xs:element name="SubA" type="tns:NameType" />
        <xs:element name="SubB" type="tns:AddressType" />


It's a talkathon - but it's not just talk. Check out the i
<http://www.imtalkathon.com/?source=EML_WLH_Talkathon_JustTalk> 'm
Received on Tuesday, 8 July 2008 18:56:31 UTC

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