I am searching for the best solution of my XML schema (XSD).
I have a response:
<xs:element name="exampleCatalogResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="meta" type="tns:metaType" />
<xs:element name="data" type="tns:defaultDataType" />
</xs:sequence>
</xs:complexType>
</xs:element>
…the defaultDatatype:
<xs:complexType name="defaultDataType">
<xs:sequence>
<xs:element name="catalog">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="catalogItem" type="tns:catalogItem" />
</xs:sequence>
</xs:complexType>
<xs:unique name="itemIdConstraint">
<xs:selector xpath="tns:catalogItem" />
<xs:field xpath="tns:id" />
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
…and the catalogItem:
<xs:complexType name="catalogItem">
<xs:sequence>
<xs:element name="id" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
…but now there is a special item which specialize catalogItem:
<xs:complexType name="specialItem">
<xs:complexContent>
<xs:extension base="tns:catalogItem">
<xs:sequence>
<xs:element name="code" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Now I need an specialized Response for my specialItem for answering the request which expects this specialItem.
How can I realise this, without writing another defaultDataType where only the type of catalogItem changes to tns:specialItem?
Thank you for your tipps 13ren,
I used the Subsumption Feature. So the default catalogItem is used everywhere also for the unique expression. And now if i use this in xml i can specify this via type.
So the last item is the default, and the two above are specialized items. this works very well for me.