Reputation: 11524
I want to create an *.xsd Document(for a simple game ;) ) which has that specification:
The <description>
has mixed elements and it has child elements i and b. These have the same type as the description element, so they can have the same i and b Element.
So I guess I have to create a recursive structure? My question is how to create such a structure?
Upvotes: 1
Views: 389
Reputation: 21638
There are some confusing statements; when you say "description
has mixed elements and [...]" do you mean to say other elements such as <c/> and <d/>, or mixed
as in it allows text as well (think html markup here)? When you refer to the i and b content, do each one has only, and the same i and b Element
, or the above mixed elements as well?
To achieve recursive content model for your case I recommend to base it using types, as opposed to groups; the former is working with most tools that I know. Here is a simple example of an XSD, that supports text (mixed="true"), from where you could start exploring:
<?xml version="1.0" encoding="utf-8"?>
<!--W3C Schema generated by QTAssistant/W3C Schema Refactoring Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="description" type="descriptionType"/>
<xsd:complexType name="descriptionType" mixed="true">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="b" type="descriptionType"/>
<xsd:element name="i" type="descriptionType"/>
</xsd:choice>
</xsd:complexType>
</xsd:schema>
I would in parallel visualize conformant XMLs, and start tweaking:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">text<b>text<b>text<b>text</b>
<i>text</i>
</b>
<i>text<b>text</b>
<i>text</i>
</i>
</b>
<i>text<b>text<b>text</b>
<i>text</i>
</b>
<i>text<b>text</b>
<i>text</i>
</i>
</i>
</description>
Upvotes: 1