google-code-export / gambas

Automatically exported from code.google.com/p/gambas
1 stars 0 forks source link

gambas3 XMLReader component generates wrong output (gambas2 was working fine) #352

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1) Describe the problem.

The gambas3 XMLReader generates the wrong output parsing a big(ger) XML file. 
In gambas2 it worked fine.

2) GIVE THE FOLLOWING INFORMATIONS (if they are appropriate):

Version: 3.3.3 and r5302 TRUNK both have it
Revision: r5302 (if you use a development version)
Operating system: Linux
Distribution: Ubuntu
Architecture: x86
GUI component: QT4
Desktop used: LXDE

3) Provide a little project that reproduces the bug or the crash.
The project for gambas2 and gambas3 is attached in the "TestXML23.tar". The 
output of gambas2 is "output2.txt" and for gambas3 it is "output3.txt".

4) If your project needs a database, try to provide it, or part of it.

5) Explain clearly how to reproduce the bug or the crash.

6) By doing that carefully, you have done 50% of the bug fix job!

IMPORTANT NOTE: if you encounter several different problems or bugs, (for
example, a bug in your project, and an interpreter crash while debugging
it), please create distinct issues!

Original issue reported on code.google.com by uAle...@gmail.com on 7 Nov 2012 at 7:25

Attachments:

GoogleCodeExporter commented 9 years ago
By default, the new XmlReader stops when encountering the end of an XML 
element. As a workaround, this behaviour can be modified by setting the 
appropriate reading flag :

   XmlR.ReadFlags[XmlReaderNodeType.EndElement] = False

This seems to fix the problem. But to my knowledge, the old XmlReader stopped 
on the end of an XML element too, so the default reading flag setting is good, 
and there should be no need to change it.

I will investigate ...

Original comment by adrien.p...@gmail.com on 8 Nov 2012 at 11:58

GoogleCodeExporter commented 9 years ago
Problem fixed in revision #5323, thanks.

Original comment by adrien.p...@gmail.com on 13 Nov 2012 at 9:32

GoogleCodeExporter commented 9 years ago
@Adrien:

Problem has ONLY CHANGED ... The output is still not the same as gambas2.

Original comment by uAle...@gmail.com on 13 Nov 2012 at 6:28

GoogleCodeExporter commented 9 years ago
I think I found the problem, but it comes from your code.
Here is the strange section : 

If CStr(XmlR.Node.value) = "" Then
   StrHeader[XmlR.Node.depth] = XmlR.Node.name
End If

If I understood well the other parts of your code, you want to add the node 
name to your array when the reader reads the beginning of an element. But the 
node value is not empty only when reading the beginning of an element (that 
worked "by chance" with Gambas 2), so it will change the array values, and the 
output is finally not correct.

One good and safe way to detect the beginning of an element is to check the 
value of the XmlReader.State property :

If XmlR.State = XmlReaderNodeType.Element Then
        StrHeader[XmlR.Node.depth] = XmlR.Node.name
End If

With this code, the output is finally correct (I checked it well this time ;) ).
Regards,
Adrien

Original comment by adrien.p...@gmail.com on 22 Nov 2012 at 4:13

GoogleCodeExporter commented 9 years ago
Thanks Adrien it works perfectly now (it also fixed the "bug" in my gambas2 
code - some unwanted xml output).

Original comment by uAle...@gmail.com on 25 Nov 2012 at 4:09