Hi Scott, Thanks for reply, I've attached simple program and xml file. -----Original Message----- From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Wednesday, October 07, 2009 12:40 PM To: HTTPAPI and FTPAPI Projects Subject: Re: XML_Parse ended in error Hello Vlad, Vladimir Vayntraub wrote: > It takes a dump on statement 2433 in EXPAT in "C" Module "XMLPARSE.C" on > character data handling routine. In my copy of EXPAT, line 2433 is a comment. Please don't post a line number, that's not useful information. Instead provide a program -- the simplest possible program -- that demonstrates the problem you are having. This should be a program that I can take and run on my computer with a minimum of effort. I've already tried parsing the XML file you attached to your e-mail, and it parsed for me (in HTTPAPI) with absolutely no errors or problems. > May be there's field size issue. It's not a field size issue. I've parsed fields that are megabytes long in a single XML element. Instead of taking random stabs at the problem, please provide some real information. I don't want to play 20 guesses. Show me how to reproduce the problem. ----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('QC2LE':'HTTPAPI')
?**-------------------------------------------------------------------------
/copy libhttptst/qrpglesrc,httpapi_h
/copy libhttptst/qrpglesrc,ifsio_h
/copy libhttptst/qrpglesrc,errno_h
/copy libhttptst/qrpglesrc,expat_h
?**----------------------------------------------------------------
d
d start@ PR
d data * value
D elem * value
D attr * dim(32767) options(*varsize)
D end PR
D data * value
D elem * value
D chardata PR
D data * value
D string 65535A const options(*varsize)
D len 10I 0 value
D QDCXLATE PR extpgm('QDCXLATE')
D len 5P 0 const
D data 32702A options(*varsize)
D table 10A const
D blanks s 132A
D Buff s 8192A
D PrintMe s 132A varying
D stack s 50A varying dim(50)
D Depth s 10I 0
D fd s 10I 0
D p s like(XML_Parser)
D len s 10I 0
D done s 10I 0
D x s 10I 0
d @file_name s 100a inz(*blanks)
d rc s 10I 0
d @xml s 1500a inz(*blanks)
d Qs c ''''
d No# s 4 0 inz(*zeros)
d ##X s 4 0 inz(*zeros)
/free
? //-----------------------------------------------
@file_name = *blanks;
@file_name = '/tmp/test.xml';
//
// Open XML document to parse
fd = open(%trim(@file_name): O_RDONLY);
if (fd < 0);
@xml = *blanks;
return;
endif;
//
// Create a "parser object" in memory that
// will be used to parse the document.
//
p = XML_ParserCreate(*NULL);
if (p = *NULL);
callp close(fd);
@xml = *blanks;
return;
endif;
//
// Register subprocedures to be called for the
// starting and ending elements of an XML document
//
XML_SetStartElementHandler(p: %paddr(start@));
XML_SetEndElementHandler(p: %paddr(end));
XML_SetCharacterDataHandler(p: %paddr(chardata));
//
// The following loop will read data from the XML
// document, and feed it into the XML parser
//
// The parser will call the "start" and "end"
// as the correct data is fed to it, and they'll
// create the outline.
//
dou (done = 1);
len = read(fd: %addr(Buff): %size(Buff));
if (len < 1);
done = 1;
endif;
if (XML_Parse(p: Buff: len: done) = XML_STATUS_ERROR);
callp close(fd);
@xml = *blanks;
return;
endif;
enddo;
//
// Done parsing... clean up!
//
XML_ParserFree(p);
callp close(fd);
return;
/end-free
P start@ B
D start@ PI
D data * value
D elem * value
D attr * dim(32767) options(*varsize)
D elemName s 50A
/free
depth = depth + 1;
elemName = %str(elem);
QDCXLATE( %len(%trimr(elemName))
: elemName
: 'QTCPEBC' );
stack(depth) = %trimr(elemName);
/end-free
P E
P end B
D end PI
D data * value
D elem * value
/free
depth = depth - 1;
/end-free
P E
P chardata B
D chardata PI
D data * value
D string 65535A const options(*varsize)
D len 10I 0 value
D x s 10I 0
D val s 132A
D newval s 132A varying
/free
if (len < 1);
return;
endif;
val = %subst(string:1:len);
QDCXLATE( len
: val
: 'QTCPEBC' );
newval = '';
for x = 1 to len;
if ( %subst(val:x:1) >= x'40' );
newval = newval + %subst(val:x:1);
endif;
endfor;
if (%len(newval)<1 or newval = *blanks);
return;
endif;
printme = stack(depth) + '|' + newval; //-- changed to '|' and it wa
if @xml <> *blanks;
@xml = %trim(@xml) + ',' + %trim(printme);
else;
@xml = %trim(@xml) + %trim(printme);
endif;
/end-free
P E
/define ERRNO_LOAD_PROCEDURE
/copy libhttptst/qrpglesrc,errno_h
Attachment:
test.xml
Description: application/xml
----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------