W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2011

Re: Choice between complextContent and complexType

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Thu, 16 Jun 2011 09:10:02 +0530
Message-ID: <BANLkTinTeqArgSYs3m9M_rzd2OkSNkcpXw@mail.gmail.com>
To: Karl Stubsjoen <kstubs@gmail.com>
Cc: xmlschema-dev@w3.org
Hi Karl,
     One way is to use the type alternative construct from XML Schema
1.1. Here's probably something we may be able to do for this use case
(this is untested),

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

     <xs:element name="description" type="xs:anyType">
           <xs:alternative test="@isExt = true()" type="EXT_formInputTypes"/>
	   <xs:alternative type="SEQ_TYPE"/>

    <xs:complexType name="EXT_formInputTypes">
	        <xs:extension base="formInputTypes">
		      <xs:attribute name="isExt" type="xs:boolean" default="1"/>

    <xs:complexType name="SEQ_TYPE">
	        <xs:element name="column" type="COL_TYPE"/>	<!-- COL_TYPE is
undefined. could be xs:string for e.g -->
	   <xs:attribute name="isExt" type="xs:boolean"/>


As per this example, by default the type of "description" is
EXT_formInputTypes. But if we add an attribute isExt = 0 (false) to
"description" in the instance document, the type of "description"
would be SEQ_TYPE.

On Thu, Jun 16, 2011 at 7:07 AM, Karl Stubsjoen <kstubs@gmail.com> wrote:
> I have an element "description", who should either extend the
> complexType "formInputTypes" or contain a sequence of "column"
> elements.  Is this possible?
> --
> Karl Stubsjoen
> MeetScoresOnline.com
> (602) 845-0006

Mukul Gandhi
Received on Thursday, 16 June 2011 03:40:50 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:59 UTC