title: How to define a default value for an option element using XSD?
body: <p>What I like to do: I want to specify an option tag in the schema, for example:</p>
  
  <pre><code>&lt;xsd:element name="my_element" type="my_type" minOccurs="0" maxOccurs="1"/&gt;
  </code></pre>
  
  <p>If the element does not occur at all, there should be a default value for this parameter. Of course I could define this default value in my code, which calls the XML parser. But I think the correct place to specify the default value would be in the *.xsd schema file (since the default value is part of the interface defined by the schema).</p>
  
  <p>Unfortunately this does not seem to be easy. The "default" attribute has a different effect: "if it does not appear it is not provided; if it does appear and it is empty, its value is the default value" (from <a href="http://www.w3.org/TR/xmlschema-0/#ref36" rel="noreferrer">http://www.w3.org/TR/xmlschema-0/#ref36</a>).</p>
  
  <p>Other links I've found discussing this issue:</p>
  
  <ul>
  <li><a href="http://codesynthesis.com/pipermail/xsd-users/2006-February/000209.html" rel="noreferrer">http://codesynthesis.com/pipermail/xsd-users/2006-February/000209.html</a></li>
  <li><a href="http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#A" rel="noreferrer">http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#A</a></li>
  </ul>
  
  <p>Is there a solution to this problem? Or should I give up?</p>