XSD1.1 validation
Posted: Thu Mar 15, 2018 10:26 am
Hi,
I am new to XML and XSD validations
Below is my input xml
<ApplicationDetail>
<AppControlNumber>123</AppControlNumber>
<SourceCode>123</SourceCode>
<FormCode>254</FormCode>
</ApplicationDetail>
I need to validate this but the condition is as follows
------VALID CASES----
Condition1: If value in AppControlNumber tag is present then it should be valid
Condition2: If value in AppControlNumber tag & SourceCode is present then it should be valid
Condition3: If value in AppControlNumber tag & FormCode is present then it should be valid
Condition4: If value in AppControlNumber tag,SourceCode & FormCodeis present then it should be valid
Condition5: If value in SourceCode tag & FormCode is present then it should be valid
** i am not able to implement condition5
i have validated 4 conditions with xsd
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="xml">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationDetail">
<xs:complexType>
<xs:sequence>
<xs:element name="AppControlNumber" minOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:short"/>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SourceCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base='xs:string'>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FormCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I tried XSD 1.1 to validate condition 5 but the solution isn't proper.Can someone help me preparing a schema which validates all the above rules.
Thanks
Gunjan
I am new to XML and XSD validations
Below is my input xml
<ApplicationDetail>
<AppControlNumber>123</AppControlNumber>
<SourceCode>123</SourceCode>
<FormCode>254</FormCode>
</ApplicationDetail>
I need to validate this but the condition is as follows
------VALID CASES----
Condition1: If value in AppControlNumber tag is present then it should be valid
Condition2: If value in AppControlNumber tag & SourceCode is present then it should be valid
Condition3: If value in AppControlNumber tag & FormCode is present then it should be valid
Condition4: If value in AppControlNumber tag,SourceCode & FormCodeis present then it should be valid
Condition5: If value in SourceCode tag & FormCode is present then it should be valid
** i am not able to implement condition5
i have validated 4 conditions with xsd
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="xml">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationDetail">
<xs:complexType>
<xs:sequence>
<xs:element name="AppControlNumber" minOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:short"/>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SourceCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base='xs:string'>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FormCode" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I tried XSD 1.1 to validate condition 5 but the solution isn't proper.Can someone help me preparing a schema which validates all the above rules.
Thanks
Gunjan