Preventing tags from being written into an XML file

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
yogesh.r
Premium Member
Premium Member
Posts: 7
Joined: Mon Apr 06, 2009 4:07 am

Preventing tags from being written into an XML file

Post by yogesh.r »

There is a requirement where I have to create a XML output file. While creating this file I have to conditionally filter out certain tags i.e. prevent the tags from being writtent into the XML file.

e.g.

<Department>
<DepartmentId>112</DepartmentId>
<EmployeeName>John</EmployeeName>
<EmployeeId>101</EmployeeName>
<EmployeeName>ZZ</EmployeeName>
<EmployeeId>00</EmployeeName>
</Department>

From the example it can be seen that a default employee 'ZZ' is being generated. I want to prevent the tag <EmployeeName>ZZ</EmployeeName> from being written into the output XML file. How can I acheive this. This there any setting in the XML output stage that can help me acheive this.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your example is a little messed up. Did you actually mean something more like?

<Department>
<DepartmentId>112</DepartmentId>
<EmployeeName>John</EmployeeName>
<EmployeeId>101</EmployeeID>
<EmployeeName>ZZ</EmployeeName>
<EmployeeId>00</EmployeeId>
</Department>

And you need to suppress the 'ZZ' name or the '00' employee id? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArjunK
Participant
Posts: 30
Joined: Sun Apr 30, 2006 6:32 pm

Post by ArjunK »

Based on the column value that you want to filter out, you can capture and transform it to an empty string in a transformer. Then in the XML output stage set the "Replace Empty values with NULL" property and that should prevent the tag from getting generated.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...or alternatively you could also just make sure that the value for that column on that row is truly "null"...the default is to not create the element tag....

...of course, it's strange that the receiving application cares.....it should be able to handle empty elements.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
yogesh.r
Premium Member
Premium Member
Posts: 7
Joined: Mon Apr 06, 2009 4:07 am

Post by yogesh.r »

chulett, Apologies for a bit confusing example.

Arjun/Ernie,
Thanks for your comments. I was able to prevent the tag from being written into my xml file.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No worries. Could you do a couple of things, please? It would help future searchers if you posted how you were able to solve this and please mark your post as Resolved using the button at the top of the screen.
-craig

"You can never have too many knives" -- Logan Nine Fingers
yogesh.r
Premium Member
Premium Member
Posts: 7
Joined: Mon Apr 06, 2009 4:07 am

Post by yogesh.r »

As suggested by Arjun and Ernie. I changed the datatype of the column to nullable 'Yes' and if the required condition was not satisfied I set the column to a null value using setNull(). Doing this prevented the tag from being written into the output XML.
Post Reply