sissaschool / xmlschema

XML Schema validator and data conversion library for Python
MIT License
421 stars 72 forks source link

unexpected (or inaccurate?) error message while validating #73

Closed giovannipizzi closed 6 years ago

giovannipizzi commented 6 years ago

I take a valid XML output of QE, ending in e.g.

      -9.386266261553111e-5 0.000000000000000e0 0.000000000000000e0
      0.000000000000000e0 -9.386266261553111e-5 0.000000000000000e0
      0.000000000000000e0 0.000000000000000e0 -9.386266261553111e-5
      </stress>
  </output>
  <status>0</status>
  <cputime>37</cputime>
  <closed DATE="16 Jul 2018" TIME="10:31:59"></closed>
</qes:espresso>

That validates correctly.

If I add a new extraneous tag something

      -9.386266261553111e-5 0.000000000000000e0 0.000000000000000e0
      0.000000000000000e0 -9.386266261553111e-5 0.000000000000000e0
      0.000000000000000e0 0.000000000000000e0 -9.386266261553111e-5
      </stress>
  </output>
  <status>0</status>
  <something>0</something>
  <cputime>37</cputime>
  <closed DATE="16 Jul 2018" TIME="10:31:59"></closed>
</qes:espresso>

the error I get seems to complain about the wrong tags (see below).

The same behaviour happens replacing a tag with a wrong one, and even just changing the order of e.g. status and cputime (is it expected that the order has to be preserved, by the way?)

Errors:

failed validating <Element '{http://www.quantum-espresso.org/ns/qes/qes-1.0}espresso' at 0x10f20a650> with XsdElement(name='input').

Reason: The child n.7 of element u'qes:espresso' has a unexpected tag 'cputime'. Tag 'input' expected.

Schema:

    <xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="input" type="qes:inputType" />

Instance:

  <ns0:espresso xmlns:ns0="http://www.quantum-espresso.org/ns/qes/qes-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Units="Hartree atomic units" xsi:schemaLocation="http://www.quantum-espresso.org/ns/qes/qes-1.0 http://www.quantum-espresso.org/ns/qes/qes-1.0.xsd">

  <general_info>
    <xml_format NAME="QEXSD" VERSION="0.1.0">QEXSD_0.1.0</xml_format>
    <creator NAME="PWSCF" VERSION="6.3MaX">XML file generated by PWSCF</creator>
    <created DATE="16Jul2018" TIME="10:31:59">This run was terminated on:  10:31:59  16 Jul 2018</created>
    <job />
  </general_info>
  <parallel_info>
    <nprocs>1</nprocs>
    <nthreads>1</nthreads>
    <ntasks>1</ntasks>
    <nbgrp>1</nbgrp>
    <npool>1</npool>
    <ndiag>1</ndiag>
  </parallel_info>
  <input>
    <control_variables>
      <title />
      <calculation>scf</calculation>
    ...
  </ns0:espresso>

and

failed validating <Element '{http://www.quantum-espresso.org/ns/qes/qes-1.0}espresso' at 0x10f20a650> with XsdElement(name='input').

Reason: The child n.8 of element u'qes:espresso' has a unexpected tag 'closed'. Tag 'input' expected.

Schema:

    <xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="input" type="qes:inputType" />

Instance:

  <ns0:espresso xmlns:ns0="http://www.quantum-espresso.org/ns/qes/qes-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Units="Hartree atomic units" xsi:schemaLocation="http://www.quantum-espresso.org/ns/qes/qes-1.0 http://www.quantum-espresso.org/ns/qes/qes-1.0.xsd">

  <general_info>
    <xml_format NAME="QEXSD" VERSION="0.1.0">QEXSD_0.1.0</xml_format>
    <creator NAME="PWSCF" VERSION="6.3MaX">XML file generated by PWSCF</creator>
    <created DATE="16Jul2018" TIME="10:31:59">This run was terminated on:  10:31:59  16 Jul 2018</created>
    <job />
  </general_info>
  <parallel_info>
    <nprocs>1</nprocs>
    <nthreads>1</nthreads>
    <ntasks>1</ntasks>
    <nbgrp>1</nbgrp>
    <npool>1</npool>
    <ndiag>1</ndiag>
  </parallel_info>
  <input>
    <control_variables>
      <title />
      <calculation>scf</calculation>
    ...
  </ns0:espresso>
brunato commented 6 years ago

Should be fixed in the new package release 1.0.2.