Hello DFDL community!
I am creating a DFDL schema to parse dBase files.
A dBase file consists of a list of records. Each record consists of a list of
fields. Prior to the list of records is a header which describes each record
field: the field's name, the length of the field's value, and its datatype
(string, date, numeric, boolean, etc.). For example, I have a dBase file
containing railway data and the file looks like this (albeit in binary):
Field-descriptor-array
Field
name: station-name
length: 254
datatype: string
Field
name: line
length: 100
datatype: string
Field
name: isActive
length: 1
datatype: boolean
Here is a record:
Van Dorn Street
blue
T
Ideally, parsing the dBase file would yield this XML:
<record>
<station-name>Van Dorn Street</station-name>
<line>blue</line>
<isActive>true</isActive>
</record>
However, that requires element names be dynamically generated, which is not
currently supported. So, instead I can design the DFDL schema to generate this
XML:
<record>
<field>Van Dorn Street</field>
<field>blue</field>
<field>true</field>
</record>
That will require the DFDL schema to calculate the number of <field> elements:
<xs:element name="field"
minOccurs="0"
maxOccurs="unbounded"
dfdl:occursCountKind="expression"
dfdl:occursCount="count{../../Field-descriptor-array/Field}"
...
Does this seem reasonable thus far?
Now I am stuck: how to specify the length and the datatype of each field
element? The i'th <field> element must have a length and datatype as specified
in the i'th Field (which are in the header section). For the example above, the
first <field> element must be a string with length 254 characters, the second
<field> element must be a string with length 100 characters, and the third
<field> element must be a boolean with length 1 byte. How do I dynamically
specify length and datatype?
/Roger