Lists with uniques

This should cover W3C XML Schema, Relax NG and DTD related problems.
senseiwa
Posts: 5

Lists with uniques

Wed May 04, 2011 4:15 pm

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!!
adrian
Posts: 2461

Re: Lists with uniques

Wed May 04, 2011 5:35 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
senseiwa
Posts: 5

Re: Lists with uniques

Thu May 05, 2011 12:31 pm

adrian wrote:Hello,

This is possible and quite simple with the GUI.




Thanks! That was really perfect! :)

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 2 guests