cannot load xsd file that imports another xsd

  • Hi, i have to load an xml schema file to validate my xml file. I tried with Qt 5.8 and 5.10.1 (atm i have only those installed) and i have the same problems i'm gonna explain here. Here is the code i use to load the schema:

    QXmlSchema schema;
    QFile schemaFile("path_to_xsd");;
    if (schemaFile.isOpen())

    inside the xsd file i have an import statement like this:

    <xs:import namespace="" schemaLocation="xml.xsd"/>

    and here is the xml.xsd file:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="" xmlns:xs="" xml:lang="en">
    	<xs:attribute name="lang" type="xs:language">
    	<xs:attribute name="space" default="preserve">
    			<xs:restriction base="xs:NCName">
    				<xs:enumeration value="default"/>
    				<xs:enumeration value="preserve"/>
    	<xs:attributeGroup name="specialAttrs">
    		<xs:attribute ref="xml:lang"/>
    		<xs:attribute ref="xml:space"/>

    If i try to add those two xsd file as resources in my project and use a relative path, i noticed that in XsdSchemaParser::parseImport() function in qxsdschemaparser.cpp at line 683 the assert


    fails because m_documentURI is not setted then not valid.
    I tried to use absolute paths both in c++ code and xml import statement (schemaLocation). The assert above is not executed, but when the parseImport() function tries to parse the xml.xsd file, it fails because of "Premature end of Document".
    Is there something i did wrong? Any suggestion?

  • Lifetime Qt Champion


    Can you provide a minimal compilable example that illustrate that behaviour ?

Log in to reply