title: The element "x" in namespace "xSchema" has invalid child element "y" in namespace "xSchema". List of possible elements expected: "y"
body: <p>I am writing a schema for my XML validation final, and finally got everything (just about) working. But now I'm getting the strangest error in my XML. I'll start by showing my schema since that's where the problem should be located yet it gives me no errors.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;schema xmlns="http://www.w3.org/2001/XMLSchema"
          xmlns:os="OrdersSchema"
          targetNamespace="OrdersSchema"
          elementFormDefault="unqualified"
          attributeFormDefault="qualified"&gt;
    &lt;element name="orders"    type="os:orders"/&gt;
    &lt;complexType name="orders"&gt;
      &lt;sequence&gt;
        &lt;element name="order" type="os:order" maxOccurs="unbounded"/&gt;
      &lt;/sequence&gt;
    &lt;/complexType&gt;
    &lt;complexType name="order"&gt;
      &lt;sequence&gt;
        &lt;element name="deliveryAddress"&gt;
          &lt;complexType&gt;
            &lt;sequence&gt;
              &lt;element name='line1' type='os:lineType'/&gt;
              &lt;element name='line2' type='os:lineType'/&gt;
              &lt;element name='line3' type='os:lineType'/&gt;
              &lt;element name='line4' type='os:lineType' minOccurs='0'/&gt;
            &lt;/sequence&gt;
            &lt;attribute name="orderId" type="string" use="required" &gt;
            &lt;/attribute&gt;
            &lt;attribute name="type" type="os:typeType" use="required"/&gt;
          &lt;/complexType&gt;
          &lt;unique name="uniqueOrderIdPerOrder"&gt;
            &lt;selector xpath="os:order"/&gt;
            &lt;field xpath="orderId"/&gt;
          &lt;/unique&gt;
        &lt;/element&gt;
        &lt;element name='items'&gt;
          &lt;complexType&gt;
            &lt;attribute name='productId' type='os:productIdType'/&gt;
            &lt;attribute name='quantity'&gt;
              &lt;simpleType&gt;
                &lt;restriction base='positiveInteger'&gt;
                &lt;/restriction&gt;
              &lt;/simpleType&gt;
            &lt;/attribute&gt;
          &lt;/complexType&gt;
        &lt;/element&gt;
        &lt;element name='note' minOccurs='0' type='string'/&gt;
      &lt;/sequence&gt;
    &lt;/complexType&gt;
  
    &lt;simpleType name='lineType'&gt;
      &lt;restriction base='string'&gt;
        &lt;minLength value='1'/&gt;
      &lt;/restriction&gt;
    &lt;/simpleType&gt;
    &lt;simpleType name='typeType'&gt;
      &lt;restriction base='string'&gt;
        &lt;enumeration value='standard'/&gt;
        &lt;enumeration value='express'/&gt;
      &lt;/restriction&gt;
    &lt;/simpleType&gt;
    &lt;simpleType name='productIdType'&gt;
      &lt;restriction base='string'&gt;
        &lt;pattern value='(?i)p[-\s](150|1[0-4][0-9]|[[1-9][0-9]|[1-9])\.[a-z][a-z][a-z][a-z][a-z][a-z]'/&gt;
        &lt;pattern value='A...+[$XYZ]\b'/&gt;
      &lt;/restriction&gt;
    &lt;/simpleType&gt;
  
  
  
  &lt;/schema&gt;
  </code></pre>
  
  <p>Now, my schema gives no errors at all, but when I link my XML file to it, I get an error saying: The element 'orders' in namespace 'OrdersSchema' has invalid child element 'order' in namespace 'OrdersSchema'. List of possible elements expected: 'order'. </p>
  
  <p>Here's a code that should validate, if anyone wants to try it out:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;os:orders xmlns:os="OrdersSchema"&gt;
    &lt;os:order orderId="ord0001" type="standard"&gt;
      &lt;deliveryAddress&gt;
        &lt;line1&gt;5, Elmstreet&lt;/line1&gt;
        &lt;line2&gt;90210 Beverly Hills&lt;/line2&gt;
        &lt;line3&gt;California&lt;/line3&gt;
      &lt;/deliveryAddress&gt;
      &lt;items&gt;
        &lt;item productId="P 150.aabaac" quantity="5" /&gt;
      &lt;/items&gt;
      &lt;note&gt;Deliver after 5 pm.&lt;/note&gt;
    &lt;/os:order&gt;
    &lt;os:order orderId="ord0003" type="express"&gt;
      &lt;deliveryAddress&gt;
        &lt;line1&gt;Voskenslaan 30&lt;/line1&gt;
        &lt;line2&gt;BE9000 Gent&lt;/line2&gt;
        &lt;line3&gt;Oost-Vlaanderen&lt;/line3&gt;
        &lt;line4&gt;Belgium&lt;/line4&gt;
      &lt;/deliveryAddress&gt;
      &lt;items&gt;
        &lt;item productId="A3546sdfsdf6546sdf654Z" quantity="10" /&gt;
        &lt;item productId="p 149.SLKDOZ" quantity="5" /&gt;
        &lt;item productId="P 100.xcvZEr" quantity="15" /&gt;
      &lt;/items&gt;
    &lt;/os:order&gt;
    &lt;os:order orderId="ord0002" type="express"&gt;
      &lt;deliveryAddress&gt;
        &lt;line1&gt;Voskenslaan 32&lt;/line1&gt;
        &lt;line2&gt;BE9000 Gent&lt;/line2&gt;
        &lt;line3&gt;Oost-Vlaanderen&lt;/line3&gt;
        &lt;line4&gt;Belgium&lt;/line4&gt;
      &lt;/deliveryAddress&gt;
      &lt;items&gt;
        &lt;item productId="P-99.ruioze" quantity="15" /&gt;
        &lt;item productId="A123qze46548X" quantity="50" /&gt;
        &lt;item productId="P 1.sqmfze" quantity="1" /&gt;
        &lt;item productId="AoknY" quantity="20" /&gt;
      &lt;/items&gt;
      &lt;note&gt;This is &lt;b&gt;very urgent&lt;/b&gt; !&lt;/note&gt;
    &lt;/os:order&gt;
  &lt;/os:orders&gt;
  </code></pre>