XML Output

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
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

XML Output

Post by bond88 »

Hi,
I am working on java integration and for that I need to pass XML data. I am using XML output to get XML format from oracle table data. If I am passing duplicate rows I am getting only one row (first tag is repeating). Please take a look at below output format. I need 3 rows separately. Please advise me.

Input:

Title -- Initials
Student Assistant -- F
Student Assistant -- F
Student Assistant -- F

Output:

-<users>
-<user>
<title> Student Assistant </title>
<title> Student Assistant </title>
<title> Student Assistant </title>
<initials> F </initials>
</user>
</users>
Bhanu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Post your XPath Expressions.
-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 »

Try adding a unique counter as another column just before title. You can remove it later.
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... or that. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post by bond88 »

I added an extra field "Num" (using surrogate key generator) to that then it started returning output like this.

Input:

Num -- Title -- Initials
61 -- Student Assistant -- F
62 -- Student Assistant -- F
63 -- Student Assistant -- F

Output:

-<users>
-<user>
<num> 61 </num>
<num> 62 </num>
<num> 63 </num>
<title> Student Assistant </title>
<initials> F </initials>
</user>
</users>

Please advise me.

Thank you,
Bhanu
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post by bond88 »

I am using following expression to create XML

/import-users-request/users/user/num
/import-users-request/users/user/title
/import-users-request/users/user/initials

Thank you,
Bhanu
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

check your xpath. make sure each one ends with "text()"

Like:

/import-users-request/users/user/num/text()

and then also check that you are using "aggregate" on the detail tab of the output link and make num your only "key".

We'll assume also that the rows are arriving in this exact order (ie...for this test, don't have a multi-node config or anything else that might confuse the issue)

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post by bond88 »

Thanks Ernie,
I added /text() to all 3 columns (descriptions) and I am using aggregate on the detail tab, I made num as key and not running any nodes I am running under sequential mode but still getting the output in the old way. Please suggest me.

Thank you,
Bhanu
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

At the moment I am not sure and right now I don't have access to DataStage to try anything.......I recall a very strange behavior from many years ago where fewer than 4 columns created some issues. As a test that wouldn't be too hard to try, add two more cols and see if it impacts anything (add num1 and num2, with equivalent xpath for a total of 5 cols). It might do nothing or might hint at what the issue is.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post by bond88 »

Thanks Ernie,
To debug I was trying with fewer columns. So I added all the required 12 columns including "NUM" and definitions to all columns with ending /text(), still it is returning in the old fashion and I tried to change different settings and all but no use.

Thank you,
Bhanu
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

So far, your xmloutput stage input link looks fine, so tell us about the rest of your Job. And in the meantime, test your xmloutput stage as is in a job that reads those same 3 or 4 rows from a sequential file.

What other stages are there that might be influencing things?

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 »

One more thing to also try.....on the test that you have that uses the "num" column, I asked you to make it the "key" (repetition element). It wouldn't hurt to try a test where, with that same Job, you make title the key (turn "OFF" the key for num).

Ernie
Ernie Ostic

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