xml tags not generating

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
sanoojk
Participant
Posts: 36
Joined: Wed Dec 19, 2007 3:54 am

xml tags not generating

Post by sanoojk »

I have a requirement where an XML of the below format need to be generated.

<demands>
<demand>
<brand>ABC</brand>
<submittedby>KZK4164</submittedby>
<senddate>2013-08-14 09:42:44.353000</senddate>
<tasklistname>CONFIG_SEND</tasklistname>
<srcfilename>CONFIG-13859</srcfilename>
<uid>13859</uid>
<stores>
<store>008256</store>
<store>008563</store>
</stores>
</demand>
<demand>
<brand>ABC</brand>
<submittedby>KZK4164</submittedby>
<senddate>2013-08-14 09:42:44.353000</senddate>
<tasklistname>CONFIG_CANCEL</tasklistname>
<uid>13859</uid>
<stores>
<store>008233</store>
<store>008444</store>
<store>008454</store>
<store>008463</store>
</stores>
</demands>

I used the STORE number as a key in the XML input and have generated each repeating demand item by applying Trigger to the UID element. The only problem I am facing now is with the start and end tag <demands></demands> . If I am specifying the XPath like /demands/demand/(the corresponding element) then I get the <demands></demands> combination getting repeated for each demand item. I only need this <demands></demands> only once in my file.

To achieve this I passed the input through another XML output stage but I got a truncated output with only a very few records.
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Can you post your exact dot release? The XML stages underwent a significant overhaul, so the answer might be different depending on what version of 8 you are using.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Hard to say. I've seen things like this before when the higher level repeating node is not easily unique (meaning --- you have to go to its 3rd or 4th element before noticing that the next instance of demand is indeed unique from the prior one). ...in this case you have to go to tasklistname before we know it's not the same demand.

In those cases, if that's what is causing this, I find it beneficial to add a counter to each of my separate higher level nodes. ....so....upstream, create a "demand" counter that is unique for every unique group of demand rows. Then put that counter as the first element in your demand node, such as:

myCounter .....................................with description of /.../demands/demand/myCounter/text()

See if that creates the correct structure. If so, edit out the myCounter element (if you need to --- depends on what type of app is receiving the xml) in a downstream transformer using ereplace or similar.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

From what I see in your sample XML, it seems you're not just creating this XML in one step. If you are creating your repeating XML tags in a separate step and appending that XML chunk in some columns like <store>. If so, don't define XPath for those tags, just put a '/' and specify it as XML in data element. I guess that should fix your problem.
Arun
sanoojk
Participant
Posts: 36
Joined: Wed Dec 19, 2007 3:54 am

Post by sanoojk »

The DS version that we use is DS 8.5
sanoojk
Participant
Posts: 36
Joined: Wed Dec 19, 2007 3:54 am

Post by sanoojk »

arunkumarmm wrote:From what I see in your sample XML, it seems you're not just creating this XML in one step. If you are creating your repeating XML tags in a separate step and appending that XML chunk in some columns like <store>. If so, don't define XPath for those tags, just put a '/' and specify it as XML in data element. I guess that should fix your problem.
We already tried the exact same way. But the repetition chunk is not displaying properly
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

So this is your problem. You create the chunk with full XPath twice so its obvious that you get your root element for every record. And the exact same way should work. From my best knowledge, that is the only way to do it. Just to make sure, you just defined the XPath with '/' or did you even mention that it is an XML in the 'Data Elements'?
Arun
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Looking at this more closely, another issue might be the use of trigger --- are you expecting to create multiple documents? Generally speaking you will want to use the "Aggregate" option, and then specify the lowest level repeating unit (just pick one of the elements at that level) as a key.

You may still also be having issues with the uniqueness of the parent, as I outlined earlier.

Ernie
Ernie Ostic

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