XML output generation

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

XML output generation

Post by velagapudi_k »

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.
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First suggestion would be to import the metadata from an xsd if at all possible, not from the xml itself. That can help tremendously.
-craig

"You can never have too many knives" -- Logan Nine Fingers
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Craig thanks for the reply. I dont know a lot about xml stuff. Can I generate an xsd from a sample xml file?
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Perhaps, but it stands a very good chance of being incomplete or incorrect. Request the xsd from whomever you are generating the xml for, your external vendor in this case.
-craig

"You can never have too many knives" -- Logan Nine Fingers
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Craig, I have a .DTD file. Will that help? If yes pls help me to import metadata from it. Meanwhile, I will ask for the xsd file.
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's pretty old school. If you generated it from the xml, I'd be inclined to not use it. Best to get the xsd and use that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

No craig I didnt generate it from the XML. I got it from the vendor. He asked to use it for validation of xml once it is generated.
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... they're not going to give you an xsd? :roll:

Point the importer to your dtd file, pretty sure it will accept that. Import the metadata in the same manner as you did before.
-craig

"You can never have too many knives" -- Logan Nine Fingers
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Craig
I asked for the xsd.
When I am trying to use the dtd file it is throwing me an error.

The file specified was not recognized as a valid xml or xml schema document.
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then unfortunately it sounds like you'll need to wait for the xsd.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

As noted before, DTD's are pretty much "old school" nowadays. The new XMLPack doesn't support them. The old xml meta data importer for the old stages (which are now deprecated) supported them, but I wouldn't advise going back to those -- the new Stages are much better. Find yourself a copy of XMLSpy or other products that support DTD to XSD translation, and then import that. It may not be perfect, but it should be close, depending on the complexity of the DTD.

..or, just import the meta data via the XML instance document itself. It will work, but you risk missing columns that aren't in the XML document you used for import, and all the datatypes will be varchar 255 instead of more realistic values.

Ernie
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hey Ernie - there's a new TV show that at first I thougt was about you. It's called "Thank God You're Here!".

:D
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

of course, I should first have looked at the original problem. Sorry. Hard to say "exactly" what you need to do, but it sounds like you are most of the way there already --- it sounds as though these are like mutually exclusive record types (filtered somehow?) if you are today using three separate jobs. Putting the logic for all three together in the same job is not easy, but it's not impossible. I'll look again to consider how you might do it all in one stage, but the general idea is to handle it the same as we would if you had dramatically different sections of a single document (ie..repeating groups for multiple mailing addresses in a Purchase Order and another with line items). Generate "chunks" of XML instead of whole documents, and then feed the finished content from the XML stage into a temporary holding location, such as an rdbms or hash table if you are using Server....then pick up the pre-finished "chunks" of XML via lookups....once they are on the same row, they can be brought back together into a single XML document with one more use of the XMLOutput Stage..... this is fairly well documented in the best practices doc that is referenced in many places on this forum.

Ernie
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You are too funny. Thank goodness that "I'm" here? How many posts do I have compared to some of you true heros on this forum? :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

eostic wrote:this is fairly well documented in the best practices doc that is referenced in many places on this forum.
Available at Kim Duke's website for download. Operators are standing by.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply