title: validating an XML schema with empty attributes
body: <p>I am having trouble validating my xml schema.</p>
  
  <p>I get these errors on the schema</p>
  
  <blockquote>
    <p>113: 18 s4s-elt-invalid-content.1: The
    content of '#AnonType_user' is
    invalid.</p>
    
    <p>164: 17 s4s-elt-invalid-content.1: The
    content of '#AnonType_festival' is
    invalid. Element 'sequence' is
    invalid, misplaced, or occurs too
    often.</p>
  </blockquote>
  
  <p>and becuase of those 2 errors, i am getting loads of the same error.  This is becuase the attribute id of the festival tag may be empty becuase there is not data for that festival</p>
  
  <blockquote>
    <p>cvc-datatype-valid.1.2.1: '' is not a
    valid value for 'integer'.</p>
    
    <p>cvc-attribute.3: The value '' of
    attribute 'id' on element 'festival'
    is not valid with respect to its type,
    'integer'.</p>
  </blockquote>
  
  <p>The lines in the schema causing the problems are</p>
  
  <pre><code>&lt;xs:element name="user"&gt;
    &lt;xs:complexType&gt;
   &lt;xs:attribute name="id" type="xs:integer"/&gt;
     &lt;xs:sequence&gt;
    &lt;xs:element ref="personal"/&gt;
    &lt;xs:element ref="account"/&gt; 
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:element name="festival"&gt;
    &lt;xs:complexType&gt;
   &lt;xs:attribute name="id" type="xs:integer" user="optional"/&gt;
    &lt;xs:sequence&gt;
     &lt;xs:element ref="event"/&gt;
     &lt;xs:element ref="contact"/&gt; 
   &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>This is a snippet from my XML file.  One user has a festival and the other doesn't</p>
  
  <pre><code>&lt;member&gt;
   &lt;user id="3"&gt;
    &lt;personal&gt;
     &lt;name&gt;Skye Saunders&lt;/name&gt;
     &lt;sex&gt;Female&lt;/sex&gt;
     &lt;address1&gt;31 Anns Court&lt;/address1&gt;
     &lt;address2&gt;&lt;/address2&gt;
     &lt;city&gt;Cirencester&lt;/city&gt;
     &lt;county&gt;Gloucestershire&lt;/county&gt;
     &lt;postcode&gt;GL7 1JG&lt;/postcode&gt;
     &lt;telephone&gt;01958303514&lt;/telephone&gt;
     &lt;mobile&gt;07260491667&lt;/mobile&gt;
     &lt;email&gt;bigundecided@hotmail.co.uk&lt;/email&gt;
    &lt;/personal&gt;
    &lt;account&gt;
     &lt;username&gt;BigUndecided&lt;/username&gt;
     &lt;password&gt;ea297847f80e046ca24a8621f4068594&lt;/password&gt;
     &lt;userlevel&gt;2&lt;/userlevel&gt;
     &lt;signupdate&gt;2010-03-26T09:23:50&lt;/signupdate&gt;
    &lt;/account&gt;
   &lt;/user&gt;
   &lt;festival id=""&gt;
    &lt;event&gt;
     &lt;eventname&gt;&lt;/eventname&gt;
     &lt;url&gt;&lt;/url&gt;
     &lt;datefrom&gt;&lt;/datefrom&gt;
     &lt;dateto&gt;&lt;/dateto&gt;
     &lt;location&gt;&lt;/location&gt;
     &lt;eventpostcode&gt;&lt;/eventpostcode&gt;
     &lt;coords&gt;
      &lt;lat&gt;&lt;/lat&gt;
      &lt;lng&gt;&lt;/lng&gt;
     &lt;/coords&gt;
    &lt;/event&gt;
    &lt;contact&gt;
     &lt;conname&gt;&lt;/conname&gt;
     &lt;conaddress1&gt;&lt;/conaddress1&gt;
     &lt;conaddress2&gt;&lt;/conaddress2&gt;
     &lt;concity&gt;&lt;/concity&gt;
     &lt;concounty&gt;&lt;/concounty&gt;
     &lt;conpostcode&gt;&lt;/conpostcode&gt;
     &lt;contelephone&gt;&lt;/contelephone&gt;
     &lt;conmobile&gt;&lt;/conmobile&gt;
     &lt;fax&gt;&lt;/fax&gt;
     &lt;conemail&gt;&lt;/conemail&gt;
    &lt;/contact&gt;
   &lt;/festival&gt;
  &lt;/member&gt;
  &lt;member&gt;
   &lt;user id="4"&gt;
    &lt;personal&gt;
     &lt;name&gt;Connor Lawson&lt;/name&gt;
     &lt;sex&gt;Male&lt;/sex&gt;
     &lt;address1&gt;12 Ash Way&lt;/address1&gt;
     &lt;address2&gt;&lt;/address2&gt;
     &lt;city&gt;Swindon&lt;/city&gt;
     &lt;county&gt;Wiltshire&lt;/county&gt;
     &lt;postcode&gt;SN3  6GS&lt;/postcode&gt;
     &lt;telephone&gt;01791928119&lt;/telephone&gt;
     &lt;mobile&gt;07338695664&lt;/mobile&gt;
     &lt;email&gt;itunestinker@fsmail.co.uk&lt;/email&gt;
    &lt;/personal&gt;
    &lt;account&gt;
     &lt;username&gt;iTuneStinker&lt;/username&gt;
     &lt;password&gt;3a1f5fda21a07bfff20c41272bae7192&lt;/password&gt;
     &lt;userlevel&gt;3&lt;/userlevel&gt;
     &lt;signupdate&gt;2010-03-26T09:23:50&lt;/signupdate&gt;
    &lt;/account&gt;
   &lt;/user&gt;
   &lt;festival id="1"&gt;
    &lt;event&gt;
     &lt;eventname&gt;Oxford Folk Festival&lt;/eventname&gt;
     &lt;url&gt;http://www.oxfordfolkfestival.com/&lt;/url&gt;
     &lt;datefrom&gt;2010-04-07&lt;/datefrom&gt;
     &lt;dateto&gt;2010-04-09&lt;/dateto&gt;
     &lt;location&gt;Oxford&lt;/location&gt;
     &lt;eventpostcode&gt;OX19BE&lt;/eventpostcode&gt;
     &lt;coords&gt;
      &lt;lat&gt;51.735640&lt;/lat&gt;
      &lt;lng&gt;-1.276136&lt;/lng&gt;
     &lt;/coords&gt;
    &lt;/event&gt;
    &lt;contact&gt;
     &lt;conname&gt;Stuart Vincent&lt;/conname&gt;
     &lt;conaddress1&gt;P.O. Box 642&lt;/conaddress1&gt;
     &lt;conaddress2&gt;&lt;/conaddress2&gt;
     &lt;concity&gt;Oxford&lt;/concity&gt;
     &lt;concounty&gt;Bedfordshire&lt;/concounty&gt;
     &lt;conpostcode&gt;OX13BY&lt;/conpostcode&gt;
     &lt;contelephone&gt;01865 79073&lt;/contelephone&gt;
     &lt;conmobile&gt;&lt;/conmobile&gt;
     &lt;fax&gt;&lt;/fax&gt;
     &lt;conemail&gt;stewards@oxfordfolkfestival.com&lt;/conemail&gt;
    &lt;/contact&gt;
   &lt;/festival&gt;
  &lt;/member&gt;
  </code></pre>
  
  <p>This is my schema</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt;
   &lt;xs:simpleType name="postcode"&gt;
    &lt;xs:restriction base="xs:string"&gt;
     &lt;xs:minLength value="6"/&gt;
     &lt;xs:maxLength value="8"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  
   &lt;xs:simpleType name="telephone"&gt;
    &lt;xs:restriction base="xs:string"&gt;
     &lt;xs:minLength value="10"/&gt;
     &lt;xs:maxLength value="13"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  
   &lt;xs:simpleType name="mobile"&gt;
    &lt;xs:restriction base="xs:string"&gt;
     &lt;xs:minLength value="11"/&gt;
     &lt;xs:maxLength value="11"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  
   &lt;xs:simpleType name="password"&gt;
    &lt;xs:restriction base="xs:string"&gt;
     &lt;xs:minLength value="32"/&gt;
     &lt;xs:maxLength value="32"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  
   &lt;xs:simpleType name="userlevel"&gt;
    &lt;xs:restriction base="xs:integer"&gt;
     &lt;xs:enumeration value="1"/&gt;
     &lt;xs:enumeration value="2"/&gt;
     &lt;xs:enumeration value="3"/&gt;
     &lt;xs:enumeration value="4"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt;
  
   &lt;xs:simpleType name="county"&gt;
    &lt;xs:restriction base="xs:string"&gt;
     &lt;xs:enumeration value="Bedfordshire"/&gt;
     &lt;xs:enumeration value="Berkshire"/&gt;
     &lt;xs:enumeration value="Bristol"/&gt;
     &lt;xs:enumeration value="Buckinghamshire"/&gt;
     &lt;xs:enumeration value="Cambridgeshire"/&gt;
     &lt;xs:enumeration value="Cheshire"/&gt;
     &lt;xs:enumeration value="Cleveland"/&gt;
     &lt;xs:enumeration value="Cornwall"/&gt;
     &lt;xs:enumeration value="Cumberland"/&gt;
     &lt;xs:enumeration value="Derbyshire"/&gt;
     &lt;xs:enumeration value="Devon"/&gt;
     &lt;xs:enumeration value="Dorset"/&gt;
     &lt;xs:enumeration value="Durham"/&gt;
     &lt;xs:enumeration value="East Ridings Of Yorkshire"/&gt;
     &lt;xs:enumeration value="Essex"/&gt;
     &lt;xs:enumeration value="Gloucestershire"/&gt;
     &lt;xs:enumeration value="Hampshire"/&gt;
     &lt;xs:enumeration value="Herefordshire"/&gt;
     &lt;xs:enumeration value="Hertfordshire"/&gt;
     &lt;xs:enumeration value="Huntingdonshire"/&gt;
     &lt;xs:enumeration value="Isle Of Man"/&gt;
     &lt;xs:enumeration value="Kent"/&gt;
     &lt;xs:enumeration value="Lancashire"/&gt;
     &lt;xs:enumeration value="Leicestershire"/&gt;
     &lt;xs:enumeration value="Lincolnshire"/&gt;
     &lt;xs:enumeration value="London"/&gt;
     &lt;xs:enumeration value="Middlesex"/&gt;
     &lt;xs:enumeration value="Norfolk"/&gt;
     &lt;xs:enumeration value="North Yorkshire"/&gt;
     &lt;xs:enumeration value="Northamptonshire"/&gt;
     &lt;xs:enumeration value="Northumberland"/&gt;
     &lt;xs:enumeration value="Nottinghamshire"/&gt;
     &lt;xs:enumeration value="Oxfordshire"/&gt;
     &lt;xs:enumeration value="Rutland"/&gt;
     &lt;xs:enumeration value="Shropshire"/&gt;
     &lt;xs:enumeration value="Somerset"/&gt;
     &lt;xs:enumeration value="South Yorkshire"/&gt;
     &lt;xs:enumeration value="Staffordshire"/&gt;
     &lt;xs:enumeration value="Suffolk"/&gt;
     &lt;xs:enumeration value="Surrey"/&gt;
     &lt;xs:enumeration value="Sussex"/&gt;
     &lt;xs:enumeration value="Tyne and Wear"/&gt;
     &lt;xs:enumeration value="Warwickshire"/&gt;
     &lt;xs:enumeration value="West Yorkshire"/&gt;
     &lt;xs:enumeration value="Westmorland"/&gt;
     &lt;xs:enumeration value="Wiltshire"/&gt;
     &lt;xs:enumeration value="Wirral"/&gt;
     &lt;xs:enumeration value="Worcestershire"/&gt;
     &lt;xs:enumeration value="Yorkshire"/&gt;
    &lt;/xs:restriction&gt;
   &lt;/xs:simpleType&gt; 
  
   &lt;xs:element name="folktask"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element minOccurs="0" maxOccurs="unbounded" ref="member"/&gt;
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="member"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="user" minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element ref="festival" minOccurs="0" maxOccurs="unbounded"/&gt;  
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
  
   &lt;xs:element name="user"&gt;
     &lt;xs:complexType&gt;
    &lt;xs:attribute name="id" type="xs:integer"/&gt;
      &lt;xs:sequence&gt;
     &lt;xs:element ref="personal"/&gt;
     &lt;xs:element ref="account"/&gt; 
      &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
  
   &lt;xs:element name="personal"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="name"/&gt;
      &lt;xs:element ref="sex"/&gt;
      &lt;xs:element ref="address1"/&gt;
      &lt;xs:element ref="address2"/&gt;
      &lt;xs:element ref="city"/&gt;
      &lt;xs:element ref="county"/&gt;
      &lt;xs:element ref="postcode"/&gt;
      &lt;xs:element ref="telephone"/&gt;
      &lt;xs:element ref="mobile"/&gt;
      &lt;xs:element ref="email"/&gt;
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="name" type="xs:string"/&gt;
   &lt;xs:element name="sex" type="xs:string"/&gt;
   &lt;xs:element name="address1" type="xs:string"/&gt;
   &lt;xs:element name="address2" type="xs:string"/&gt;
   &lt;xs:element name="city" type="xs:string"/&gt;
   &lt;xs:element name="county" type="xs:string"/&gt;
   &lt;xs:element name="postcode" type="postcode"/&gt;
   &lt;xs:element name="telephone" type="telephone"/&gt;
   &lt;xs:element name="mobile" type="mobile"/&gt;
   &lt;xs:element name="email" type="xs:string"/&gt;
   &lt;xs:element name="account"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="username"/&gt;
      &lt;xs:element ref="password"/&gt;
      &lt;xs:element ref="userlevel"/&gt;
      &lt;xs:element ref="signupdate"/&gt; 
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="username" type="xs:string"/&gt;
   &lt;xs:element name="password" type="password"/&gt;
   &lt;xs:element name="userlevel" type="userlevel"/&gt;
   &lt;xs:element name="signupdate" type="xs:dateTime"/&gt;
  
   &lt;xs:element name="festival"&gt;
     &lt;xs:complexType&gt;
    &lt;xs:attribute name="id" type="xs:integer" user="optional"/&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="event"/&gt;
      &lt;xs:element ref="contact"/&gt; 
    &lt;/xs:sequence&gt;
     &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
  
   &lt;xs:element name="event"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="eventname"/&gt; 
      &lt;xs:element ref="url"/&gt;
      &lt;xs:element ref="datefrom"/&gt;
      &lt;xs:element ref="dateto"/&gt;
      &lt;xs:element ref="location"/&gt;
      &lt;xs:element ref="eventpostcode"/&gt;
      &lt;xs:element ref="coords"/&gt; 
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="eventname" type="xs:string"/&gt;
   &lt;xs:element name="url" type="xs:string"/&gt;
   &lt;xs:element name="datefrom" type="xs:date"/&gt;
   &lt;xs:element name="dateto" type="xs:date"/&gt;
   &lt;xs:element name="location" type="xs:string"/&gt;
   &lt;xs:element name="eventpostcode" type="postcode"/&gt;
   &lt;xs:element name="coords"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="lat"/&gt;
      &lt;xs:element ref="lng"/&gt; 
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="lat" type="xs:decimal"/&gt;
   &lt;xs:element name="lng" type="xs:decimal"/&gt;
   &lt;xs:element name="contact"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element ref="conname"/&gt;
      &lt;xs:element ref="conaddress1"/&gt;
      &lt;xs:element ref="conaddress2"/&gt;
      &lt;xs:element ref="concity"/&gt; 
      &lt;xs:element ref="concounty"/&gt;
      &lt;xs:element ref="conpostcode"/&gt; 
      &lt;xs:element ref="contelephone"/&gt;
      &lt;xs:element ref="conmobile"/&gt; 
      &lt;xs:element ref="fax"/&gt;
      &lt;xs:element ref="conemail"/&gt;  
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
   &lt;xs:element name="conname" type="xs:string"/&gt;
   &lt;xs:element name="conaddress1" type="xs:string"/&gt;
   &lt;xs:element name="conaddress2" type="xs:string"/&gt;
   &lt;xs:element name="concity" type="xs:string"/&gt;
   &lt;xs:element name="concounty" type="xs:string"/&gt;
   &lt;xs:element name="conpostcode" type="postcode"/&gt;
   &lt;xs:element name="contelephone" type="telephone"/&gt;
   &lt;xs:element name="conmobile" type="mobile"/&gt;
   &lt;xs:element name="fax" type="telephone"/&gt;
   &lt;xs:element name="conemail" type="xs:string"/&gt;
  &lt;/xs:schema&gt;
  </code></pre>