Re: Choice between complextContent and complexType
Mukul Gandhi <[email protected]>
| Newsgroups | gmane.text.xml.schema.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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