title: ' ' is not a valid value for 'integer'. Accept nil or with values
body: <p>I am getting an error saying <em>'' is not a valid value for 'integer'.</em> I have tried using <em>nillable="true"</em> for the element and tried changing the pattern values using the restriction. The <em>parentInstanceId</em> element in the xml file doesn't have any values. But I am supposed to give a restriction of 20 characters to it.</p>
  
  <p>This is my xsd file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
   &lt;xs:element name="createSalesOrder"&gt;          &lt;!--root--&gt;
    &lt;xs:complexType mixed="true"&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element name="order"&gt;                  &lt;!--sub-root--&gt;
       &lt;xs:complexType mixed="true"&gt; 
        &lt;xs:sequence&gt;
  
         &lt;xs:element name="orderSource"&gt;       &lt;!--orderSource--&gt;
          &lt;xs:simpleType&gt;
          &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:maxLength value="30"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="purchaseOrder"&gt;       &lt;!--purchaseOrder--&gt;
         &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:maxLength value="20"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="purchaseOrderType"&gt;   &lt;!--purchaseOrderType--&gt;
         &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:maxLength value="5"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="purchaseOrderDate"&gt;   &lt;!--purchaseOrderDate--&gt;
         &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:date"/&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
          &lt;xs:element name="orderType"&gt;         &lt;!--orderType--&gt;
         &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:maxLength value="10"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="orderExpiry"&gt;             &lt;!--orderExpiry--&gt;
         &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:integer"&gt;
          &lt;xs:minInclusive value="1"/&gt;
          &lt;xs:maxInclusive value="5"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="orderConsumerReferenceId"&gt;  &lt;!--OCRId--&gt;
         &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:maxLength value="20"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="orderSourceReferenceId"&gt;  &lt;!--OSRId--&gt;
         &lt;xs:simpleType&gt;
          &lt;xs:restriction base="xs:integer"&gt;
          &lt;xs:pattern value="\d{7}"/&gt;
          &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="shipping"&gt;       &lt;!--shipping--&gt;
          &lt;xs:complexType mixed="true"&gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="requestedDate" type="xs:dateTime"/&gt;
            &lt;xs:element name="shipmentOrigin" type="xs:boolean"/&gt;
           &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="orderCurrency"&gt;  &lt;!--orderCurrency--&gt;
          &lt;xs:complexType mixed="true"&gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="currencyCode" type="xs:string" default="EUR"/&gt;
            &lt;xs:element name="currencyExchangeRate"&gt;
             &lt;xs:simpleType&gt;
              &lt;xs:restriction base="xs:integer"&gt;
               &lt;xs:enumeration value="1"/&gt;
              &lt;/xs:restriction&gt;
             &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
           &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="partner" maxOccurs="unbounded"&gt;  &lt;!--partner--&gt;
          &lt;xs:complexType mixed="true"&gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="partnerRole" type="xs:string"/&gt;
            &lt;xs:element name="partnerId"/&gt;
            &lt;xs:element name="communicationLanguageCode" type="xs:string"/&gt;
            &lt;xs:element name="address" minOccurs="0" maxOccurs="unbounded"&gt;
             &lt;xs:complexType mixed="true"&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/&gt;
               &lt;xs:element name="value"&gt;
               &lt;xs:simpleType&gt;
               &lt;xs:restriction base="xs:string"&gt;
                &lt;xs:maxLength value="50"/&gt;
               &lt;/xs:restriction&gt;
               &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
             &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
           &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="salesOrganization"&gt;  &lt;!-- salesOrganization --&gt;
          &lt;xs:simpleType&gt;
           &lt;xs:restriction base="xs:string"&gt;
            &lt;xs:maxLength value="10"/&gt;
           &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="distributionChannel"&gt; &lt;!--distributionChannel--&gt;
          &lt;xs:simpleType&gt;
           &lt;xs:restriction base="xs:string"&gt;
            &lt;xs:pattern value="[A-Z][A-Z]"/&gt;
           &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
  
         &lt;xs:element name="division" type="xs:integer"/&gt;
         &lt;xs:element name="orderTerm" minOccurs="1" maxOccurs="unbounded"&gt; &lt;!--orderTerm--&gt;
          &lt;xs:complexType mixed="true"&gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="name" type="xs:string"/&gt;
            &lt;xs:element name="value"&gt;
             &lt;xs:simpleType&gt;
              &lt;xs:restriction base="xs:string"&gt;
               &lt;xs:enumeration value="2 YEARS"/&gt;
               &lt;xs:enumeration value="3 YEARS"/&gt;
               &lt;xs:enumeration value="4 YEARS"/&gt;
               &lt;xs:enumeration value="5 YEARS"/&gt;
              &lt;/xs:restriction&gt;
             &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
           &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;
         &lt;xs:element name="lineItem" minOccurs="0"&gt;  &lt;!--lineItem--&gt;
          &lt;xs:complexType mixed="true"&gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="lineId" type="xs:integer"/&gt;
            &lt;xs:element name="parentLineId"&gt;      &lt;!--parentId--&gt;
             &lt;xs:simpleType&gt;
              &lt;xs:restriction base="xs:string"&gt;
               &lt;xs:maxLength value="12"/&gt;
              &lt;/xs:restriction&gt;
             &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="materialFlowType" type="xs:integer"/&gt;
            &lt;xs:element name="material" minOccurs="1" type="xs:string"/&gt;
            &lt;xs:element name="materialDescription" minOccurs="0"&gt;  &lt;!--materialDescription--&gt;
             &lt;xs:simpleType&gt;
              &lt;xs:restriction base="xs:string"&gt;
               &lt;xs:maxLength value="20"/&gt;
              &lt;/xs:restriction&gt;
             &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="orderedQuantity" minOccurs="1" type="xs:integer"/&gt; 
            &lt;xs:element name="configuration"&gt;     &lt;!--configuration--&gt;
             &lt;xs:complexType mixed="true"&gt;
              &lt;xs:sequence&gt;
               &lt;xs:element name="instanceId"&gt;      &lt;!--instanceId--&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:integer"&gt;
                  &lt;xs:pattern value="\d{1,20}"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
               &lt;xs:element name="parentInstanceId" nillable="false"&gt;  &lt;!--parentInstanceId--&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:integer"&gt;
                  &lt;xs:pattern value="[0-9]{0,20}"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
               &lt;xs:element name="quantity" type="xs:integer"/&gt;
               &lt;xs:element name="objectKey"&gt;        &lt;!--objectKey--&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:maxLength value="25"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
               &lt;xs:element name="characteristics" maxOccurs="unbounded"&gt;  &lt;!--characteristics--&gt;
                &lt;xs:complexType mixed="true"&gt;
                 &lt;xs:sequence&gt;
                  &lt;xs:element name="type" minOccurs="1"&gt;
                   &lt;xs:simpleType&gt;
                    &lt;xs:restriction base="xs:string"&gt;
                     &lt;xs:maxLength value="15"/&gt;
                    &lt;/xs:restriction&gt;
                   &lt;/xs:simpleType&gt;
                  &lt;/xs:element&gt;
                  &lt;xs:element name="value" minOccurs="1"&gt;
                   &lt;xs:simpleType&gt;
                    &lt;xs:restriction base="xs:string"&gt;
                     &lt;xs:maxLength value="20"/&gt;
                    &lt;/xs:restriction&gt;
                   &lt;/xs:simpleType&gt;
                  &lt;/xs:element&gt;
                 &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
               &lt;/xs:element&gt;                                  &lt;!--characteristics ends--&gt;
              &lt;/xs:sequence&gt;
             &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;              &lt;!--configuration ends--&gt;
            &lt;xs:element name="price"&gt;       &lt;!--price--&gt;
             &lt;xs:complexType mixed="true"&gt;
              &lt;xs:sequence&gt;
               &lt;xs:element name="name"&gt;      &lt;!--name--&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:maxLength value="15"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
               &lt;xs:element name="value" type="xs:decimal"/&gt;
               &lt;xs:element name="currencyCode" default="EUR" minOccurs="1" maxOccurs="1"&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:maxLength value="3"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
             &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;                       &lt;!--price ends--&gt;
            &lt;xs:element name="shippingDate"&gt;     &lt;!--shippingDate--&gt;
             &lt;xs:complexType mixed="true"&gt;
              &lt;xs:sequence&gt;
               &lt;xs:element name="name"&gt;
                &lt;xs:simpleType&gt;
                 &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:maxLength value="15"/&gt;
                 &lt;/xs:restriction&gt;
                &lt;/xs:simpleType&gt;
               &lt;/xs:element&gt;
               &lt;xs:element name="value" type="xs:dateTime"/&gt;
              &lt;/xs:sequence&gt;
             &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;                         &lt;!--shippingDate ends--&gt;
            &lt;xs:element name="shipmentOrigin" type="xs:string"/&gt;
           &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;                                   &lt;!--lineItem ends--&gt;
         &lt;xs:element name="callbackUrl" type="xs:string"/&gt;
        &lt;/xs:sequence&gt;
       &lt;/xs:complexType&gt;
      &lt;/xs:element&gt; 
      &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
   &lt;/xs:schema&gt;   
  </code></pre>
  
  <p>and this the xml file for which I am supposed to develop the xsd file</p>
  
  <pre><code>&lt;createSalesOrder&gt;
     (M)
     &lt;order&gt;
        (M)
        &lt;orderSource&gt;BridgeSAP&lt;/orderSource&gt;
        //restriction of 30 characters (M)
        &lt;purchaseOrder&gt;test USO now&lt;/purchaseOrder&gt;
        //restriction of 20 characters (M)
        &lt;purchaseOrderType&gt;ZSATA&lt;/purchaseOrderType&gt;
        //restriction of 5 characters, refer from value (M)
        &lt;purchaseOrderDate&gt;2015-06-25&lt;/purchaseOrderDate&gt;
        //restriction as of the value (M)
        &lt;orderType&gt;ZOR&lt;/orderType&gt;
        //restriction of 10 characters (O)
        &lt;orderExpiry&gt;2&lt;/orderExpiry&gt;
        //restriction of expiry ranges from 1-5
        &lt;orderConsumerReferenceId&gt;order017&lt;/orderConsumerReferenceId&gt;
        //restriction of 20 characters (M)
        &lt;orderSourceReferenceId&gt;6003670&lt;/orderSourceReferenceId&gt;
        //restriction of 8 numbers (M)
        &lt;shipping&gt;
           &lt;requestedDate&gt;2015-10-30T15:12:25&lt;/requestedDate&gt;
           //restriction as of the value (M)
           &lt;shipmentOrigin&gt;true&lt;/shipmentOrigin&gt;
           //restriction as of the value (O)
        &lt;/shipping&gt;
        &lt;orderCurrency&gt;
           &lt;currencyCode&gt;EUR&lt;/currencyCode&gt;
           //default the currency to EUR and provide restrictions (M)
           &lt;currencyExchangeRate&gt;1&lt;/currencyExchangeRate&gt;
           //restriction as of the value (M)
        &lt;/orderCurrency&gt;
        &lt;partner&gt;
           &lt;partnerRole&gt;AG&lt;/partnerRole&gt;
           //restriction as of the value (M)
           &lt;partnerId&gt;CFR01440&lt;/partnerId&gt;
           //restriction as of the value (M)
           &lt;communicationLanguageCode&gt;fr&lt;/communicationLanguageCode&gt;
           //restriction as of the value (O)
        &lt;/partner&gt;
        &lt;partner&gt;
           &lt;partnerRole&gt;WE&lt;/partnerRole&gt;
           &lt;partnerId/&gt;
           &lt;communicationLanguageCode&gt;ag&lt;/communicationLanguageCode&gt;
           &lt;address&gt;
              (O)
              &lt;name&gt;NAME1&lt;/name&gt;
              //restriction of 10 characters (M)
              &lt;value&gt;Example Name 1&lt;/value&gt;
              //restriction of 50 characters (O)
           &lt;/address&gt;
           &lt;address&gt;
              &lt;name&gt;NAME2&lt;/name&gt;
              &lt;value&gt;Example Name 2&lt;/value&gt;
           &lt;/address&gt;
        &lt;/partner&gt;
        &lt;salesOrganization&gt;FR08&lt;/salesOrganization&gt;
        //restriction of 10 characters (M)
        &lt;distributionChannel&gt;IG&lt;/distributionChannel&gt;
        //restriction as of the value (M)
        &lt;division&gt;01&lt;/division&gt;
        //restriction as of the value (M)
        &lt;orderTerm&gt;
           (M)
           &lt;name&gt;INCO1&lt;/name&gt;
           //restriction as of the value (M)
           &lt;value&gt;2 YEARS&lt;/value&gt;
           //restriction as of enumeration (2 YEARS, 3 YEARS, 4 YEARS, 5 YEARS) (M)
        &lt;/orderTerm&gt;
        &lt;orderTerm&gt;
           &lt;name&gt;INCO2&lt;/name&gt;
           &lt;value&gt;3 YEARS&lt;/value&gt;
        &lt;/orderTerm&gt;
        &lt;orderTerm&gt;
           &lt;name&gt;ZTERM&lt;/name&gt;
           &lt;value&gt;4 YEARS&lt;/value&gt;
        &lt;/orderTerm&gt;
        &lt;lineItem&gt;
           (O)
           &lt;lineId&gt;1000&lt;/lineId&gt;
           //restriction as of the value (M)
           &lt;parentLineId/&gt;
           //restriction of 12 characters (O)
           &lt;materialFlowType&gt;1&lt;/materialFlowType&gt;
           //restriction as of the value (M)
           &lt;material&gt;GCR_S24SWB_01&lt;/material&gt;
           //restriction as of the value (M)
           &lt;materialDescription&gt;SM6 24kV&lt;/materialDescription&gt;
           //restriction of 20 characters (O)
           &lt;orderedQuantity&gt;1&lt;/orderedQuantity&gt;
           //restriction as of the value (M)
           &lt;configuration&gt;
              &lt;instanceId&gt;00000001&lt;/instanceId&gt;
              //restriction as of 20 characters (M)
              &lt;parentInstanceId/&gt;
              //restriction as of 20 characters (O)
              &lt;quantity&gt;1&lt;/quantity&gt;
              //restriction as of the value (M)
              &lt;objectKey&gt;GCR_S24SWB_01&lt;/objectKey&gt;
              //restriction as of 25 characters (M)
              &lt;characteristics&gt;
                 &lt;type&gt;PRO_ARKTX1&lt;/type&gt;
                 //restriction as of 15 characters (M)
                 &lt;value&gt;SM6 Test&lt;/value&gt;
                 //restriction as of 20 characters (M)
              &lt;/characteristics&gt;
              &lt;characteristics&gt;
                 &lt;type&gt;PRO_ETO_FLAG&lt;/type&gt;
                 &lt;value&gt;1&lt;/value&gt;
              &lt;/characteristics&gt;
           &lt;/configuration&gt;
           &lt;price&gt;
              &lt;name&gt;ZPN0&lt;/name&gt;
              //restriction as of 15 characters (M)
              &lt;value&gt;4500.50&lt;/value&gt;
              //restriction as of the value (M)
              &lt;currencyCode&gt;EUR&lt;/currencyCode&gt;
              //default the currency to EUR and provide restrictions (M)
           &lt;/price&gt;
           &lt;shippingDate&gt;
              &lt;name&gt;ETDAT&lt;/name&gt;
              //restriction as of 15 characters (M)
              &lt;value&gt;2015-10-30T15:12:25&lt;/value&gt;
              //restriction as of the value (M)
           &lt;/shippingDate&gt;
           &lt;shipmentOrigin&gt;FR12&lt;/shipmentOrigin&gt;
           //restriction as of the value (O)
        &lt;/lineItem&gt;
        &lt;callbackUrl&gt;https://www.example.com/xml&lt;/callbackUrl&gt;
     &lt;/order&gt;
  &lt;/createSalesOrder&gt;
  </code></pre>