title: Why XML Schema example in primer fails to validate?
body: <p>I am looking at <code>po.xml</code> example in <a href="http://www.w3.org/TR/xmlschema-0/#po.xml" rel="nofollow">XML Schema primer</a>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;purchaseOrder orderDate="1999-10-20" xmlns="http://www.example.com/PO"&gt;
     &lt;shipTo country="US"&gt;
        &lt;name&gt;Alice Smith&lt;/name&gt;
        &lt;street&gt;123 Maple Street&lt;/street&gt;
        &lt;city&gt;Mill Valley&lt;/city&gt;
        &lt;state&gt;CA&lt;/state&gt;
        &lt;zip&gt;90952&lt;/zip&gt;
     &lt;/shipTo&gt;
     &lt;billTo country="US"&gt;
        &lt;name&gt;Robert Smith&lt;/name&gt;
        &lt;street&gt;8 Oak Avenue&lt;/street&gt;
        &lt;city&gt;Old Town&lt;/city&gt;
        &lt;state&gt;PA&lt;/state&gt;
        &lt;zip&gt;95819&lt;/zip&gt;
     &lt;/billTo&gt;
     &lt;comment&gt;Hurry, my lawn is going wild!&lt;/comment&gt;
     &lt;items&gt;
        &lt;item partNum="872-AA"&gt;
           &lt;productName&gt;Lawnmower&lt;/productName&gt;
           &lt;quantity&gt;1&lt;/quantity&gt;
           &lt;USPrice&gt;148.95&lt;/USPrice&gt;
           &lt;comment&gt;Confirm this is electric&lt;/comment&gt;
        &lt;/item&gt;
        &lt;item partNum="926-AA"&gt;
           &lt;productName&gt;Baby Monitor&lt;/productName&gt;
           &lt;quantity&gt;1&lt;/quantity&gt;
           &lt;USPrice&gt;39.98&lt;/USPrice&gt;
           &lt;shipDate&gt;1999-05-21&lt;/shipDate&gt;
        &lt;/item&gt;
     &lt;/items&gt;
  &lt;/purchaseOrder&gt;
  </code></pre>
  
  <p>When I validate it <a href="http://www.freeformatter.com/xml-validator-xsd.html" rel="nofollow">here</a> it fails to validate using the following schema:</p>
  
  <pre><code>&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO" targetNamespace="http://www.example.com/PO"&gt;
  
    &lt;xsd:annotation&gt;
      &lt;xsd:documentation xml:lang="en"&gt;
       Purchase order schema for Example.com.
       Copyright 2000 Example.com. All rights reserved.
      &lt;/xsd:documentation&gt;
    &lt;/xsd:annotation&gt;
  
    &lt;xsd:element name="purchaseOrder" type="PurchaseOrderType"/&gt;
  
    &lt;xsd:element name="comment" type="xsd:string"/&gt;
  
    &lt;xsd:complexType name="PurchaseOrderType"&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="shipTo" type="USAddress"/&gt;
        &lt;xsd:element name="billTo" type="USAddress"/&gt;
        &lt;xsd:element ref="comment" minOccurs="0"/&gt;
        &lt;xsd:element name="items"  type="Items"/&gt;
      &lt;/xsd:sequence&gt;
      &lt;xsd:attribute name="orderDate" type="xsd:date"/&gt;
    &lt;/xsd:complexType&gt;
  
    &lt;xsd:complexType name="USAddress"&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="name"   type="xsd:string"/&gt;
        &lt;xsd:element name="street" type="xsd:string"/&gt;
        &lt;xsd:element name="city"   type="xsd:string"/&gt;
        &lt;xsd:element name="state"  type="xsd:string"/&gt;
        &lt;xsd:element name="zip"    type="xsd:decimal"/&gt;
      &lt;/xsd:sequence&gt;
      &lt;xsd:attribute name="country" type="xsd:NMTOKEN"
                     fixed="US"/&gt;
    &lt;/xsd:complexType&gt;
  
    &lt;xsd:complexType name="Items"&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="item" minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence&gt;
              &lt;xsd:element name="productName" type="xsd:string"/&gt;
              &lt;xsd:element name="quantity"&gt;
                &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:positiveInteger"&gt;
                    &lt;xsd:maxExclusive value="100"/&gt;
                  &lt;/xsd:restriction&gt;
                &lt;/xsd:simpleType&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="USPrice"  type="xsd:decimal"/&gt;
              &lt;xsd:element ref="comment"   minOccurs="0"/&gt;
              &lt;xsd:element name="shipDate" type="xsd:date" minOccurs="0"/&gt;
            &lt;/xsd:sequence&gt;
            &lt;xsd:attribute name="partNum" type="SKU" use="required"/&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  
    &lt;!-- Stock Keeping Unit, a code for identifying products --&gt;
    &lt;xsd:simpleType name="SKU"&gt;
      &lt;xsd:restriction base="xsd:string"&gt;
        &lt;xsd:pattern value="\d{3}-[A-Z]{2}"/&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:simpleType&gt;
  
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>With the following error:</p>
  
  <blockquote>
    <p>Src-resolve.4.1: Error Resolving Component 'PurchaseOrderType'. It Was Detected That 'PurchaseOrderType' Has No Namespace, But Components With No Target Namespace Are Not Referenceable From Schema Document 'null'. If 'PurchaseOrderType' Is Intended To Have A Namespace, Perhaps A Prefix Needs To Be Provided. If It Is Intended That 'PurchaseOrderType' Has No Namespace, Then An 'import' Without A "namespace" Attribute Should Be Added To 'null'.</p>
  </blockquote>
  
  <p>Similar happens if I run <code>xmllint --schema po.xsd po.xml</code>:</p>
  
  <blockquote>
    <p>po.xsd:10: element element: Schemas parser error : Element '{<a href="http://www.w3.org/2001/XMLSchema" rel="nofollow">http://www.w3.org/2001/XMLSchema</a>}element', attribute 'type': References from this schema to components in no namespace are not allowed, since not indicated by an import statement.</p>
  </blockquote>
  
  <p>(I added <code>xmlns:po="http://www.example.com/PO" targetNamespace="http://www.example.com/PO"</code> to the root element in schema found in primer in the hope that it will make it work, but no luck.)</p>