title: Schematron validation with lxml in Python: how to retrieve validation errors?
body: <p>I'm trying to do some Schematron validation with lxml. For the specific application I'm working at, it's important that any tests that failed the validation are reported back. The <a href="http://lxml.de/validation.html" rel="nofollow noreferrer">lxml documentation</a> mentions the presence of  the <code>validation_report</code> property object. I <em>think</em> this should contain the info I'm looking for, but I just can't figure out how work with it. Here's some example code that demonstrates my problem (adapted from <a href="http://lxml.de/validation.html#id2" rel="nofollow noreferrer">http://lxml.de/validation.html#id2</a>; tested with Python 2.7.4):</p>
  
  <pre class="lang-py prettyprint-override"><code>import StringIO
  from lxml import isoschematron
  from lxml import etree
  
  def main():
  
      # Schema
      f = StringIO.StringIO('''\
      &lt;schema xmlns="http://purl.oclc.org/dsdl/schematron" &gt;
      &lt;pattern id="sum_equals_100_percent"&gt;
      &lt;title&gt;Sum equals 100%.&lt;/title&gt;
      &lt;rule context="Total"&gt;
      &lt;assert test="sum(//Percent)=100"&gt;Sum is not 100%.&lt;/assert&gt;
      &lt;/rule&gt;
      &lt;/pattern&gt;
      &lt;/schema&gt;
      ''')
  
      # Parse schema
      sct_doc = etree.parse(f)
      schematron = isoschematron.Schematron(sct_doc, store_report = True)
  
      # XML to validate - validation will fail because sum of numbers
      # not equal to 100 
      notValid = StringIO.StringIO('''\
          &lt;Total&gt;
          &lt;Percent&gt;30&lt;/Percent&gt;
          &lt;Percent&gt;30&lt;/Percent&gt;
          &lt;Percent&gt;50&lt;/Percent&gt;
          &lt;/Total&gt;
          ''')
      # Parse xml
      doc = etree.parse(notValid)
  
      # Validate against schema
      validationResult = schematron.validate(doc)
  
      # Validation report (assuming here this is where reason 
      # for validation failure is stored, but perhaps I'm wrong?)
      report = isoschematron.Schematron.validation_report
  
      print("is valid: " + str(validationResult))
      print(dir(report.__doc__))
  
  main()
  </code></pre>
  
  <p>Now, from the value of <code>validationResult</code> I can see that the validation failed (as expected), so next I would like to know <em>why</em>. The result of the second print statement gives me:</p>
  
  <pre><code>['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__
  format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__get
  slice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mo
  d__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
   '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook
  __', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center',
   'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index
  ', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper',
  'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', '
  rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', '
  strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
  </code></pre>
  
  <p>Which is about as far as I'm getting, based on the documentation and <a href="https://stackoverflow.com/questions/10963206/schematron-report-issue-with-python-lxml">this related question</a>. Could well be something really obvious I'm overlooking?</p>