0
votes

Hi
the below is my xml

<?xml version="1.0" encoding="UTF-8"?>
<CatalogObjects loadItemName="CatalogEntryOfferPrice">
<Catalog>
<PriceListUniqueId></PriceListUniqueId>
<PriceListName>MadisonsNominal Products Price List</PriceListName>
<CatentryUniqueId></CatentryUniqueId>
<CatentryPartNumber>012-300-050-RX</CatentryPartNumber>
<Identifier></Identifier>
<Precedence>0</Precedence>
<StartDate></StartDate>
<EndDate></EndDate>
<QuantityUnitIdentifier></QuantityUnitIdentifier>
<MinimumQuantity></MinimumQuantity>
<MaximumQuantity></MaximumQuantity>
<LastUpdate></LastUpdate>
<Description></Description>
<PriceInUSD>45</PriceInUSD>
<PriceInBRL></PriceInBRL>
<PriceInCAD></PriceInCAD>
<PriceInCNY></PriceInCNY>
<PriceInEUR></PriceInEUR>
<PriceInJPY></PriceInJPY>
<PriceInKRW></PriceInKRW>
<PriceInTWD></PriceInTWD>
<Delete>0</Delete>
</Catalog>

for that i created xsd as below

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  elementFormDefault="qualified">
 <xs:element name="CatalogObjects">
  <xs:complexType>
<xs:sequence>
<xs:element ref="Catalog" />
</xs:sequence>
<xs:attribute type="xs:string" name="loadItemName" fixed="CatalogEntryOfferPrice" use="required"/>
  </xs:complexType>
</xs:element>
<xs:element name="Catalog" >
 <xs:complexType>
<xs:sequence>
       <xs:element type="xs:string" name="PriceListUniqueId" />
       <xs:element type="xs:string" name="PriceListName" />
       <xs:element type="xs:string" name="CatentryUniqueId" />
       <xs:element type="xs:string" name="CatentryPartNumber" />
       <xs:element type="xs:string" name="Identifier" />
       <xs:element type="xs:byte" name="Precedence" />
       <xs:element type="xs:string" name="StartDate" />
       <xs:element type="xs:string" name="EndDate" />
       <xs:element type="xs:string" name="QuantityUnitIdentifier" />
       <xs:element type="xs:string" name="MinimumQuantity" />
       <xs:element type="xs:string" name="MaximumQuantity" />
       <xs:element type="xs:string" name="LastUpdate" />
       <xs:element type="xs:string" name="Description" />
       <xs:element type="xs:float" name="PriceInUSD" />
       <xs:element type="xs:float" name="PriceInBRL" />
       <xs:element type="xs:float" name="PriceInCAD" />
       <xs:element type="xs:float" name="PriceInCNY" />
       <xs:element type="xs:float" name="PriceInEUR" />
       <xs:element type="xs:float" name="PriceInJPY" />
       <xs:element type="xs:float" name="PriceInKRW" />
       <xs:element type="xs:float" name="PriceInTWD" />
       <xs:element type="xs:byte" name="Delete" fixed="0"/>
    </xs:sequence>
   </xs:complexType>
 </xs:element>
 </xs:schema>  

i want price elements and date elements can be empty but i am getting error for "date" and "float" elements as below

Error - Line 10, 25: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 25; cvc-datatype-valid.1.2.1: '' is not a valid value for 'date'.
Error - Line 10, 25: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 25; cvc-type.3.1.3: The value '' of element 'StartDate' is not valid.
Error - Line 11, 21: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-datatype-valid.1.2.1: '' is not a valid value for 'date'.
Error - Line 11, 21: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-type.3.1.3: The value '' of element 'EndDate' is not valid.
Error - Line 18, 27: org.xml.sax.SAXParseException; lineNumber: 18; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 18, 27: org.xml.sax.SAXParseException; lineNumber: 18; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInBRL' is not valid.
Error - Line 19, 27: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 19, 27: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInCAD' is not valid.
Error - Line 20, 27: org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 20, 27: org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInCNY' is not valid.
Error - Line 21, 27: org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 21, 27: org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInEUR' is not valid.
Error - Line 22, 27: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 22, 27: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInJPY' is not valid.
Error - Line 23, 27: org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 23, 27: org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInKRW' is not valid.
Error - Line 24, 27: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 27; cvc-datatype-valid.1.2.1: '' is not a valid value for 'float'.
Error - Line 24, 27: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 27; cvc-type.3.1.3: The value '' of element 'PriceInTWD' is not valid.

i tried xsd nullable ,minOccurs and maxOccurs but i am not succeeded.Can any one please put some light on minOccurs , maxOccurs and xsd nullable to solve this issue?
Thanks

1

1 Answers

1
votes

Setting nillability to true has the effect that an empty element is allowed if it carries the attribute-value specification xsi:nil="true" (or the equivalent -- the namespace prefix may vary, and the value may be a literal 1 instead of true). But the default value of xsi:nil is false.

If you want to allow the value to be absent without specifying xsi:nil="true", one way would be to define a union type whose first member is xsd:float (or xsd:date) and whose second member is a restriction of xsd:string whose single value is the empty string.