Skip to content

XAware Open Source Data Integration

You are here: Home arrow Forums
XAware Community Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Re:How to write multiple format fixed length file (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:How to write multiple format fixed length file
#2958
prichards (User)
XAware user
Posts: 104
User Offline Click here to see the profile of this user
Re:How to write multiple format fixed length file 2 Months, 1 Week ago Karma: 13  
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.
File Attachment:
File Name: FileWrite.zip
File Size: 3134
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
      Topics Author Date
    thread link
How to write multiple format fixed length file
sanjeev.khare 2008/10/24 00:17
    thread link
thread linkthread link Re:How to write multiple format fixed length file
prichards 2008/10/27 11:16
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Community Login

Polls

What best describes your current or next project that will include data services?
 

Visit XAware.com