XML Output: Including "name"/@name in xpath

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
Maximus_Jack
Premium Member
Premium Member
Posts: 139
Joined: Fri Apr 11, 2008 1:02 pm

XML Output: Including "name"/@name in xpath

Post by Maximus_Jack »

Hi
i'm using the xml output stage to generate the xml, i have created everything, but as a last minute change the downstream needs a small change in one of the column name, as of now the column name is like

<columnname>121212</columnname>

now they want it as
<columnname name="something">121212</columnname>

i know it is some XML thing ( like checking for a condition.. i guess), but during the xml generation i'm not doing anything like that, is there any way to bring that change in the xpath, so that it will reflect that?

any ideas...

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

Post by eostic »

Sure....just add another column to the input link....with the "something" in it......

Each DataStage "column" is able to be placed into xml as an element value, or as an attribute value. So...in this case, you have two columns....one for the value of the element called <column> and another for the value of "name" (has "something" in it).

something /.../.../column/@name
column /.../.../column/text()

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

By the way....I've seen xml like this...it is usually a "quickie" way of doing xml design....so that the elements don't have to be called out specifically. It is a poor design, frankly, because it means that the metadata is really just "data" and not reflected in the xml structure or any xsd's.

Consider:

<column name="ssn">123456789</column>
<column name="first name">fred</column>
<column name="email">fred@company.com</column>

How much nicer that would be if it were:

<ssn>123456789</ssn>
<firstName>fred</firstName>
<email>fred@company.com</email>

...you may not be able to influence the design, but if you can, the xml and the jobs to load it will be much nicer all around.

As it stands, you probably already are pivoting your rows of data so that you can generate "rows" for each column, and then you will also need to hard code the names of the columns so that you have string values for each of the element possibilities.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Maximus_Jack
Premium Member
Premium Member
Posts: 139
Joined: Fri Apr 11, 2008 1:02 pm

Post by Maximus_Jack »

you are the MAN... :D


absolutely.. did it... thanks a lot..

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

Post by eostic »

;) glad it worked. I wish clearing the snow in our driveway was as easy.

Ernie
Ernie Ostic

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