我有一個架構如下圖所示,我有一個關於架構如何使無論是在XML模式強制性領域
1.How使CourierNumber
或WorkLocationCoordinate
mandatory.I幾個問題都使用一個全球型下面
EDIT所示 仍然沒有運氣如阿貝爾提到我修飾的模式,但它是failing.The輸入XML是
<?xml version="1.0" encoding="utf-8"?>
<NOCPlantMapRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<NOCTypeID>0</NOCTypeID>
<WorkLocation>
<ParcelNumber>4545</ParcelNumber>
<Roads>
<WorkLocationRoad>
<RoadName>dubai road</RoadName>
</WorkLocationRoad>
</Roads>
<WorkArea>
<WorkArea>
<Coordinates>
<WorkLocationCoordinate>
<CoordinateX>56</CoordinateX>
<CoordinateY>23</CoordinateY>
</WorkLocationCoordinate>
</Coordinates>
<Communities />
</WorkArea>
</WorkArea>
</WorkLocation>
</NOCPlantMapRequest>
和SCH EMA是
<?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="NOCReference" minOccurs="0" type="xsd:string" />
<xsd:element name="NOCTypeID" minOccurs="0" type="xsd:unsignedByte" />
<xsd:element name="NOCTypeName" minOccurs="0" type="xsd:string" />
<xsd:element name="ApplicationName" minOccurs="0" type="xsd:string" />
<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:choice>
<xsd:sequence>
<xsd:element name="ParcelNumber" type="ParcelNumberType" />
</xsd:sequence>
<xsd:sequence>
<xsd:element name="WorkArea" type="WorkAreaType" />
</xsd:sequence>
</xsd:choice>
</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: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>
但如下圖所示 不適我收到錯誤。
Error - Line 6, 12: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 12; cvc-complex-type.2.4.d: Invalid content was found starting with element 'Roads'. No child element is expected at this point.
Error - Line 19, 24: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 24; cvc-complex-type.2.4.d: Invalid content was found starting with element 'Communities'. No child element is expected at this point.
我的主要要求是要麼ParcelNumber
或WorkLocationCoordinateType
應該呈現,出了什麼問題?
你可以修改它根據我的問題,因爲當我把類型WorkLocationCoordinate我得到的錯誤類型屬性不能與簡單類型或複雜類型一起存在 –
peter
try –
Manraj
相同的結果「屬性不能以簡單類型或複雜類型出現」 – peter