DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
srds2



Group memberships:
Premium Members

Joined: 29 Nov 2011
Posts: 66

Points: 821

Post Posted: Thu Jul 25, 2013 3:51 pm Reply with quote    Back to top    

DataStage® Release: 7x
Job Type: Parallel
OS: Unix
I have a job with Below structure
Some Stages->XML Output Stage->XML Output Stage->XML Transformer Stage

Till the First XML Output Stage, When I have written the output to a file the below structure can be seen

Code:
     <MainSubTag>
       <Tag1>Value1</Tag1>
        <Tag2>Value2</Tag2>
     </MainSubTag>
     <MainSubTag>
        <Tag1>Value3</Tag1>
        <Tag2>Value4</Tag2>
     </MainSubTag>

In the next XML Output Stage, I am getting the below output

Code:
<MainTag>
     <MainSubTag>
         <Tag1>Value1</Tag1>
        <Tag2>Value2</Tag2>
     </MainSubTag>
</MainTag>
<MainTag>
     <MainSubTag>
        <Tag1>Value3</Tag1>
        <Tag2>Value4</Tag2>
     </MainSubTag>
</MainTag>

But, Actually I should get something like this,

Code:
<MainTag>
     <MainSubTag>
         <Tag1>Value1</Tag1>
        <Tag2>Value2</Tag2>
     </MainSubTag>
     <MainSubTag>
        <Tag1>Value3</Tag1>
        <Tag2>Value4</Tag2>
     </MainSubTag>
</MainTag>

So, in the final XML Output Stage before writing to a XML Transformer, the root element is repeating for each sub element
srds2



Group memberships:
Premium Members

Joined: 29 Nov 2011
Posts: 66

Points: 821

Post Posted: Thu Jul 25, 2013 5:53 pm Reply with quote    Back to top    

Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
   <xsl:template match="/MainTag">
      <MainTag>
   <xsl:for-each select="MainSubTag">
      <MainSubTag>
      <xsl:apply-templates select="./*[not(name()='Tag2')]"/>
      </MainSubTag>
   </xsl:for-each>
      </MainTag>
   </xsl:template>

   <xsl:template match="MainSubTag">
      <MainSubTag>
         <xsl:apply-templates select="./@*[not(name()='Tag2')]"/>
      </Order>
   </xsl:template>
   <xsl:template match="node()|@*">
      <xsl:copy>
         <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
   </xsl:template>

</xsl:stylesheet>


This style sheet is being used in Final XML Transformer Stage.
Rate this response:  
Not yet rated
lstsaur
Participant



Joined: 21 Oct 2004
Posts: 1139

Points: 5432

Post Posted: Fri Jul 26, 2013 9:57 am Reply with quote    Back to top    

What's your root element? Are you thinking that "MainTag" is your root element? Please post your XML document.
Rate this response:  
Not yet rated
MrBlack
Participant



Joined: 08 Aug 2012
Posts: 125

Points: 1546

Post Posted: Wed Jul 31, 2013 9:15 am Reply with quote    Back to top    

You say you job looks like this:

Code:
Some Stages -> XML Output -> XML Output -> XML Transformer


I'm curious couldn't your job look like this with just a single XML Output stage:

Code:
Some Stages -> XML Output -> XML Transformer


And then you would just adjust your XPath to write out your tags properly? Is there a reason for two XML Output stages?
Rate this response:  
Not yet rated
eostic

Premium Poster



Group memberships:
Premium Members

Joined: 17 Oct 2005
Posts: 3825

Points: 30845

Post Posted: Wed Jul 31, 2013 12:05 pm Reply with quote    Back to top    

+ 1 and also, why the XML Transformer? If you exclusively are doing things in xslt, that makes sense, but it shouldn't be necessary if you are using xmlOutput. As for duplicated root elements, ...

_________________
Ernie Ostic

blogit!
Open IGC is Here!
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours