PDA

View Full Version : Problems with "schema" example...



Cyrano
22nd February 2010, 15:45
I was playing with the Qt example "schema" and I noticed that I receive a not well-formed error-description when I use an invalid xml-schema.

I explain better:

1. First of all I modified the example (just a little... I only replaced the "QTextBrowser" object with a "QTextEdit" object... in this way I can edit the schema too).

2. Then, I executed it and I used these simple xml-schema and xml-instance:

simple-xml-schema.xsd:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="contact">
</xsd:element>
</xsd:schema>


simple-xml-instance.xml:

<contact>
</contact>


3. If I modify the xml-schema in this way (now I want to use an invalid xml-schema):

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="contact"
</xsd:element>
</xsd:schema>

this is an invalid xml-schema and after the "load" function I receive this error-description:

<html xmlns='http://www.w3.org/1999/xhtml/'><body><p>Expected '>' or '/', but got '<'.</p></body></html>

According to the Qt documentation the error-description is an xhtml text... but this xhtml text is not well-formed (the text between <p> and </p> is not "escaped") and the QLabel in the example cannot show it properly...


4. If I introduce a similar mistake on the xml-instance I have a different behaviour... in this case the error-description is valid:

<contact
</contact>

this is an invalid xml-instance and after the "validate" function (using the valid xml-schema, of course) I receive this error-description:

<html xmlns='http://www.w3.org/1999/xhtml/'><body><p>Expected &apos;&gt;&apos; or &apos;/&apos;, but got &apos;&lt;&apos;.</p></body></html>

In this case the error-description is well formed (the text between <p> and </p> is "escaped") and the QLabel shows it properly...


Why the different behaviours? bug or my mistake?



P.S.1: sorry for the long message... I couldn't find a simpler way to explain my problem... heheh

P.S.2: I'm using the installation "qt-win-opensource-4.6.2-vs2008.exe" on a windows vista pc