Hi Folks, I am creating a DFDL schema for the CSV format as defined in RFC 4180.
I have learned that a CSV file may or may not have a header record. I have learned that each record is separated by a newline and the last record may or may not have a new line. My DFDL Schema is working great except when the last record contains a newline. With this input: [cid:[email protected]] I get this XML: <csv> <record> <field>1997</field> <field>Ford</field> <field>E350</field> <field>ac, abs, moon</field> <field>2999.99</field> </record> <record> <field>1999</field> <field>Chevy</field> <field>Venture Extended Edition</field> <field>4900.00</field> </record> <record> <field>1999</field> <field>Chevy</field> <field>Venture Extended Edition</field> <field>Very Large</field> <field>5000.00</field> </record> <record> <field>1996</field> <field>Jeep</field> <field>Grand Cherokee</field> <field>MUST SELL! air, moon roof, loaded</field> <field>4799.00</field> </record> <record> <field></field> </record> </csv> Notice the last <record> element has just one <field> element and it is empty. I don't want that last record. I tried specifying in the declaration for the field element that dfdl:indexOccurs must be greater than 0 but that didn't help. See below. What's the solution, please? I've attached the TDML file. /Roger <xs:element name="field" maxOccurs="unbounded" type="xs:string" dfdl:escapeSchemeRef="Quotes" dfdl:occursCountKind="implicit"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:assert test="{ dfdl:occursIndex() gt 0 }" message="{'If the last record is empty, then no fields should be generated'}" /> </xs:appinfo> </xs:annotation> </xs:element>
csv.tdml.xml
Description: csv.tdml.xml
