XML output generation
Posted: Mon Apr 16, 2007 8:57 am
Hi all, I have a question about xml generation. I need to generate an XML file for an external vendor every week which should have our organization hierarchy. The hierarchy we have is Region(parent)-->District(child)-->Store(child to district). The sample xml file is below
<?xml version="1.0" encoding="UTF-8"?>
<!-- Regions -->
<orgapiload>
<region org_cd="00010" org_level_cd="REGION" name="REGION 10 SOUTHEAST" locationname="USSTO">
<orgrel org_cd="USSTO" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</region>
<!-- Districts -->
<district org_cd="00001" org_level_cd="DISTRICT" name="DISTRICT 1 SO FL DAD" locationname="REGION 25 SOUTH">
<orgrel org_cd="00025" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</district>
<!-- Stores -->
<store org_cd="00001" org_level_cd="STORE" name="00001" locationname="LAUDERDALE LAKES,FL" address1="3301 N STATE RD" address2="# 7 LAKES MALL" city="LAUDERDALE LAKES" state="FL" zip="33319" phone1="9547336100" timezone_cd="EST">
<orgrel org_cd="00010" org_level_cd="DIST" eff_date="12/29/1986"/>
<status code="Active" eff_date="12/29/1986"/>
</store>
</orgapiload>
Generating the above xml is not a problem. when I am using the metadata importer, it is recognising all the organisation levels as I am using different reserve word for different organisation levels. See bold in the above xml.
But the desired output xml is below
<?xml version="1.0" encoding="UTF-8"?>
<!-- Regions -->
<orgapiload>
<entry org_cd="00010" org_level_cd="REGION" name="REGION 10 SOUTHEAST" locationname="USSTO">
<orgrel org_cd="USSTO" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Districts -->
<entry org_cd="00001" org_level_cd="DISTRICT" name="DISTRICT 1 SO FL DAD" locationname="REGION 25 SOUTH">
<orgrel org_cd="00025" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Stores -->
<entry org_cd="00001" org_level_cd="STORE" name="00001" locationname="LAUDERDALE LAKES,FL" address1="3301 N STATE RD" address2="# 7 LAKES MALL" city="LAUDERDALE LAKES" state="FL" zip="33319" phone1="9547336100" timezone_cd="EST">
<orgrel org_cd="00010" org_level_cd="DIST" eff_date="12/29/1986"/>
<status code="Active" eff_date="12/29/1986"/>
</entry>
</orgapiload>
When i am using the metadata importer to get the table defnition from the 2nd xml, its not recognising all the organization levels as I want the same reserve word for all the levels.
Right now I am acheiving the above xml by using 3 different jobs appending to the same file, but there is a lot of manual work to do after the jobs run, to acheive the desired xml.
Pls help me to acheive the above, if possible in one job. Any input is appreciated as I know going through this big post and understanding it takes a lot of time.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Regions -->
<orgapiload>
<region org_cd="00010" org_level_cd="REGION" name="REGION 10 SOUTHEAST" locationname="USSTO">
<orgrel org_cd="USSTO" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</region>
<!-- Districts -->
<district org_cd="00001" org_level_cd="DISTRICT" name="DISTRICT 1 SO FL DAD" locationname="REGION 25 SOUTH">
<orgrel org_cd="00025" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</district>
<!-- Stores -->
<store org_cd="00001" org_level_cd="STORE" name="00001" locationname="LAUDERDALE LAKES,FL" address1="3301 N STATE RD" address2="# 7 LAKES MALL" city="LAUDERDALE LAKES" state="FL" zip="33319" phone1="9547336100" timezone_cd="EST">
<orgrel org_cd="00010" org_level_cd="DIST" eff_date="12/29/1986"/>
<status code="Active" eff_date="12/29/1986"/>
</store>
</orgapiload>
Generating the above xml is not a problem. when I am using the metadata importer, it is recognising all the organisation levels as I am using different reserve word for different organisation levels. See bold in the above xml.
But the desired output xml is below
<?xml version="1.0" encoding="UTF-8"?>
<!-- Regions -->
<orgapiload>
<entry org_cd="00010" org_level_cd="REGION" name="REGION 10 SOUTHEAST" locationname="USSTO">
<orgrel org_cd="USSTO" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Districts -->
<entry org_cd="00001" org_level_cd="DISTRICT" name="DISTRICT 1 SO FL DAD" locationname="REGION 25 SOUTH">
<orgrel org_cd="00025" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Stores -->
<entry org_cd="00001" org_level_cd="STORE" name="00001" locationname="LAUDERDALE LAKES,FL" address1="3301 N STATE RD" address2="# 7 LAKES MALL" city="LAUDERDALE LAKES" state="FL" zip="33319" phone1="9547336100" timezone_cd="EST">
<orgrel org_cd="00010" org_level_cd="DIST" eff_date="12/29/1986"/>
<status code="Active" eff_date="12/29/1986"/>
</entry>
</orgapiload>
When i am using the metadata importer to get the table defnition from the 2nd xml, its not recognising all the organization levels as I want the same reserve word for all the levels.
Right now I am acheiving the above xml by using 3 different jobs appending to the same file, but there is a lot of manual work to do after the jobs run, to acheive the desired xml.
Pls help me to acheive the above, if possible in one job. Any input is appreciated as I know going through this big post and understanding it takes a lot of time.