views:

25

answers:

2

Hi, 1. Need to define XSD element that has some attributes and can hold list of itself

This is the type definition:

<xs:complexType name="t_TestCase" >
  <xs:sequence>
    <xs:element type="t_TestCase" minOccurs="0"></xs:element>
  </xs:sequence>
</xs:complexType>

This is the element based on the type:

  1. BUT - when adding attribute to the type - it seems that it is not valid anymore. (the sequence tag is invalid)

Advise please?

Tx

A: 

Use a complex type like so:

  <xs:element name="t_TestCase">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="t_TestCase"/>
      </xs:sequence>
      <xs:attribute name="att1"/>
    </xs:complexType>
  </xs:element>

Edit: my first answer sucked

p00ya
Thanks. I noticed that the top node is an element rather than ComplexType...What i do want is to define everything as ComplexType and then assign this to an element. Is that possible?
jammusi
The problem is that if you're allowing children of the complex type "t_TestCase" to be nested within themselves, under what tag are they nested? You have to name an element somewhere.
p00ya
A: 

I miss here something....is it that the problem was the order of appearence of the sequence and attribute tags (sequence must come first)?

jammusi