Error validating/parsing xml file against xsd with lxml/objectify in Python
<p>in Python/Django, I need to parse and objectify a file .xml according to a given XMLSchema made of three .xsd files referring each other in such a way:</p>
<p>schema3.xsd (referring schema1.xsd)</p>
<p>schema2.xsd (referring schema1.xsd)</p>
<p>schema1.xsd (referring schema2.xsd)</p>
<p><a href="https://github.com/perentix/lxml_multiple_xsd" rel="nofollow noreferrer">xml schemas import</a></p>
<p>For this I'm using the following piece of code which I've already tested being succesfull when used with a couple of xml/xsd files (where .xsd is &quot;standalone&quot; without refering others .xsd):</p>
<pre>
import lxml
import os.path
from lxml import etree, objectify
from lxml.etree import XMLSyntaxError

def xml_validator(request):

    # define path of files
    path_file_xml = '../myxmlfile.xml'
    path_file_xsd = '../schema3.xsd'    

    # get file XML
    xml_file = open(path_file_xml, 'r')
    xml_string = xml_file.read()
    xml_file.close()

    # get XML Schema
    doc = etree.parse(path_file_xsd)
    schema = etree.XMLSchema(doc)

    #define parser
    parser = objectify.makeparser(schema=schema)

    # trasform XML file
    root = objectify.fromstring(xml_string, parser)
    test1 = root.tag
    
    return render(request, 'risultati.html', {'risultato': test1})
</pre>
<p>Unfortunately, I'm stucked with the following error that i got with the multiple .xsd described above:</p>
<p><strong>complex type 'ObjectType': The content model is not determinist.</strong></p>
<blockquote>
<p>Request Method:   GET Request URL:    <a href="http://127.0.0.1:8000/xml_validator" rel="nofollow noreferrer">http://127.0.0.1:8000/xml_validator</a></p>
<p>Django Version:   1.9.1 Exception Type:   XMLSchemaParseError Exception</p>
<p>Value:     complex type 'ObjectType': The content model is not
determinist., line 80</p>
</blockquote>
<p>Any idea about that ?</p>
<p>Thanks a lot in advance for any suggestion or useful tips to approach this problem...</p>
<p>cheers</p>
<p><strong>Update 23/03/2016</strong></p>
<p>Here (and in the following answers to the post, because it actually exceed the max number of characters for a post),  a sample of the files to figure out the problem...</p>
<p><a href="https://github.com/perentix/lxml_multiple_xsd" rel="nofollow noreferrer">sample files on GitHub</a></p>