S
stacey
Hello everyone,
I am using SaxParser, to parse an xml document, and i noticed that
sometimes it ignores some data, while reading the characters inside an
element.
What i mean is:
My xml file includes many instances of the following structure:
<pk>
<absi>769.9541477864069</absi>
<area>170.0227589457148</area>
<background>0.0000000000000000</background>
<chisq>1202.267500954470</chisq>
<goodn>1607.355201650164</goodn>
<ind>1106.121302500338</ind>
<lind>1082.000000000000</lind>
<mass>922.4428373952809</mass>
<meth>4</meth>
<reso>5700.586009913091</reso>
<rind>1256.000000000000</rind>
<s2n>6.073893519996163</s2n>
<type>0</type>
</pk>
My java code is quite big, but i debugged it, and i saw that the
problem is in the function characters.
The function characters:
public void characters(char buf[], int offset, int len) throws
SAXException {
String s = new String(buf, offset, len);
The s string sometimes is not as big as it should. Can we define the
offset and the len?
The problem is when it reaches the <mass> element. Sometimes it works
ok, and it reads all the number 922.4428373952809.
But other times, when let say the mass value is 1455.668578151738,
the result is just 14 .
Do you have any idea what is the error?? I can post my code, but i
didn't do it know cause this post is already too big. Maybe someone
has already encountered the error..
I would appreciate any help.
Thank you very very much,
Stacey
PS:
I have many files like this, and i have noticed that my output files
have a similar structure. Fault every four lines for some time and
then it correct. :
922.4428373952809 769.9541477864069
927.4953784899038 37191.92095290756
933.5252259507145 8110.517189035567
940.4653099147753 9868.125486196035
941.518898 4381.813320162202 <------------ we
lose some numbers
947.5404155021193 2787.439831966368
954.4881638784998 392.1130341071628
965.4569335866441 1401.545504962355
978.4210869646715 438.9369494573742
984.4917 886.1359194417274 <------------ we
lose more numbers
1003.550150977367 497.0759433683916
1017.529625718612 3169.151170705610
1055.582684542875 4943.314163415449
1066.107033179408 443.6729762946884
1074.5 3354.853245126279 <------------ we
lose more numbers
1076.531768475310 646.8024403962839
1083.527120777254 498.7760684249872
1311.697689088619 16369.00024571709
1325.729755074315 287.2714228497898
1349 637.2393867567375 <------------
the number now is integer (error)
1373.598186480195 223.2986354292584
1385.548026377931 431.7554665051648
1387.553176811347 268.0273520356520
1443.594333307889 1317.685936747487
14 661.7093703067692 <------- It
should have read: 1455.668578151738
1457.610697327313 768.3194420301912
1467.786043204199 3468.484434990418
1546.734272041830 565.9503240406932
1552.544423206343 610.4527352860962
1566.639317869258 308.7611649665076
1575.708923737670 1524.695259940473
(the rest of the file is ok)
I am using SaxParser, to parse an xml document, and i noticed that
sometimes it ignores some data, while reading the characters inside an
element.
What i mean is:
My xml file includes many instances of the following structure:
<pk>
<absi>769.9541477864069</absi>
<area>170.0227589457148</area>
<background>0.0000000000000000</background>
<chisq>1202.267500954470</chisq>
<goodn>1607.355201650164</goodn>
<ind>1106.121302500338</ind>
<lind>1082.000000000000</lind>
<mass>922.4428373952809</mass>
<meth>4</meth>
<reso>5700.586009913091</reso>
<rind>1256.000000000000</rind>
<s2n>6.073893519996163</s2n>
<type>0</type>
</pk>
My java code is quite big, but i debugged it, and i saw that the
problem is in the function characters.
value, and i write them in a file.From every of the above structures i want to get the absi and mass
The function characters:
public void characters(char buf[], int offset, int len) throws
SAXException {
String s = new String(buf, offset, len);
The s string sometimes is not as big as it should. Can we define the
offset and the len?
The problem is when it reaches the <mass> element. Sometimes it works
ok, and it reads all the number 922.4428373952809.
But other times, when let say the mass value is 1455.668578151738,
the result is just 14 .
Do you have any idea what is the error?? I can post my code, but i
didn't do it know cause this post is already too big. Maybe someone
has already encountered the error..
I would appreciate any help.
Thank you very very much,
Stacey
PS:
I have many files like this, and i have noticed that my output files
have a similar structure. Fault every four lines for some time and
then it correct. :
922.4428373952809 769.9541477864069
927.4953784899038 37191.92095290756
933.5252259507145 8110.517189035567
940.4653099147753 9868.125486196035
941.518898 4381.813320162202 <------------ we
lose some numbers
947.5404155021193 2787.439831966368
954.4881638784998 392.1130341071628
965.4569335866441 1401.545504962355
978.4210869646715 438.9369494573742
984.4917 886.1359194417274 <------------ we
lose more numbers
1003.550150977367 497.0759433683916
1017.529625718612 3169.151170705610
1055.582684542875 4943.314163415449
1066.107033179408 443.6729762946884
1074.5 3354.853245126279 <------------ we
lose more numbers
1076.531768475310 646.8024403962839
1083.527120777254 498.7760684249872
1311.697689088619 16369.00024571709
1325.729755074315 287.2714228497898
1349 637.2393867567375 <------------
the number now is integer (error)
1373.598186480195 223.2986354292584
1385.548026377931 431.7554665051648
1387.553176811347 268.0273520356520
1443.594333307889 1317.685936747487
14 661.7093703067692 <------- It
should have read: 1455.668578151738
1457.610697327313 768.3194420301912
1467.786043204199 3468.484434990418
1546.734272041830 565.9503240406932
1552.544423206343 610.4527352860962
1566.639317869258 308.7611649665076
1575.708923737670 1524.695259940473
(the rest of the file is ok)