Altova Mailing List Archives


Re: complex type

From: "Priya Lakshminarayanan" <priyal@---------.--->
To: NULL
Date: 6/21/2006 10:53:00 AM

You can use the following content model to allow the elements in any order 
and to allow them to appear any number of times. But you will have to check 
in your application code that each of the elements appear atleast once.

<xsd:complexType name="OrderType">
 <xsd:choice minOccurs="1" maxOccurs="unbounded">
 <xsd:element name="shipTo" type="Address"/>
 <xsd:element name="billTo" type="Address"/>
 <xsd:element ref="comment" minOccurs="0"/>
 <xsd:element name="items" type="Items"/>
 </xsd:choice>
 <xsd:attribute name="orderDate" type="xsd:date"/>
 </xsd:complexType>

Thanks,
Priya

"Vinita" <batra.vinita@g...> wrote in message 
news:1150862702.009899.288430@b......
> hi,
> thanks for the reply.
> but if i use <xs:all> indicator then maxOccur value for element can not
> be more than one.
> but my requirement is that i do not want to use any ordering of
> elements in complex type as well as maxOccur for element can be
> "unbounded"
> Please suggest some solution for this.
>
> Thanks and Regards
> Vinita Batra.
>
>
> Dhanvanth wrote:
>> Vinita wrote:
>> > suppose there r 6 elements with in xml complex type,
>> > Now i do not want any ordering for these elements.
>> > but i want, all the elements should be present with in a complex type.
>> > and maxoccurrence for these elements within complex type can be
>> > "unbounded"
>> >
>> > Is there any solution for this?
>> >
>> >
>> > Regards
>> > Vinita
>>
>> you can use the xsd:all element to specify what you need.
>>
>> eg:
>>
>> <xsd:complexType name="OrderType">
>> <xsd:all>
>> <xsd:element name="shipTo" type="Address"/>
>> <xsd:element name="billTo" type="Address"/>
>> <xsd:element ref="comment" minOccurs="0"/>
>> <xsd:element name="items" type="Items"/>
>> </xsd:all>
>> <xsd:attribute name="orderDate" type="xsd:date"/>
>> </xsd:complexType>
>>
>> XSD All element permits the elements in the group to appear (or not
>> appear) in any order in the containing element. When a complex type
>> includes the all element the corresponding XML data can include some or
>> all of the listed elements in any order. To make the elements
>> compulsory, use the minOccurs attribute.
>> (the above definition taken from http://smrtx.com/RS/xsd.htm)
> 


Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.