What does the input message look like?
The XML - input message looks basicly like that:
<Delivery> <Company> <Agencies> <Agency> <Dossiers> <Dossier> <Products> <Product/> </Products> </Dossier> </Dossiers> </Agency> </Agencies> </Company> </Delivery>
Whereas the plural in the tag name indicates a 1-n relation, meaning under e.g. Agencies are multiple Agency elements.
What I plan is to create csv-files out of this xml-message. Each csv-file should hold a specific entity (like product or agency etc.)
From what I see there... it looks as though it should work... the file:outputStream is scoped around the Company fragment (openOnElement="Company") and the templating is applied on the Product fragment (applyOnElement="Product"), which is within the "Company" fragment.
If you could send an executable example based on either the ESB quickstart or Smooks example formats, then I could have a quick look.