Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. cannot load xsd file that imports another xsd
Forum Update on Monday, May 27th 2025

cannot load xsd file that imports another xsd

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 635 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rigu10
    wrote on last edited by
    #1

    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");
    schemaFile.open(QIODevice::ReadOnly);
    if (schemaFile.isOpen())
        schema.load(&schemaFile);
    

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

    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
    

    and here is the xml.xsd file:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
      <xs:annotation>
    		<xs:documentation></xs:documentation>
    	</xs:annotation>
    	<xs:attribute name="lang" type="xs:language">
    		<xs:annotation>
    			<xs:documentation></xs:documentation>
    		</xs:annotation>
    	</xs:attribute>
    	<xs:attribute name="space" default="preserve">
    		<xs:simpleType>
    			<xs:restriction base="xs:NCName">
    				<xs:enumeration value="default"/>
    				<xs:enumeration value="preserve"/>
    			</xs:restriction>
    		</xs:simpleType>
    	</xs:attribute>
    	<xs:attributeGroup name="specialAttrs">
    		<xs:attribute ref="xml:lang"/>
    		<xs:attribute ref="xml:space"/>
    	</xs:attributeGroup>
    </xs:schema>
    

    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

    Q_ASSERT(m_documentURI.isValid());
    

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved