You should be able to use the
xa:merge_template in the File BizComp to "drill down" and call another File BizComp. The example
writeDelim_multipleFiles.xbd in XAware Designer
File -> New -> Example... -> BizComponent Examples -> File BizComponent Examples shows how this works.
However, it appears that this is not currently supported for the File BizComp when writing Fixed data or
XML (see XAware Tracker
#2201029). It may be possible to call another File BizComponent in the
xa:column_map, but it might not write the results in the order that you need.
Another way to iterate over your elements and call the appropriate File BizComp for each section, is to use an XML Mapper Bizcomp. You can pass
xa-input::/contact/data from your
BizDoc into the XML Bizcomp. Then you can call three different File BizComps, one to match each record type (B11, B12, and B13 in your example) passing the appropriate data into each File BC. For the first, you would pass
xa-results:: which is the current <data> element, and map the /data children in the File BC. For the second Bizcomp, you would pass
xa-results::./Child1 which are all of the <Child1> children of the current <data> element, and map the /Child1 fields in the second Bizcomp, and so forth. When calling the File Bizcomp, the
xa:input attribute will iterate over the matching structures and execute that many times (i.e. once for each <Child1> element or <Child2> element in the input reference). See the attached example.
Note: you don't have to return any data in the XML Mapper, but I mapped the "name" element in the results so you can see which records were written to the file. You could also use an
xa:map structure in the XML Mapper BC if you wanted to map additional fields for each repeating child element, or you could map the values directly if there is no more than 1 occurrence of each <Chilld1> for a given <data> element or each <Child2> for a given <Child1> element (see the XML Mapper Help and examples).
If there are 0 structures matching the input reference, then the File Bizcomp will not be executed. However, when there is an "optional" element in your input file structure, such as the Child1/Leaf2 element which is missing from the last record in your example, the mapping will result in a "substitution failure". You can write and apply a simple
Functoid on the field mapping, to check for an invalid value such as "StartsWith("%") and return either a valid value or an empty string, so that the substitution string is not mapped.