title: In-document schema declarations and lxml
body: <p>As per the official documentation of lxml, if one wants to validate a xml document against a xml schema document, one has to</p>
  
  <ol>
  <li>construct the XMLSchema object (basically, parse the schema document)</li>
  <li>construct the XMLParser, passing the XMLSchema object as its <code>schema</code> argument</li>
  <li>parse the actual xml document (instance document) using the constructed parser</li>
  </ol>
  
  <p>There can be variations, but the essense is pretty much the same no matter how you do it, - the schema is specified 'externally' (as opposed to specifying it inside the actual xml document).</p>
  
  <p>If you follow this procedure, the validation occurs, sure enough, but if I understand it correctly, that completely ignores the whole idea of the schemaLocation and noNamespaceSchemaLocation attributes from <a href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow noreferrer">xsi</a></p>
  
  <p>This introduces a whole bunch of limitations, starting with the fact, that you have to deal with instance&lt;->schema relation all by yourself (either store it externally or write some hack to retrieve the schema location from the root element of the instance document), you can not validate the document using multiple schemata (say, when each schema governs its own namespace) and so on.</p>
  
  <p>So the question is: maybe I am missing something completely trivial or doing it wrong? Or are my statements about lxml's limitations regarding schema validation true?</p>
  
  <p>To recap, I'd like to be able to:</p>
  
  <ul>
  <li>have the parser use the schema location declarations in the instance document at parse/validation time</li>
  <li>use multiple schemata to validate a xml document</li>
  <li>declare schema locations on non-root elements (not of extreme importance)</li>
  </ul>
  
  <p>Maybe I should look for a different library? Although, that'd be a real shame, - lxml is a de-facto xml processing library for python and is regarded by everyone as the best one in terms of performace/features/convenience (and rightfully so, to a certain extent)</p>