Page 1 of 1

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

Posted: Tue Feb 11, 2014 10:37 am
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

Posted: Tue Feb 11, 2014 11:11 am
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

Posted: Tue Feb 11, 2014 11:17 am
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

Posted: Tue Feb 11, 2014 12:33 pm
by Maximus_Jack
you are the MAN... :D


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

MJ

Posted: Tue Feb 11, 2014 12:49 pm
by eostic
;) glad it worked. I wish clearing the snow in our driveway was as easy.

Ernie