Closed GoogleCodeExporter closed 9 years ago
Sorry, but your English is a little hard to follow. Is the 'transacciones'
record supposed to be 150 or 240 characters in length? If 150, you may need to
put minLength="150" on that record definition.
Original comment by kevin.s...@gmail.com
on 12 Feb 2013 at 2:42
Hello Kevin,
I'm Sorry, my English is not good, the problem is that there is an error when
it tries to process a record 250 of 150 characters to another, for example I
have the following stream.
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="stream" format="fixedlength" strict="true">
<record name="record1" class="map" occurs="0+">
<field name="record" length="240" type="string" />
</record>
<record name="record2" class="map" occurs="2">
<field name="record" length="150" type="string" />
</record>
</stream>
</beanio>
Then using a code like the following:
import java.io.InputStreamReader;
import org.beanio.BeanReader;
import org.beanio.StreamFactory;
public class Test {
public static void main(String[] args) throws Exception {
StreamFactory factory = StreamFactory.newInstance();
factory.load(Test.class.getResourceAsStream("Stream.xml"));
BeanReader in = factory
.createReader(
"stream",
new InputStreamReader(
Test.class
.getResourceAsStream("ExtractoCuentaAhorrosPlanoAmpliada.txt")));
while (in.read() != null) {
}
in.close();
}
}
BeanIO throws the following stack trace:
Exception in thread "main" org.beanio.InvalidRecordException: Invalid 'record1'
record at line 1109
==> Invalid record length, expected minimum 240 characters
at org.beanio.internal.parser.UnmarshallingContext.validate(UnmarshallingContext.java:196)
at org.beanio.internal.parser.BeanReaderImpl.internalRead(BeanReaderImpl.java:105)
at org.beanio.internal.parser.BeanReaderImpl.read(BeanReaderImpl.java:64)
at Test.main(Test.java:18)
In line 1109 begins to use a record of 150 characters, but BeanIO throws
InvalidRecordException, if you see the stream, the last two records must be 150
characters.
Original comment by andress...@gmail.com
on 12 Feb 2013 at 4:44
Attachments:
Hello,
That is expected behavior. Without any record identifying criteria defined,
"record1" will continue to match because there is no finite maximum
occurrences. You either need to add a record identifying field (i.e.
rid="true") to the record, or identify records based on their length. For
example, add ridLength="240" to record1 and ridLength="150" to record2
(assuming you are using BeanIO 2.0.3).
Thanks,
Kevin
Original comment by kevin.s...@gmail.com
on 12 Feb 2013 at 3:47
<?xml version='1.0' encoding='UTF-8' ?>
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="stream" format="fixedlength" strict="true">
<record name="record1" class="map" occurs="0+" ridLength="240">
<field name="record" length="240" type="string" />
</record>
<record name="record2" class="map" occurs="2" ridLength="150">
<field name="record" length="150" type="string" />
</record>
</stream>
</beanio>
Wow!, BeanIO is amazing!, congratulations, great work, you saved my project,
thank you very much.
Andrés Sánchez Lozano.
Original comment by andress...@gmail.com
on 13 Feb 2013 at 2:02
Original issue reported on code.google.com by
andress...@gmail.com
on 9 Feb 2013 at 9:04Attachments: