What xsd will let an element have itself as a sub element infinitely?
- by David Basarab
How can I create an xsd to give me this type of xml structure that can go on infinitely?
<?xml version="1.0" encoding="utf-8" ?>
<SampleXml>
<Items>
<Item name="SomeName" type="string">
This would be the value
</Item>
<Item name="SecondName" type="string">
This is the next string
</Item>
<Item name="AnotherName" type="list">
<Items>
<Item name="SubName" type="string">
A string in a sub list
</Item>
<Item name="SubSubName" type="list">
<Items>
<Item name="HowDoI" type="string">
How do I keep this going infinately?
</Item>
</Items>
</Item>
</Items>
</Item>
</Items>
</SampleXml>
The only solution I have found has been to just repeat in the xsd as many times as I am willing to copy. Like below.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="SampleXml">
<xs:complexType>
<xs:sequence>
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Item">
<xs:complexType mixed="true">
<xs:sequence minOccurs="0">
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Item">
<xs:complexType mixed="true">
<xs:sequence minOccurs="0">
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element name="Item">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="type" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="type" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="type" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>