I've been trying (rather unsuccessfully) to create an XSD that would allow for something like this:
Here is something I've tried already:
As you can see I want to separate the SubRules element and the Variable attribute from RuleTaskEnum so I can use them for other task types yet to be defined (you can see one in there RuleTaskLength).
That XSD shows an error for multiple definitions of "Value".
I've also try extensions (tried this first actually):
How can I possibly get it so the SubRules element can be in any order with the other elements of the task (if there are other elements), and be decoupled from the tasks?
Please let me know if you need me to clarify anything.
Thanks.
Code:
<RuleTasks>
<RuleTaskEnum Variable="SpecialType">
<SubRules />
<Value>1</Value>
<Value>2</Value>
</RuleTaskEnum>
<RuleTaskEnum Variable="SpecialType1">
<Value>1</Value>
<Value>2</Value>
<SubRules />
</RuleTaskEnum>
<RuleTaskEnum Variable="SpecialType2">
<Value>1</Value>
<SubRules />
<Value>2</Value>
</RuleTaskEnum>
</RuleTasks>
Code:
<xs:complexType name="RuleTasks">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="RuleTaskEnum" type="RuleTaskEnum" />
<xs:element name="RuleTaskLength" type="RuleTaskLength" />
</xs:choice>
</xs:complexType>
<xs:attributeGroup name="aRuleTask">
<xs:attribute name="Variable" type="xs:string" use="required" />
<xs:attribute name="StopProcessing" type="xs:boolean" use="optional" />
<xs:attribute name="FailMsg" type="xs:string" use="optional" />
<xs:attribute name="WarnNoFail" type="xs:boolean" use="optional" />
</xs:attributeGroup>
<xs:group name="gRuleTask">
<xs:sequence>
<xs:element name="SubRules" type="RuleContainer" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:group>
<xs:complexType name="RuleTaskEnum">
<xs:choice>
<xs:sequence>
<xs:group ref="gRuleTask" />
<xs:element name="Value" type="xs:anyURI" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:sequence>
<xs:element name="Value" type="xs:anyURI" minOccurs="1" maxOccurs="unbounded" />
<xs:group ref="gRuleTask" />
</xs:sequence>
</xs:choice>
<xs:attributeGroup ref="aRuleTask" />
</xs:complexType>
That XSD shows an error for multiple definitions of "Value".
I've also try extensions (tried this first actually):
Code:
<xs:complexType name="RuleTask">
<xs:sequence>
<xs:element name="SubRules" type="RuleContainer" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="Variable" type="xs:string" use="required" />
<xs:attribute name="StopProcessing" type="xs:boolean" use="optional" />
<xs:attribute name="FailMsg" type="xs:string" use="optional" />
<xs:attribute name="WarnNoFail" type="xs:boolean" use="optional" />
</xs:complexType>
<xs:complexType name="RuleTaskEnum">
<xs:complexContent>
<xs:extension base="RuleTask">
<xs:sequence>
<xs:element name="Value" type="xs:anyURI" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="RuleTaskLength">
<xs:complexContent>
<xs:extension base="RuleTask">
<xs:attribute name="MinLength" type="xs:integer" use="optional" />
<xs:attribute name="MaxLength" type="xs:integer" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
How can I possibly get it so the SubRules element can be in any order with the other elements of the task (if there are other elements), and be decoupled from the tasks?
Please let me know if you need me to clarify anything.
Thanks.