This question already has an answer here:
I have a requirement like either ParcelNumber or co-ordinates like CoordinateX or CoordinateY mandatory and these two contains different hierarchy in XML . So if the input xml contains parcel number it should return success or if it contains co-ordinates, then it should return success.I created following schema ,and it will return success if i send only parcel number, but if i send Co-ordinates it will fail ,it is asking to send parcel number which is wrong.How to achieve it.In Nutshell i have following question
1>If i send both coordinates and no parcel number it should return success 2>IF i send x coordinate then it should fail and ask to send Y co ordinate Following is what i have done so far
<?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> <xsd:element name="NOCPlantMapRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="Applicationtype" minOccurs="0" type="xsd:string"/> <xsd:element name="RelatedNOCRefNumber" minOccurs="0" type="xsd:string"/> <xsd:element name="WorkLocation" minOccurs="1" maxOccurs="1" type="LocationType"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="LocationType"> <xsd:all> <xsd:element name="ParcelNumber" type="ParcelNumberType" maxOccurs="1"/> <xsd:element name="WorkArea" type="WorkAreaType" maxOccurs="1"/> <xsd:element name="Roads" type="RoadListType" maxOccurs="1"/> </xsd:all> </xsd:complexType> <xsd:complexType name="RoadListType"> <xsd:sequence> <xsd:element name="WorkLocationRoad" type="WorkLocationRoadType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="WorkLocationRoadType"> <xsd:sequence> <xsd:element name="RoadName" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="CommunitiesListType"> <xsd:sequence> <xsd:element name="WorkLocationRoad" type="WorkLocationRoadType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="ParcelNumberType"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> <xsd:complexType name="WorkAreaType"> <xsd:sequence> <xsd:element name="WorkArea" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Coordinates" minOccurs="1" type="CoordinatesType"/> <xsd:element name="Communities" type="CommunitiesListType" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="CoordinatesType"> <xsd:sequence> <xsd:element name="WorkLocationCoordinate" type="WorkLocationCoordinateType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="WorkLocationCoordinateType"> <xsd:sequence> <xsd:element name="CoordinateX" type="xsd:string"/> <xsd:element name="CoordinateY" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema> EDIT Any idea of how to use choice properly here
EDIT i did like but no luck at all
<xs:complexType name="tSome"> <xs:sequence> <xs:choice> <xs:element name="ParcelNumber" type="ParcelNumberType" /> <xs:element name="WorkArea" type="WorkAreaType" /> </xs:choice> <xs:element name="Roads" type="RoadListType" /> </xs:sequence> </xs:complexType>
No comments:
Post a Comment