XML Input, Reading the repeated elements

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

Post Reply
swades
Premium Member
Premium Member
Posts: 323
Joined: Mon Dec 04, 2006 11:52 pm

XML Input, Reading the repeated elements

Post by swades »

Hi,

I am trying to read the repeated elements of an XML. The part of the XML looks like ...
.......
.......
<Customer>
<Phone number="Home">5715271662</Phone>
<Phone number="Mobile">5715271663</Phone>
</Customer>
<Location>
<City name="One">Reston</City>
<City name="Two">Herndon</City>
</Location>
.......
.......

I am using the seqfile stage---> xml input stage ---> transformer ---> oracle stage

In the XML input stage, I gave the following XPaths (in description) to read those values. And mentioned the Phonetype as the repetitive element(Key).

Phonetype --> ....../Customer/Phone/@number
Number --> ....../Customer/Phone/text()
Citytype --> ...../Location/City/@schemeName
Cityname --> ...../Location/City/text()

but, it gives the output as

Phonetype Number Citytype Cityname
---------- ------- ---------- -------
Home 5715271662 One Reston
Mobile 5715271663 One Reston

I need the output as

Phonetype Number Citytype Cityname
---------- ------- ---------- -------
Home 5715271662 One Reston
Mobile 5715271663 Two Herndon

We cannot declare more than one key field. But, there should be someway to read them to get the mentioned output.
I am not sure whether to mention something in the derivation of the xml input stage.
Would anyone please help me out?

Thanks,
Swades
Last edited by swades on Thu Jun 28, 2007 12:41 pm, edited 1 time in total.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Try reading the XML with just 2 fileds:

Code: Select all

Phonetype --> ....../Customer/Phone/@number 
Number --> ....../Customer/Phone/text() 
And specify 'Phonetype' as repetition element.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Post Reply