title: S4s-att-not-allowed: Attribute 'targetNameSpace' Cannot Appear In Element 'schema' validation error
body: <p>So I get this error when attempting to validate my XML</p>
  
  <p>"S4s-att-not-allowed: Attribute 'targetNameSpace' Cannot Appear In Element 'schema'."</p>
  
  <p>I have a commonTypes.xsd with all the rules that I would need to associate to different elements. This is the commonTypes.xsd file:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-16" ?&gt;
  &lt;xs:schema
             targetNamespace="common"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             elementFormDefault="qualified"&gt;
  
  &lt;!-- Password Restrictions --&gt;
      &lt;xs:simpleType name="passWord"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[A-Za-z0-9_]{6,12}" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;!-- User Name Restrictions --&gt;
      &lt;xs:simpleType name="userName"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[A-Za-z]{6,12}" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;!-- Name Retrictions --&gt;
      &lt;xs:simpleType name="firstName"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[A-Za-z]" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
      &lt;xs:simpleType name="middleName"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[A-Za-z]" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
      &lt;xs:simpleType name="lastName"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[A-Za-z]" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;!-- Email Restrictions --&gt;
      &lt;xs:simpleType name="email"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="[^@]+@[^\.]+\..+" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;!-- Gender --&gt;
      &lt;xs:simpleType name="gender"&gt;
          &lt;xs:restriction base="xu:string"&gt;
              &lt;xs:pattern value="male|female" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  
      &lt;!-- Number Restrictions --&gt;
      &lt;xs:simpleType name="number"&gt;
          &lt;xs:restriction base="xu:integer"&gt;
              &lt;xs:pattern value="^[2-9]\d{2}-\d{3}-\d{4}$" /&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>the file that I am attempting to validate- and its schema are as follows:</p>
  
  <p>user.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  
  &lt;user xmlns="localhost"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
      &gt;
  &lt;!-- I will use xs:schemalocation="/user.xsd" as the location of the schema --&gt;
      &lt;userId&gt;&lt;/userId&gt;
      &lt;loginInfo&gt;
          &lt;userName&gt;&lt;/userName&gt;
          &lt;passWord&gt;&lt;/passWord&gt;
      &lt;/loginInfo&gt;
      &lt;contactInfo&gt;
          &lt;firstName&gt;&lt;/firstName&gt;
          &lt;middleName&gt;&lt;/middleName&gt;
          &lt;lastName&gt;&lt;/lastName&gt;
      &lt;/contactInfo&gt;
      &lt;profile&gt;
          &lt;email&gt;&lt;/email&gt;
          &lt;dateOfBirth&gt;&lt;/dateOfBirth&gt;
          &lt;gender&gt;&lt;/gender&gt;
          &lt;profilePhoto&gt;
          &lt;/profilePhoto&gt;
          &lt;homePhone&gt;&lt;/homePhone&gt;
          &lt;cellPhone&gt;&lt;/cellPhone&gt;
      &lt;/profile&gt;
      &lt;createdDate&gt;&lt;/createdDate&gt;
  &lt;/user&gt;
  </code></pre>
  
  <p>and the user.xsd:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:cmn="commonTypes.xsd"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             targetNameSpace="user"&gt;
  &lt;xs:import namespace="commonTypes" schemaLocation="commonTypes.xsd" /&gt;
      &lt;!-- Main Users Schema --&gt;
  
      &lt;xs:element name="user"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
          &lt;!-- userID --&gt;
          &lt;xs:element maxOccurs="1" name="userID" type="cmn:ID"/&gt;
  
          &lt;!-- login Info --&gt;
          &lt;xs:element name="loginInfo"&gt;
              &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                      &lt;!-- Username and Password --&gt;
                      &lt;xs:element name="userName" type="cmn:userName" /&gt;
                      &lt;xs:element name="passWord" type="cmn:passWord" /&gt;
                  &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;!-- Name --&gt;
          &lt;xs:element name="contactInfo"&gt;
              &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                      &lt;!-- Names --&gt;
                      &lt;xs:element name="firstName" type="cmn:firstName" /&gt;
                      &lt;xs:element name="middleName" type="cmn:middleName" /&gt;
                      &lt;xs:element name="lastName" type="cmn:lastName" /&gt;
                  &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;!-- Profile --&gt;
          &lt;xs:element name="profile"&gt;
              &lt;xs:complexType name="profile"&gt;
                  &lt;xs:sequence&gt;
                      &lt;!-- Profile --&gt;
                      &lt;xs:element name="email" type="cmn:email" /&gt;
                      &lt;xs:element name="dateOfBirth" type="cmn:date" /&gt;
                      &lt;xs:element name="gender" type="cmn:gender" /&gt;
                      &lt;xs:element name="profilePhoto" type="cmn:image" /&gt;
                      &lt;xs:element name="homePhone" type="cmn:number" /&gt;
                      &lt;xs:element name="cellPhone" type="cmn:number" /&gt;
                  &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;xs:element name="createdDate" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>So my question is, why I cannot use a <code>targetNameSpace</code> in this schema when I have seen documentation with it being used? </p>
  
  <p>I think this problems stems from me attempting to import- and then use the rules associated with the commonTypes.xsd file. </p>
  
  <p>I am brand new to XML and its kicking my butt. Any other suggestions are welcome. thanks!</p>