The data structure that is read or written to a data source is described by I/O elements and attributes. Elements can contain attributes and nested elements. A formatter interprets the arrangement of elements and attributes to generate a particular format, such as XML or CSV.
When a formatter writes an attribute's value, there are two ways the
attribute can get the value. First, it can name an iterator with the XML
iterator attribute. Each time the formatter writes the
attribute, the attribute will get the next value from the iterator. For
example:
<dm:iterator id="foo"/>
...
<dmio:attribute iterator="foo"/>
When getting values from an iterator, the attribute can also give a value of
true or false to the XML attribute named
current. If current is true, then the attribute
gets the iterator's current value. Otherwise it gets its next value. For
example:
<dm:iterator id="foo"/>
...
<dmio:attribute iterator="foo" current="true"/>
Second, an I/O attribute can take a value attribute, whose
value is a
dot-separated value name. Each time
the formatter writes the attribute, the attribute looks up the value by name
in the nearest enclosing I/O element. This scenario is used when an element
that contains the attribute
listens to an iterator, and gets a
set of values from the iterator when it fires a next event.
A value list can listen to an attribute, and get
values from it as they are read in. The next example reads strings from a
file named in.csv, and writes them to out.xml.
The contents of in.csv are:
data0,1
data1,2
data2,4
The XML configuration is:
<!-- values -->
<dm:values id="av"/>
<dm:values id="bv"/>
<!-- element -->
<dmio:element>
<dmio:file-reader path="in.csv"/>
<dmio:csv-format>
<dmio:attribute name="a">
<dm:listener listener="av" event="next" action="addValue"/>
</dmio:attribute>
<dmio:attribute name="b">
<dm:listener listener="bv" event="next" action="addValue"/>
</dmio:attribute>
</dmio:element>
Note: reading values into a values list is not currently implemented.