You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by SonalG <gs...@gmail.com> on 2012/06/01 12:48:23 UTC

endElement called with junk characters

Hello,

I have overridden SAX parser methods startElement, endElement and
characters.
In characters method i am concatenating values since it may be called
multiple times.

My sample XML looks like following:

<?xml version="1.0" encoding="UTF-8"?>
<CDR>
        <CALL_TYPE>MOC</CALL_TYPE>
        <A_PTY>1</A_PTY>
        <B_PTY>2</B_PTY>
</CDR>
<CDR>
        <CALL_TYPE>MTC</CALL_TYPE>
        <A_PTY>2</A_PTY>
        <B_PTY>1</B_PTY>
</CDR>

I am treating the fields enclosed within <CDR></CDR> to be one record.
The problem I am facing is when the endElement is called for the first
</CDR>, it also immediately calls endElement again with junk characters
(there is no StartElement called).
And then it gives segmentation fault.
What I expect is it to call start element for the next <CDR>.

What could be the problem with the parser or handling of startElement and
endElement methods?
-- 
View this message in context: http://old.nabble.com/endElement-called-with-junk-characters-tp33944001p33944001.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: endElement called with junk characters

Posted by SonalG <gs...@gmail.com>.
Hi,

Thanks a lot! I will add the root element and additional code to handle
individual records within the root element.

Regards
Sonal


Alberto Massari-2 wrote:
> 
> Hi,
> I need to check about the second endElement call, but your XML is 
> invalid as it has two root elements. Did you set up Xerces to proceed 
> also in case of fatal errors?
> 
> Alberto
> 
> Il 01/06/2012 12:48, SonalG ha scritto:
>> Hello,
>>
>> I have overridden SAX parser methods startElement, endElement and
>> characters.
>> In characters method i am concatenating values since it may be called
>> multiple times.
>>
>> My sample XML looks like following:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <CDR>
>>          <CALL_TYPE>MOC</CALL_TYPE>
>>          <A_PTY>1</A_PTY>
>>          <B_PTY>2</B_PTY>
>> </CDR>
>> <CDR>
>>          <CALL_TYPE>MTC</CALL_TYPE>
>>          <A_PTY>2</A_PTY>
>>          <B_PTY>1</B_PTY>
>> </CDR>
>>
>> I am treating the fields enclosed within<CDR></CDR>  to be one record.
>> The problem I am facing is when the endElement is called for the first
>> </CDR>, it also immediately calls endElement again with junk characters
>> (there is no StartElement called).
>> And then it gives segmentation fault.
>> What I expect is it to call start element for the next<CDR>.
>>
>> What could be the problem with the parser or handling of startElement and
>> endElement methods?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/endElement-called-with-junk-characters-tp33944001p33944322.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: endElement called with junk characters

Posted by Alberto Massari <Al...@progress.com>.
Hi,
I need to check about the second endElement call, but your XML is 
invalid as it has two root elements. Did you set up Xerces to proceed 
also in case of fatal errors?

Alberto

Il 01/06/2012 12:48, SonalG ha scritto:
> Hello,
>
> I have overridden SAX parser methods startElement, endElement and
> characters.
> In characters method i am concatenating values since it may be called
> multiple times.
>
> My sample XML looks like following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <CDR>
>          <CALL_TYPE>MOC</CALL_TYPE>
>          <A_PTY>1</A_PTY>
>          <B_PTY>2</B_PTY>
> </CDR>
> <CDR>
>          <CALL_TYPE>MTC</CALL_TYPE>
>          <A_PTY>2</A_PTY>
>          <B_PTY>1</B_PTY>
> </CDR>
>
> I am treating the fields enclosed within<CDR></CDR>  to be one record.
> The problem I am facing is when the endElement is called for the first
> </CDR>, it also immediately calls endElement again with junk characters
> (there is no StartElement called).
> And then it gives segmentation fault.
> What I expect is it to call start element for the next<CDR>.
>
> What could be the problem with the parser or handling of startElement and
> endElement methods?


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org