Page 1 of 1

Setting XML attributes

Posted: Tue Jun 07, 2005 9:21 am
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!?!)

Posted: Wed Apr 25, 2007 1:49 am
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.

Posted: Wed Apr 25, 2007 8:03 pm
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