Can I write XSD schema for this? Please note that the category is repeated inside other category (same name). (Sorry I’m new to XML Schemas.)
<list>
<category name="...">
<category name="Cats">
<subcategory>Syamese</subcategory>
</category>
</category>
<category name="...">
<category name="Dogs">
<subcategory>Fox Terier</subcategory>
</category>
</category>
</list>
My current XSD has the following, but it’s only good for only one category wrapper.
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element name="category">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element ref="category"/>
<xs:element maxOccurs="unbounded" ref="subcategory"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
I know I’d better rename one of the category’s. But can I do this anyway?
Yes, that’s legal. Perhaps not convenient. Think of XHTML. You can nest div in div in div… just like your category in category.
Your’re missing the list element part in your XSD.