Setting XML attributes

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
jeawin
Participant
Posts: 18
Joined: Mon Oct 04, 2004 6:49 am
Location: Milton Keynes
Contact:

Setting XML attributes

Post by jeawin »

I am trying to set the attribute of a tag within the XML writer stage such that the entity data output looks like this:

<livestockInformation>
<species Exception="N">HO</species>
</livestockInformation>

The tag is called 'species', the data is 'HO', and the attribute setting I am trying to accomplish is the 'Exception="N"' bit.

In the transformer stage prior to the XML writer stage I have two columns called 'species' and 'Exception'. Exception is hard-coded to "N". In the column definitions the description of the two fields are respectively:

/livestockInformation/species
/livestockInformation/species/@Exception

This gives the following result:

<livestockInformation>
<species>HO</species>
<species Exception="N"/>
</livestockInformation>

Close, but no banana! Other things I have tried have not worked either.

Anyone out there know how to enter attribute text within a tag using the XML writer stage? (Or am I going to have to write a routine to take the xml output and manually insert the 'Exception="N"' bit!?!)
raewu
Premium Member
Premium Member
Posts: 5
Joined: Thu May 12, 2005 9:51 am
Location: københavn, DK

Post by raewu »

i have always used a routine myself in this situation, but i'd be interested to here of a more efficient way to do this.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Are you really using the XMLWriter? or XMLOutput? XMLWriter is as good as deprecated now. Assuming that you are in release 6 as noted, then manually creating the xml string yourself is probably the only bet (the new XMLinput and XMLoutut stages replace the old XMLReader and XMLWriter) It's been many years since I've tried the old stages, so can't help you with a real test, but I will assume you've tried switching the order of the columns. XMLWriter was fairly primitive, as it was a UV/Basic stage under the covers and didn't use any of the standard XML industry parsers (they didn't formally exist in their current form when this Stage first arrived!).

Ernie
Post Reply