I notice that when using CSV data with segmented lines, I can only use <segment-value/>'s in the first column/field. In other words, I can only identify different line formats based on data in the first column/field of each line.
I can switch based on 'fmtX' fine, but not 'markerX'.
This is demonstrated with the following FlatToXml config file using the above data. As it stands now, this config file doesn't work. However, changing first segment definition to the following,
This turned out to be a bug in FlatFileConverter.handleSegmentedLine(). The line.substring(column, width) in the 'if' statement is incorrect, and should read line.substring(column, column + width). This is becase String.substring() takes a beginning and ending *index*, not a beginning index and length (see the JDK 1.4 JavaDoc). Making this change now properly recognizes patterns beyond the first character.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey,
I notice that when using CSV data with segmented lines, I can only use <segment-value/>'s in the first column/field. In other words, I can only identify different line formats based on data in the first column/field of each line.
For example, if my data looks like this,
fmt1,marker1,one,two,three
fmt2,marker2,three,four,five
I can switch based on 'fmtX' fine, but not 'markerX'.
This is demonstrated with the following FlatToXml config file using the above data. As it stands now, this config file doesn't work. However, changing first segment definition to the following,
<segment-column>1</segment-column>
<segment-width>4</segment-width>
<segment-value>fmt1</segment-value>
makes everthing work fine.
I *really* need to be able to select rows based on subsequent columns.
Any suggestions?
TIA,
-Mitch
<?xml version="1.0" encoding="UTF-8"?>
<conversion>
<header>
<output-document>
<root-element>order</root-element>
<row-element>not-applicable-here</row-element>
</output-document>
<input-document>
<conversion-type>segmented-line</conversion-type>
<line-ending>CR</line-ending>
<field-separator>,</field-separator>
</input-document>
</header>
<line-segments>
<segment>
<segment-name>header</segment-name>
<segment-column>5</segment-column>
<segment-width>7</segment-width>
<segment-value>marker1</segment-value>
<begin-group-name>Format1</begin-group-name>
<csv-fields>
<field>
<field-name>test1</field-name>
<field-number>3</field-number>
</field>
<field>
<field-name>test2</field-name>
<field-number>4</field-number>
</field>
<field>
<field-name>test3</field-name>
<field-number>5</field-number>
</field>
</csv-fields>
</segment>
<segment>
<segment-name>header</segment-name>
<segment-column>1</segment-column>
<segment-width>4</segment-width>
<segment-value>fmt1</segment-value>
<begin-group-name>Format2</begin-group-name>
<csv-fields>
<field>
<field-name>test1</field-name>
<field-number>3</field-number>
</field>
<field>
<field-name>test2</field-name>
<field-number>4</field-number>
</field>
<field>
<field-name>test3</field-name>
<field-number>5</field-number>
</field>
</csv-fields>
</segment>
</line-segments>
</conversion>
This turned out to be a bug in FlatFileConverter.handleSegmentedLine(). The line.substring(column, width) in the 'if' statement is incorrect, and should read line.substring(column, column + width). This is becase String.substring() takes a beginning and ending *index*, not a beginning index and length (see the JDK 1.4 JavaDoc). Making this change now properly recognizes patterns beyond the first character.
I've opened ticket #865397 for this issue.
Thanks
I will be fixing this now. Initially will be rolling fix into the HEAD branch in CVS
Bruce.