开发者

Java XMLInputFactory - truncates text when reading data with .getData()

开发者 https://www.devze.com 2023-01-21 21:40 出处:网络
I\'m using XMLInputFactory to read data (sql queries) from xml file. In some cases, the data is truncated. For example:

I'm using XMLInputFactory to read data (sql queries) from xml file.

In some cases, the data is truncated. For example:

select CASE WHEN count(*) > 0 THEN 'LX1VQMSSRV069 OK' ELSE 'LX1VQMSSRV069 NOK' END from [PIWSLog].[dbo].[log]

is read as (text is truncated after the last '.'):

select CASE WHEN count(*) > 0 THEN 'LX1VQMSSRV069 OK' ELSE 'LX1VQMSSRV069 NOK' END from [PIWSLog].[dbo]

I've tested with several string and it seems that the problem is with the char's in [].[].[]..

I'm readind data using:

mySQLquery = event.asCharacters().getData();

Another situation is if the string has '\n'. Like, if it has two '\n', the event.asCharacters().getData(); reads correctly, but if it has thr开发者_JAVA技巧ee '\n' it truncates the string after the second '\n'. This is very odd!

Any idea what's the problem and how can I solve it?


The XMLInputFactory API is not obliged to give you all of the characters of a String in one go. It's permitted to pass you a sequence of events, each containing a fragment of the string.

You'll probably find that if you read another event after the one containing the truncated string, you'll find the remainder of your string (possibly after several events).

0

精彩评论

暂无评论...
验证码 换一张
取 消