Skip to Content
0
Jul 20, 2009 at 09:47 PM

XSLT mapping query

18 Views

Hi All

I have done a XSLT mapping to map a flat file structure to a hierarchical structure. But my 3rd level node is getting repeated for 2nd level node. Please find the details below

Source Structure - flat file

Header - 1

Record - 1....unbound

Forecast - 1....unbound

Target Structure

level1 - MessageHeader - 1

level1 - ProductActivity - 1

level 2 Record - 1...unbound

level 3 Forecast - 1...unbound

*Sample Format of Source file*

Header

Record1

Forecast1.1

Forecast1.2

Record2

Forecast 2.1

Forecast 2.2

Now after execution of XSLT mapping the output I am getting contains all Forecast nodes for every record. For example output of above mentioned format is

*Sample Format of target structure*

MessageHeader

ProductActivity

Record1

Forecast1.1

Forecast1.2

Forecast2.1

Forecast2.2

Record2

Forecast1.1

Forecast1.2

Forecast2.1

Forecast2.2

Expected Output

MessageHeader

ProductActivity

Record1

Forecast1.1

Forecast1.2

Record2

Forecast2.1

Forecast2.2

Here is code for forcast row

<!-- TimeSeries: Net demand forecast(Dynamic replenishment) and Planned Receipt (SNI)-->
<xsl:if test="$ProcessFlag= 'SM'">
<OrderForecastTimeSeries>
<xsl:for-each select="//Forecast">
<Item>
<ValidityPeriod>
<StartDateTime><xsl:value-of select="substring(./ForecastDate, 1,4)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(./ForecastDate,5,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(./ForecastDate,7,2)"/>
<xsl:text>T</xsl:text>
<xsl:text>00:00:00</xsl:text>
</StartDateTime>
<EndDateTime>
<xsl:value-of select="substring(./ForecastDate, 1,4)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(./ForecastDate,5,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(./ForecastDate,7,2)"/>
<xsl:text>T</xsl:text>
<xsl:text>00:00:00</xsl:text>
</EndDateTime>
</ValidityPeriod>
<Quantity>
<xsl:attribute name="unitCode"><xsl:value-of select="Unit"/></xsl:attribute>
<xsl:value-of select="Quantity"/>
</Quantity>
</Item>
</xsl:for-each>
</OrderForecastTimeSeries>
</xsl:if>

Edited by: Amol on Jul 21, 2009 3:26 AM