473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Expat 1.95.8 fails on XML with newline

I saw something similar on the sourceforge bugs list but it was from
2001 so I assume it's fixed by now.

O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6.

I have the following XML (simplified for discussion purposes) The XML
starts and ends with the braces.

{

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>}

NOTICE the newline(0A) at the beginning of the file. Now I use the
following C++ code to read from the XML file:

do
{
size_t len = fread(buf, 1, sizeof(buf), xmlfile);
done = len < sizeof(buf);
if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
{
return ReturnLua(State, 1, "Error while parsing.");
}
} while (!done);

This works mint on all other XML files, but not with that one. This is
how the XML file is returned to me by a SOAP server. What happens is
that on first pass through the while loop, XML_Parse doesn't even go
into the functions previously set, it instantly returns
XML_STATUS_ERROR, and the rest is history.

I would like to know if the error is in my file reading code or an
Expat bug. If it is the latter, is there a patch or quick fix? And if
it is my code, then what could I do to strip the initial newline(s)?

Thanks in advance!

Jeff Lambert
Jul 20 '05 #1
4 2403
Jeff Lambert wrote:
{

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>}

NOTICE the newline(0A) at the beginning of the file.


This is not allowed. Nothing is allowed prior to the XML declaration.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jul 20 '05 #2

NOTICE the newline(0A) at the beginning of the file. Now I use the
following C++ code to read from the XML file:

That makes the file not well formed, so any parser should reject it.
harsh but fair:-)

David
Jul 20 '05 #3
Jeff Lambert wrote:
I saw something similar on the sourceforge bugs list but it was from
2001 so I assume it's fixed by now.

O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6.

I have the following XML (simplified for discussion purposes) The XML
starts and ends with the braces.

{

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>}

NOTICE the newline(0A) at the beginning of the file. Now I use the
following C++ code to read from the XML file:

do
{
size_t len = fread(buf, 1, sizeof(buf), xmlfile);
done = len < sizeof(buf);
if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
{
return ReturnLua(State, 1, "Error while parsing.");
}
} while (!done);

This works mint on all other XML files, but not with that one. This is
how the XML file is returned to me by a SOAP server. What happens is
that on first pass through the while loop, XML_Parse doesn't even go
into the functions previously set, it instantly returns
XML_STATUS_ERROR, and the rest is history.

I would like to know if the error is in my file reading code or an
Expat bug. If it is the latter, is there a patch or quick fix? And if
it is my code, then what could I do to strip the initial newline(s)?


The given sample XML file (with whitespace before the xml declaration)
is processed without errors in my build of XMLgawk with Expat 1.95.8 on
Windows XP. You can find the sources at:

http://home.vrweb.de/~juergen.kahrs/gawk/XML/

You can download the source of "XMLpuller" and look how it uses Expat.

NOTE: I work in Windows, but I've tested the input file with both Unix
(LF) and Windows (CR+LF) newlines.
--
To reply by e-mail, please remove the extra dot
in the given address: m.collado -> mcollado

Jul 20 '05 #4
Jeff Lambert wrote:
I saw something similar on the sourceforge bugs list but it was from
2001 so I assume it's fixed by now.

O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6.

I have the following XML (simplified for discussion purposes) The XML
starts and ends with the braces.

{

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>}

NOTICE the newline(0A) at the beginning of the file. Now I use the
following C++ code to read from the XML file:

do
{
size_t len = fread(buf, 1, sizeof(buf), xmlfile);
done = len < sizeof(buf);
if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
{
return ReturnLua(State, 1, "Error while parsing.");
}
} while (!done);

This works mint on all other XML files, but not with that one. This is
how the XML file is returned to me by a SOAP server. What happens is
that on first pass through the while loop, XML_Parse doesn't even go
into the functions previously set, it instantly returns
XML_STATUS_ERROR, and the rest is history.

I would like to know if the error is in my file reading code or an
Expat bug. If it is the latter, is there a patch or quick fix? And if
it is my code, then what could I do to strip the initial newline(s)?

Thanks in advance!

Jeff Lambert


Please disregard my previous (cancelled) post about correct processing
in Windows. I was wrong.

My apologies.
--
To reply by e-mail, please remove the extra dot
in the given address: m.collado -> mcollado

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Brown | last post by:
Python 2.3 comes with its own version of Expat. setup.py says it is Expat 1.95.2, but the code in Modules/expat seems to actually be Expat 1.95.6. It's really 1.95.6, right? -- Mike
1
by: Doug | last post by:
I am running solaris 7 on two machines. I compiled python 2.2.1 with expat parser on one machine. The python binary is located in /usr/local/bin and the libraries are located in /usr/local/lib. ...
1
by: Ingo Blank | last post by:
Hi, while 95% of my 'psycoed' applications run fine, it throws SIGSEGVs in conjunction with expat. Anybody noticed the same ? Python 2.3.2 (#4, Nov 13 2003, 02:10:49) on linux2 $ uname...
2
by: Thomas Guettler | last post by:
Hi! What are the difference between xml.parsers.expat and xml.sax? Up to now I used xml.sax.make_parser and subclass from ContentHandler. I think xml.sax.make_parser uses expat as default....
4
by: alainpoint | last post by:
Hello, I use Elementtree to parse an elementary SVG file (in fact, it is one of the examples in the "SVG essentials" book). More precisely, it is the fig0201.svg file in the second chapter. The...
1
by: David Madore | last post by:
Hi! Anyone in for a Byzantine discussion on XML well-formedness? Here's the situation: test.xml contains --- test.xml: cut after --- <?xml version="1.0" encoding="us-ascii"?> <!DOCTYPE...
4
by: Jakob Møbjerg Nielsen | last post by:
Expat keeps telling me that there is "junk after document element". I've tried different encoding, and I'm quite sure that the buffer is nul-terminated. I really have no idea to what the problem...
2
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program...
1
by: vadlapatlahari | last post by:
Hi, I get the following error with Expat while configuring my application server. Can anyone suggest a solution? When i do an ldd, i get the following : $ldd Expat.so Expat.so needs:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.