views:

381

answers:

2

I'd like the ability to have an arbitrary level of nesting children of the same parent element, e.g.:

<path expr="/">
  <path expr="usr">
    <path expr="bin">
      <path expr="X11" />
    </path>
  </path>
  <path expr="var" />
</path>

I'm writing the XML Schema file, and I'm at a loss as to how to represent this parent/child relationship in the schema: here's what I have, but it's not a valid schema definition:

          <xs:element name="path">
            <xs:complexType>
              <xs:sequence>
                <xs:element ref="path" minOccurs="0" />
              </xs:sequence>
              <xs:attribute name="expr" type="xs:string" use="required" />
            </xs:complexType>
          </xs:element>

Update: Thanks for the response. I tried that, and I'm getting the following error: The 'w3.org/2001/XMLSchema:complexType' element is not supported in this context. I should mention that the path hierarchy as I've described is itself a child of an element called application, so the entire structure resembles this:

<application name="test">
  <path expr="/">
    <path expr="usr">
      <path expr="bin">
        <path expr="X11" />
      </path>
    </path>
    <path expr="var" />
  </path>
</application>
+2  A: 
Colin
Thanks for the response. I tried that, and I'm getting the following error:The 'http://www.w3.org/2001/XMLSchema:complexType' element is not supported in this context. I should mention that the path hierarchy as I've described is itself a child of an element called application, so the entire structure resembles this:<application name="test"> <path expr="/"> <path expr="usr"> <path expr="bin"> <path expr="X11" /> </path> </path> <path expr="var" /> </path></application>
@Nick Davis: It's best to add clarifications like this one to the question itself (you can always edit it). In a comment you don't have formatting, and potentially important details are out of view.
Tomalak
Thanks for the tip -- I've edited the original question with my comment.
Thanks, that worked!
A: 

Personally I prefer RelaxNG over XML Schema. May be worth your time to try it out.

flygandehund