pradeepsjsu / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 0 forks source link

If a stream defined structure repeats with maxOccurs="unbounded", the 2nd element in a group cannot be recognized #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?  If applicable, please provide a
mapping configuration and sample record input to recreate the problem.
1. Run the BeanIOVerifier as listed below.
2. See error: Exception in thread "main" org.beanio.UnexpectedRecordException: 
Unexpected record 'fileControl' at line 5
3. Comment out the open and close <group> tag in the BeanIOTest.xml and run 
BeanIOVerifier again. No errors.

What is the expected output? What do you see instead?
The structure defined by <stream> should be able to repeat itself when <group> 
is used.

What version of BeanIO are you using? What JDK version?
2.0.3. JDK 1.6.0_31

Please provide any additional information below.
========BeanIOVerifier.java=====
package fileBean;

import java.io.File;

import org.beanio.BeanReader;
import org.beanio.StreamFactory;

/**
 * @date Created on 2013-02-01
 */
public class BeanIOVerifier {
    private static String MAPPING_FILE = BeanIOVerifier.class.getPackage().getName().replace('.', '/') + "/BeanIOTest.xml";
    private static String INPUT_FILE = "BeanIOTest.txt";

    public static void main(String[] args) throws Exception {
        // create a BeanIO StreamFactory
        StreamFactory factory = StreamFactory.newInstance();
        // load the mapping file from the working directory
        factory.load(MAPPING_FILE);

        File currInputFile = new File(BeanIOVerifier.class.getResource(INPUT_FILE).toURI());
        BeanReader in = factory.createReader("test", currInputFile);

        Object record = null;
        while ((record = in.read()) != null) {
        }

        in.close();
        System.out.println("done");
    }
}
========End of BeanIOVerifier.java=====
========BeanIOTest.xml=====
<?xml version="1.0" encoding="UTF-8"?>

<beanio xmlns="http://www.beanio.org/2012/03">

    <stream name="test" format="fixedlength" strict="true" minOccurs="0" maxOccurs="unbounded">
        <group name="filegroup" order="1" minOccurs="0">
            <record name="fileHeader" order="1" minOccurs="1" maxOccurs="1" minLength="5" maxLength="5" class="map">
                <field name="recordType" length="5" rid="true" regex="1{5}" />
            </record>

            <record name="fileControl" order="2" minOccurs="0" maxOccurs="1" minLength="5" maxLength="5" class="map">
                <field name="recordType" length="5" rid="true" regex="8{5}" />
            </record>
        </group>

        <record name="blockFiller" order="3" minOccurs="0" minLength="5" maxLength="5" class="map">
            <field name="recordType" length="5" rid="true" regex="9{5}" />
        </record>
    </stream>
</beanio>
========End of BeanIOTest.xml=====
========BeanIOTest.txt=====
11111
88888
99999
11111
88888
99999
11111
99999
========End of BeanIOTest.txt=====

Original issue reported on code.google.com by hongqia...@gmail.com on 20 Feb 2013 at 7:25

GoogleCodeExporter commented 8 years ago
I also used the jar file fixed for issue 56 to test it. Same error was reported.

Original comment by hongqia...@gmail.com on 20 Feb 2013 at 7:35

GoogleCodeExporter commented 8 years ago
Thanks for the simple example.  I was able to easily reproduce it and am 
looking into it...

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 23 Feb 2013 at 4:16

GoogleCodeExporter commented 8 years ago
Fixed for 2.0.4, snapshot JAR attached.

Original comment by kevin.s...@gmail.com on 23 Feb 2013 at 5:06

Attachments:

GoogleCodeExporter commented 8 years ago
The new fix works perfect.  Thanks!

Original comment by hongqia...@gmail.com on 25 Feb 2013 at 3:16

GoogleCodeExporter commented 8 years ago

Original comment by kevin.s...@gmail.com on 6 Mar 2013 at 3:14