Page 1 of 1

Lists with uniques

Posted: Wed May 04, 2011 4:15 pm
by senseiwa
Dear all,

I am a newbie here, and I don't know much about schemas... I am still using the GUI for that!

What am I trying to do? I'd like to create a complex type that is a list of unique elements... obviously without succeeding!

For example, I want a complex type with the following possibilities:
- a
- b
- c
- d

So, something like

Code: Select all

<mynode>
<a/>
<b/>
</mynode>
is ok, and so is

Code: Select all

<mynode>
<d/>
<a/>
</mynode>
However, entering the same element twice, it should raise an error:

Code: Select all

<mynode>
<d/>
<a/>
<d/>
</mynode>
Is it possible to do this with the GUI?
Thanks!!

Re: Lists with uniques

Posted: Wed May 04, 2011 5:35 pm
by adrian
Hello,

This is possible and quite simple with the GUI.

1. Add a new global complex type:
Right click on the schema frame and from the contextual menu choose:
New Global -> Complex Type, give it a name.
2. Inside the complex type add an All compositor:
Right click on the complex type and from the the contextual menu choose:
Append Child -> All
3. Inside the All compositor add each element and make it optional:
For each element right click on the All compositor and from the the contextual menu choose:
Append Child -> Element, give the element a name, right click on the added element and from the contextual menu choose Optional.

You will obtain something like this:

Code: Select all

<xs:complexType name="mytype">
<xs:all>
<xs:element name="a" minOccurs="0"></xs:element>
<xs:element name="b" minOccurs="0"></xs:element>
<xs:element name="c" minOccurs="0"></xs:element>
<xs:element name="d" minOccurs="0"></xs:element>
</xs:all>
</xs:complexType>
Regards,
Adrian

Re: Lists with uniques

Posted: Thu May 05, 2011 12:31 pm
by senseiwa
adrian wrote:Hello,

This is possible and quite simple with the GUI.

Thanks! That was really perfect! :)