title: XML Schema How to Declare Price and Currency
body: <p>I'm creating an XML schema that stores information about houses.</p>
  <p>I want to store the <code>price</code> and the <code>currency</code>.</p>
  <p>It makes sense in my mind to declare this by having the currency as an attribute of the price element.</p>
  <p>Also, I want to restrict the values that can be entered as the <code>currency</code> to pounds, euros or dollars.</p>
  <p>EG:</p>
  <pre><code>&lt;price currency=&quot;euros&quot;&gt;10000.00&lt;/price&gt;
  </code></pre>
  <p>So at the moment I'm declaring this in my XML Schema as:</p>
  <pre><code>&lt;!-- House Price, and the currency as an attribute --&gt;
  &lt;xs:element name=&quot;price&quot;&gt;
      &lt;xs:complexType&gt;
          &lt;xs:attribute name=&quot;currency&quot;&gt;
              &lt;xs:simpleType&gt;
                  &lt;xs:restriction base=&quot;xs:string&quot;&gt;
                      &lt;xs:enumeration value=&quot;pounds&quot; /&gt;
                      &lt;xs:enumeration value=&quot;euros&quot; /&gt;
                      &lt;xs:enumeration value=&quot;dollars&quot; /&gt;
                  &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
          &lt;/xs:attribute&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  <p>The issue that I have with this:</p>
  <ul>
  <li><p>I'm not exactly sure if this will restrict the attribute element to <code>pounds, euros or dollars</code></p>
  </li>
  <li><p>I can't seem to specify a <code>type</code> on the price to a double, as I would like due to the error:</p>
  <blockquote>
  <p><code>Element 'price' has both a 'type' attribute and a 'anonymous type' child. Only one of these is allowed for an element.</code></p>
  </blockquote>
  </li>
  </ul>
  <p>Should I just keep it simple and declare them as separate elements:</p>
  <pre><code>&lt;price&gt;10000.00&lt;/price&gt;
  &lt;currency&gt;euros&lt;/currency&gt;
  </code></pre>
  <p>...or am I on the right path?</p>