XML Input Stage Replace Empty Values with Null

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
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

XML Input Stage Replace Empty Values with Null

Post by reddy »

Hi,

I am trying to replace the Empty values in the xml files to null. I have checked Replace Empty values with Null tab both on Stage/Transformation settings and Output/Transformation settings page. But i see empty values in teh output. Can anyone please help me? Thank you.

Reddy
jmarutz
Participant
Posts: 5
Joined: Mon Jun 26, 2006 12:42 pm

Post by jmarutz »

Are you sure the values are empty? Some non-printable characters don't display correctly in datastage, but are seen as values. Try either getting the length on those strings to make sure they're empty or write it to a file and vi it.
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Post by reddy »

They are empty. I can see that they are empty when i view tthe particular XML file.


reddy
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Hi Reddy...

How are you checking the nulls? The only safe way to check is to use the isNull() function against the columns, in a Transformer after your XMLInput Stage. Do something simple, like have a NullFlag column that is set to "yes" if [isNull(linkFromXMLInput.ColumnName)=1] ....otherwise you can't be sure.

If "replace empty values with nulls" is checked, both types of empty elements (<myElement/> and <myElement></myElement> will be NULL and xsi:nil and truly missing elements will also be NULL (more rows end up NULL than with default).

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How do you claim to be able to "see" non-printing characters such as, perhaps, Esc in the XML file?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Post by reddy »

Hi,
I am trying to capture the empty spaces and default them to null. So may i have to use a transforemr after teh XML Input and do something like IF input.columnname ='' then setnull() else input.columname. I think i will try this.

when i checked Replace empty spaces with null, i did not get even a single value as NULL and i can see a lot of empty spaces. Did I miss something in this process.

I think the values are empty in teh XML file beacuse i see a lot of this type of data in my xml file.

Process="" Version="" Priority=""

So, i thought these must be empty values and rightly when i extract them to a sequential file i get just a blank value for this particular field.

Thanks,

Reddy
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

if you have xml content that looks like:

<myXML>
<myElement>
<rows>
<col1>123</col2>
<col2/>
<col3>456</col3>
</rows>
</myElement>
</myXML

and xpath for col2 that looks like /myXML/myElement/rows/col2/text()

and you check "Replace empty elements with null", then

isNull(LinkFromXML.col2) will yield "true".

What you do with it after that is up to you.....and simply in the domain of DataStage and no longer an xml issue. If you have this situation and isNull does not equate to true, let us know.

Ernie
Ernie Ostic

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