XML Output unable to generate multiple namespaces

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
amit.jaiswal_ATL
Premium Member
Premium Member
Posts: 28
Joined: Thu Oct 23, 2014 1:49 pm

XML Output unable to generate multiple namespaces

Post by amit.jaiswal_ATL »

Hello All,

I am reading data from a table and creating XML blocks and storing in the Oracle target table as BLOB. I am using Oracle Connector Stage ==> XML Output Stage ==> Transformer Stage ==> XML Output Stage ==> Oracle Connector Stage to generate below XML. I am able to generate XML structure and first namespace correctly but unable to generate later three namespaces (I have added comments against *). Can you please let me know how I can generate those namespaces?

=========
<s:ShowStandardCodes xmlns:gwm="http://www.gm.com/2006/GWM" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.starstandards.org/STAR" xsi:schemaLocation="http://www.gm.com/2006/GWM v1.01\GWM_TI_ShowStandardCodes.xsd" revision="3.0" release="8.1-Lite" environment="Production"> * ABLE to generate namespace
<s:ApplicationArea>
<s:Sender xmlns:s="http://www.starstandards.org/STAR" xsi:type="s:Sender">...</s:Sender> ** UNABLE to generate namespace
<s:CreationDateTime>2015-01-21T13:29:15.00Z</s:CreationDateTime>
<s:Destination>...</s:Destination>
</s:ApplicationArea>
<s:DataArea>
<s:Show xmlns:s="http://www.starstandards.org/STAR" xsi:type="s:Show"/> ** UNABLE to generate namespace
<s:StandardCodes>
<s:Header xmlns:gwm="http://www.gm.com/2006/GWM" xsi:type="gwm:StandardCodesHeaderExtended">...</s:Header> ** UNABLE to generate namespace

========

Additional info :
Expected result for one of the tag :
<s:Sender xmlns:s="http://www.starstandards.org/STAR" xsi:type="s:Sender">

Actual result : <s:Sender xsi:type="s:Sender">

Missing part : xmlns:s="http://www.starstandards.org/STAR"

I used below xpath in the Description column :
/s:ShowStandardCodes/s:ApplicationArea/s:Sender[@xsi:type="s:Sender"]/s:Component

Please let me know if you need additional information. Thanks in advance!

Thanks,
-Amit
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Not sure of the best way to go about that...if you truly need the namespace declarations again in a subsequent higher element....(they appear to be identical in this case, are they always? ...if so, they shouldn't necessarily be needed, unless this xml gets broken up later on)....

Some approaches you might take:

a) build the xml in chunks and then put it all back together again. Build each chunk as the namespace section...each with its own xmlOutput Stage icon instance. Put them together again using the same technique used when building multi-path hierarchical output (see the xml best practices document that you will find if you search thru the forum here).

b) "zap" it in there later. If the xml documents aren't that big, pass them thru a transformer, locate the position where you need the namespace string and use a string function to put in the value that you need.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
amit.jaiswal_ATL
Premium Member
Premium Member
Posts: 28
Joined: Thu Oct 23, 2014 1:49 pm

Post by amit.jaiswal_ATL »

Thanks Ernie. I used option-2 and used Ereplace function to add the namespaces and it worked as expected. Thanks for your help!
Amit Jaiswal
Atlanta GA USA
Post Reply