As I mentioned in my comment, the usage of <xsd:any>
is incorrect.
Furthermore, <xsd:sequence>
also cannot contain a complexType. See: http://msdn.microsoft.com/en-us/library/ms256089.aspx
I would also suggest not using patterns like RandomNameN to identify your elements but more like: <RandomName id='N'>
. Speaking OO, you could think of your XSD as your Class definitions, with the complexTypes
being the classes, and elements
being references to instances of the complexTypes
classes, therefore for elements you should also define their type
.
Your XML document will then represent your Objects. Where the type of the Object is represented in the Tag.
Your complexType could be wrapped inside of an element. And since you have a variable number of elements in the sequence, you should set maxOccurs
to unbounded. Your resulting Schema should look like this:
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:element name='ROOT'>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RandomName" maxOccurs='unbounded'>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Element" minOccurs='4' maxOccurs='4' type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>>
In which case your XML could look like this:
<ROOT >
<RandomName>
<Element>v</Element>
<Element>v</Element>
<Element>v</Element>
<Element>v</Element>
</RandomName>
<RandomName>
<Element>v</Element>
<Element>v</Element>
<Element>v</Element>
<Element>v</Element>
</RandomName>
</ROOT>
Finally, if RandomName1 - RandonNameN are from the same type (or Class if we're speaking OO) then the tags in the XML file should also be the same. Same goes for Element1-Element4.
However, if they are of different types but have common elements, you could use inheritance.
Element1
could look like this for example:
<complexType name="Element1">
<complexContent>
<extension base="Element">
<sequence>
<xs:element type="xs:string" name="additionalField"/>
</sequence>
</extension>
</complexContent>
</complexType>