Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Bug in xml parser?
Bug in xml parser? [message #27272] Fri, 09 July 2010 22:55 Go to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Hi,

I wonder if there is bug in xml parser because of the following problem.

I use XMLRPC package.
I debuged the package. I can see this.
The server returns an xml which something like this:

<value><string>line1\nline2\nline3\n</string></value>

The parser returns a string which is "line1\nline2\nline3" without the final \n.
My question is .. Is this bug if the xml parser does not return the final \n?

It looks so.

This is how I fixed it:
Add this line to xmlparser class definition:
void Preserve(bool b) { npreserve = b; }

Modified xmlrpc\client.cpp
This is the result of changes around line 65.

if(IsNull(response)) {
faultCode = XMLRPC_CLIENT_HTTP_ERROR;
faultString = server.GetError();
error = "Http request failed: " + faultString;
LLOG(error);
return ErrorValue(error);
}
XmlParser p(response);
p.Preserve(true); //<-- new line
try {





[Updated on: Sat, 10 July 2010 10:12]

Report message to a moderator

Re: Bug in xml parser? [message #27273 is a reply to message #27272] Sat, 10 July 2010 12:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Fri, 09 July 2010 16:55

Hi,

I wonder if there is bug in xml parser because of the following problem.

I use XMLRPC package.
I debuged the package. I can see this.
The server returns an xml which something like this:

<value><string>line1\nline2\nline3\n</string></value>

The parser returns a string which is "line1\nline2\nline3" without the final \n.
My question is .. Is this bug if the xml parser does not return the final \n?



Well, the problem is somewhat fuzzy...

Quote:


This is how I fixed it:
Add this line to xmlparser class definition:
void Preserve(bool b) { npreserve = b; }



I have implemented very similar fix, only instead of using npreserve I have used another bool attribute.

Mirek
Re: Bug in xml parser? [message #27291 is a reply to message #27273] Sun, 11 July 2010 08:11 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
What boolean attribute?


Re: Bug in xml parser? [message #27292 is a reply to message #27291] Sun, 11 July 2010 10:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Sun, 11 July 2010 02:11

What boolean attribute?





"attribute" is alternate name for "instance member variable"...

What about the proxy?

Mirek
Re: Bug in xml parser? [message #27551 is a reply to message #27292] Fri, 23 July 2010 10:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Sun, 18 July 2010 05:12

luzr wrote on Sun, 18 July 2010 10:03

aftershock wrote on Mon, 12 July 2010 12:27

I think this is the fix
void XmlParser::Next()
{
nattr.Clear();
nattr1 = nattrval1 = Null;
if(empty_tag) {
empty_tag = false;
type = XML_END;
return;
}
text.Clear();
type = XML_EOF;
if (!(npreserve || preserveall)) //<-- this should be added
SkipWhites();


The problem is the initial whitespace and EOL is thrown away which is not good.
Your other fix seems to be ok.

Have a good day!

Marton





Hi,

I had to revert this patch as it completely breaks any existing XML code.

I suggest you to send me some testcase demonstrating XML that needs XmlParser to be fixed, I will try to find some workaround.

Mirek

It was not my intention Really? How does it break them?

E.g
<value> myvalue</value>
This should return " myvalue" if it is read..


Marton



That is not a problem. The trouble is that when active, it will not skip any whitespaces in between tags, so:

<tag1>
   <tag2>


cannot be parsed with

   if(Tag("tag1") && Tag("tag2"))


as there is now Text element in between....

Sure, perhaps we might try to alter parser philosophy, but at this point I think that would be dangerous and we should try to find another solution first...

Mirek

(reposting back to forum to eventually gather more comments).
Re: Bug in xml parser? [message #28673 is a reply to message #27272] Sat, 11 September 2010 11:50 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Just one comment...
Parsing whitespace as text between tags is correct formally,right?


Re: Bug in xml parser? [message #28907 is a reply to message #28673] Sat, 25 September 2010 15:25 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Sat, 11 September 2010 05:50

Just one comment...
Parsing whitespace as text between tags is correct formally,right?





As I understand it, yes. But pain in the ass for any "normal" XML...
Previous Topic: navigate does not always work correctly
Next Topic: SliderCtrl max check
Goto Forum:
  


Current Time: Thu Mar 28 19:05:26 CET 2024

Total time taken to generate the page: 0.01170 seconds