By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Extending complex type - minOccurs

P: n/a
Hi all :)

Is it posible in xsd to change only minOccurs value of element in
complex type by extending this type?

The problem I'm trying to solve is this: I have two complex types -
"TextField" and "FileChooser".
Here is definition of "TextField"

<xsd:complexType name="TextField">
<xsd:sequence>
<xsd:element name="paramName" type="xsd:string"/>
<!-- some other element's definitions here -->
<xsd:element name="file" minOccurs="0" type="file" />
</xsd:sequence>
</xsd:complexType>

"FileChooser"'s type is "TextFile", but I want to ensure that in
"FileChooser" element "file" will occur 1 time. How can it be done? Is
it possible?

Thx for yor time,
Katis

Apr 19 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 19 Apr, 12:25, katis <katarzyna.by...@gmail.comwrote:
Hi all :)

Is it posible in xsd to change only minOccurs value of element in
complex type by extending this type?

The problem I'm trying to solve is this: I have two complex types -
"TextField" and "FileChooser".
Here is definition of "TextField"

<xsd:complexType name="TextField">
<xsd:sequence>
<xsd:element name="paramName" type="xsd:string"/>
<!-- some other element's definitions here -->
<xsd:element name="file" minOccurs="0" type="file" />
</xsd:sequence>
</xsd:complexType>

"FileChooser"'s type is "TextFile", but I want to ensure that in
"FileChooser" element "file" will occur 1 time. How can it be done? Is
it possible?

Thx for yor time,
Katis
Hi Katis,
I think it is not possible. Once you define an element of a particular
complex type it will take the complex types defintion. So you have to
change minOccurs to 1 within "TextFile" type.
Thanks,
Chandra

Apr 19 '07 #2

P: n/a
Thanks for your response, Chandru - I get your point. But it seems I
didn't make myselfe clear. I was thinking of defining another complex
type - let's say "FileChooserType" that would extend "TextField", and
defining "FileChooser" as a element of a "FileChooserType" type.

So my question - one more time - is: is it possible to change value of
minOccurs of some element when extending the complex type? In other
words - I have complex type "TextField" and "FileChooserType"
extending "TextField" type. In "TextField" I have <xsd:element
name="file" minOccurs="0" type="file" /defined. I want to be able to
use "file" element also in "FileChooserType", but with minOccurs
changed from 0 to 1. Can it be done using extending mechanism or
should I define another type - let's say "SuperTextType" without
"file" element in it, and make "TextField" and "FileChooserType"
extending "SuperTextType", each of them defining "file" element with
different minOccurs count?

Katis

Chandru napisal(a):
On 19 Apr, 12:25, katis <katarzyna.by...@gmail.comwrote:
Hi all :)

Is it posible in xsd to change only minOccurs value of element in
complex type by extending this type?

The problem I'm trying to solve is this: I have two complex types -
"TextField" and "FileChooser".
Here is definition of "TextField"

<xsd:complexType name="TextField">
<xsd:sequence>
<xsd:element name="paramName" type="xsd:string"/>
<!-- some other element's definitions here -->
<xsd:element name="file" minOccurs="0" type="file" />
</xsd:sequence>
</xsd:complexType>

"FileChooser"'s type is "TextFile", but I want to ensure that in
"FileChooser" element "file" will occur 1 time. How can it be done? Is
it possible?

Thx for yor time,
Katis

Hi Katis,
I think it is not possible. Once you define an element of a particular
complex type it will take the complex types defintion. So you have to
change minOccurs to 1 within "TextFile" type.
Thanks,
Chandra
Apr 19 '07 #3

P: n/a
On 19 Apr, 13:17, katis <katarzyna.by...@gmail.comwrote:
Thanks for your response, Chandru - I get your point. But it seems I
didn't make myselfe clear. I was thinking of defining another complex
type - let's say "FileChooserType" that would extend "TextField", and
defining "FileChooser" as a element of a "FileChooserType" type.

So my question - one more time - is: is it possible to change value of
minOccurs of some element when extending the complex type? In other
words - I have complex type "TextField" and "FileChooserType"
extending "TextField" type. In "TextField" I have <xsd:element
name="file" minOccurs="0" type="file" /defined. I want to be able to
use "file" element also in "FileChooserType", but with minOccurs
changed from 0 to 1. Can it be done using extending mechanism or
should I define another type - let's say "SuperTextType" without
"file" element in it, and make "TextField" and "FileChooserType"
extending "SuperTextType", each of them defining "file" element with
different minOccurs count?

Katis

Chandru napisal(a):
On 19 Apr, 12:25, katis <katarzyna.by...@gmail.comwrote:
Hi all :)
Is it posible in xsd to change only minOccurs value of element in
complex type by extending this type?
The problem I'm trying to solve is this: I have two complex types -
"TextField" and "FileChooser".
Here is definition of "TextField"
<xsd:complexType name="TextField">
<xsd:sequence>
<xsd:element name="paramName" type="xsd:string"/>
<!-- some other element's definitions here -->
<xsd:element name="file" minOccurs="0" type="file" />
</xsd:sequence>
</xsd:complexType>
"FileChooser"'s type is "TextFile", but I want to ensure that in
"FileChooser" element "file" will occur 1 time. How can it be done? Is
it possible?
Thx for yor time,
Katis
Hi Katis,
I think it is not possible. Once you define an element of a particular
complex type it will take the complex types defintion. So you have to
change minOccurs to 1 within "TextFile" type.
Thanks,
Chandra- Hide quoted text -

- Show quoted text -

I think what you could do is use schema's <restrictionoption, e.g.
define FileChooser as:

<xsd:complexType name="FileChooser">
<xsd:complexContent>
<xsd:restriction base="TextField">
<xsd:sequence>
<xsd:element name="paramName" type="xsd:string"/>
<!-- some other element's definitions here -->
<xsd:element name="file" minOccurs="1" type="file" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

The down side of that is that you largely have to redefine
FileChooser. You can get around this to some degree by using a group
for the common stuff.

<xsd:complexType name="TextField">
<xsd:sequence>
<xsd:group ref="commonStuff"/>
<xsd:element name="file" minOccurs="0" type="file" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="FileChooser">
<xsd:complexContent>
<xsd:restriction base="TextField">
<xsd:sequence>
<xsd:group ref="commonStuff"/>
<xsd:element name="file" minOccurs="1" type="file" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

Consequently, your suggestions to use a super type is probably more
appealing.

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML Schema to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============================================

Apr 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.