I am working on a schema file that I intend to use with JAXB for a project of mine. In Java, I have the following sort of code structure
public interface Condition {
...
}
public class AndCondition implements Condition {
public AndCondition(List<Condition> conditions){
...
}
}
public class StateCondition implements Condition {
public StateCondition(Item item, String attributeName, String attributeValue){
...
}
}
Naturally I have other objects in my code which rely on having a Condition object
public class Action{
List<Item> targets;
List<Item> tools;
Condition condition;
...
}
My question is, if I define in my XML Schema a complexType and extend them:
<xs:element name="Condition">
</xs:element>
<xs:element name="StateCondition">
<xs:complexContent>
<xs:extension base="Condition">
<xs:sequence>
<xs:element ref="Item" />
<xs:element name="ATTRIB" type="AttributeType" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:element>
<xs:element name="AndCondition">
<xs:complexContent>
<xs:extension base="Condition">
<xs:sequence>
<xs:element ref="Condition" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:element>
<xs:element name="Item">
<xs:sequence>
<xs:element name="TARGETS">
<xs:element ref="Item" minOccurs="0" maxOccurs="unbounded />
</xs:element>
<xs:element name="TOOLS">
<xs:element ref="Item" minOccurs="0" maxOccurs="unbounded />
</xs:element>
<xs:element ref="Condition" />
</xs:sequence>
</xs:element>
Will I achieve the same sort of idea? In which I mean, if I create an XML file that holds one AndCondition, will it satisfy the validator?