
February 18th, 2011, 09:47 AM
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
|
Can't make xml validate against schema when omitting elements
I'm not a big fan of XML or XSD or XLS either because the documentation is poor, or my understandig of the documentation is poor.
Either way I have a problem. Part of a schema that a 3rd part has supplied is this
xml Code:
Original
- xml Code |
|
|
|
<xs:element name="DeliveredToAE" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="DeliveredToOperator"> <xs:complexType> <xs:sequence> <xs:element name="AEApprovalNo" type="aeApprovalNoType"/> <xs:element name="OperatorName"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="250"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Return" type="TonnageReturnType" maxOccurs="26"/> </xs:sequence> </xs:complexType> <xs:unique name="uniqueCategoryObligationDeliveredToAE"> <xs:selector xpath="Return"/> <xs:field xpath="CategoryName"/> <xs:field xpath="ObligationType"/> </xs:unique> </xs:element>
When I have relevant records I have no problem in creating the valid XML that validates agaisnt this part of the schema.
The validation fails when I have no data to make any XML elements of <DeliveredToAE>.
If i leave it out then the validation fails saying that it was expected
If I put an empty one in then I get an error saying that it is incomplete
Assuming I have no data for "DeliveredToAE" and given this schema, what would be the valid XML to put in?
|