Parse xml which has hierarchical data

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Parse xml which has hierarchical data

Post by sheema »

Hi,

I have xsd which has 5 levels of hierarchy in that, in 8.1 i have used 5 xml input stages one after another to parse this XML. I have been trying to use the new XML stage in datastage 8.5 to parse the same XML.
Do i have to use 5 XML parser steps in the new XML stage. I am not able to figure out how to overcome this issue.Can some one please help me with this.
Thanks

Sheema
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

Can some one please throw some light on this issue.
Thanks

Sheema
elsont
Participant
Posts: 16
Joined: Wed Oct 08, 2008 1:20 am
Location: Chicago

Re: Parse xml which has hierarchical data

Post by elsont »

Try setting element of 5th level as KEY (repetition element).
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

I tried elsont's suggestion to set last level column as key.

I tried that using 3 levels(in xsd) of hierararchy, by setting one of the columns(Col1) in level 3 hierarchy as key . I see that in the Mapping section Col1 is mapped to some other column in level2 when i click auto map.So I am trying to manually select the correct column to map col1(which is in level 3), but i am getting the below error

CDIUI2820E The mapping is not applicable due to an invalid type conversion or difference in the source and target list dimensions.

All the columns in level1,level2 and level3 are of datatatype varchar so i assume that it is not invalid type conversion. Can some please help me with this issue.
Thanks

Sheema
saikir
Participant
Posts: 92
Joined: Wed Nov 08, 2006 12:25 am
Location: Minneapolis
Contact:

Post by saikir »

Hi,

Are you on DB2? I have just completed working on DB2 Pure XML and this really works great. Its lets you store the data as a XML data type natively in the DB and you write XPATH queries to parse the data. It is pretty simple with some learning. Here is a good document that explains it

http://www.google.com/url?sa=t&rct=j&q= ... L0vK878GgA

Sai
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

We are not using Db2.
Thanks

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

Post by eostic »

are the 5 levels independent of each other? ...meaning, not nested, but entirely independent in meaning and number of occurrences (imagine a company with a node for employees and another node for products).

If they are truly independent, then it can absolutely be done with one single Stage, in the old xmlInput Stage or the new xml Stage.....

....but..... it will be multiple "links" coming out of it..........

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post by sheema »

The 5 levels are nested. How can we achieve this in new XML stage in 8.5.
Thanks

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

Post by eostic »

if they are nested, it can be done with either Stage, and in a single output link...if you use the new Stage, be sure you have at least FP1, and you need the xsd. If you don't have the xsd, you'll need to generate one, or use the xml Input Stage.

With the new Stage, initially have a parsing step that identifies the correct "root" of your document....then, in the Output Step, first map the "lowest" level list (little blue icon identifing the lowest level repeating node) to your output link, before you do anything else, and then map columns from the nodes that are above it.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply