I’m trying to write a schema for some XML that is like HTML.
It has < b >< u >< i >< font >< img > tags all inside < p >(aragraph) tags. The problem is they can be in any order:
<p> <u><b>test</u><b> </p>
or
<p> <b><u>test</u></b> </p>.
I am trying to create a self referential complex type but I always get “invalid schema” errors. If anyone can guide me to the correct way to do this I would be much appreciated.
Schema:
<xs:element name="HTMLDocument">
<xs:complexType>
<xs:sequence>
<xs:element name="p" type="textElements" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="textElements" mixed="true">
<xs:group>
<xs:element name="b" type="textElements"/>
<xs:element name="i" type="textElements"/>
<xs:element name="u" type="textElements"/>
<xs:element name="a" type="textElements"/>
<xs:element name="font" type="textElements">
<xs:complexType>
<xs:attribute name="size" type="xs:string"/>
<xs:attribute name="face" type="xs:string"/>
<xs:attribute name="color" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="img">
<xs:complexType>
<xs:attribute name="src" type="xs:string"/>
<xs:attribute name="width" type="xs:decimal"/>
<xs:attribute name="height" type="xs:decimal"/>
</xs:complexType>
</xs:element>
</xs:group>
</xs:complexType>
</xs:schema>
Gaaah, curse you XML Schema!
Sorry, just need to let that out sometimes. I think this does what you want, but some testing wouldn’t be bad:
EDIT: oh, looks like you don’t need that extra xs:sequence. I’ll take it out…