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

Re: Choice between complextContent and complexType

From: Karl Stubsjoen <kstubs@gmail.com>
Date: Wed, 15 Jun 2011 21:18:11 -0700
Message-ID: <BANLkTi=g_R0NQHKWUbCzDn3naX22N-1TpA@mail.gmail.com>
To: Mukul Gandhi <gandhi.mukul@gmail.com>
Cc: xmlschema-dev@w3.org
Hi Mukul,
I'm trying to stick with 1.0 standards.  If there is not a 1.0
solution than I think I must define a new child element of
description.  This is what I am doing now.
Thanks,
Karl..

On Wed, Jun 15, 2011 at 8:40 PM, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
> 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:element>
>
>    <xs:complexType name="EXT_formInputTypes">
>          <xs:complexContent>
>                <xs:extension base="formInputTypes">
>                      <xs:attribute name="isExt" type="xs:boolean" default="1"/>
>                </xs:extension>
>          </xs:complexContent>
>    </xs:complexType>
>
>    <xs:complexType name="SEQ_TYPE">
>           <xs:sequence>
>                <xs:element name="column" type="COL_TYPE"/>     <!-- COL_TYPE is
> undefined. could be xs:string for e.g -->
>           </xs:sequence>
>           <xs:attribute name="isExt" type="xs:boolean"/>
>    </xs:complextype>
>
> </xs:schema>
>
> 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
>
>
>
>
>
> --
> Regards,
> Mukul Gandhi
>



-- 
Karl Stubsjoen
MeetScoresOnline.com
(602) 845-0006
Received on Thursday, 16 June 2011 04:18:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 16 June 2011 04:18:48 GMT