Defining multiple possibilities for the same element
Posted
by
moggi
on Stack Overflow
See other posts from Stack Overflow
or by moggi
Published on 2011-01-16T03:04:54Z
Indexed on
2011/01/16
5:53 UTC
Read the original article
Hit count: 215
xsd
|xml-schema
Hello,
is it possible in XML Schema to define the same element with several different definitions depending on one attribute.
As Example:
<xsd:element name="Element">
<xsd:complexType>
<xsd:sequence>
<xsd:attribute name="type" fixed="type1"/>
<xsd:seqeuence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Element">
<xsd:complexType>
<xsd:sequence>
<xsd:attribute name="type" fixed="type2"/>
<xsd:attribute name="value" type="xsd:integer"/>
<xsd:seqeuence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RootElement">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Element"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Or is there any other way to solve this problem. It is important that both definitions are named "Element", because I have an application needing that both elements are named the same way. But there is a second application that needs the additional information for type2.
© Stack Overflow or respective owner