On Fri, Jan 23, 2009 at 1:08 PM, Gunaranjan Chandraraju <
chandrar...@apple.com> wrote:
>
> <record>
> <coreInfo id="123" , .../>
> <address street="XYZ1" State="CA" ...type="home" />
> <address street="XYZ2" state="CA" ... type="Office"/>
> <address street="XYZ3" state="CA" ....type="Other"/>
> </record>
>
> I have setup my DIH to treat these as entities as below
>
> <dataConfig>
> <dataSource type="FileDataSource" encoding="UTF-8" />
> <document>
> <entity name ="f" processor="FileListEntityProcessor"
> baseDir="***"
> fileName=".*xml"
> rootEntity="false"
> dataSource="null" >
> <entity
> name="record"
> processor="XPathEntityProcessor"
> stream="false"
> forEach="/record"
> url="${f.fileAbsolutePath}">
> <field column="ID" xpath="/record/@id" />
>
> <!-- Address -->
> <entity
> name="record_adr"
> processor="XPathEntityProcessor"
> stream="false"
> forEach="/record/address"
> url="${f.fileAbsolutePath}">
> <field column="address_street"
> xpath="/record/address/@street" />
> <field column="address_state"
> xpath="/record/address//@state" />
> <field column="address_type"
> xpath="/record/address//@type" />
> </entity>
> </entity>
> </entity>
> </document>
> </dataConfig>
>
I think the only way is to create a dynamic field for each attribute
(street, state etc.). Write a transformer to copy the fields from your data
config to appropriately named dynamic field (e.g. street_1, state_1, etc).
To maintain this counter you will need to get/store it with
Context#getSessionAttribute(name, val, Context.SCOPE_DOC) and
Context#setSessionAttribute(name, val, Context.SCOPE_DOC).
I cant't think of an easier way.
--
Regards,
Shalin Shekhar Mangar.