I have the below input xml,
<GSKProductHierarchy>
<GlobalBusinessIdentifier>ZGB001</GlobalBusinessIdentifier>
<Hierarchy>
<Material>335165140779</Material>
<Level1>02</Level1>
<Level2>02AQ</Level2>
<Level3>02AQ006</Level3>
<Level4>02AQ006309</Level4>
<Level5>02AQ006309</Level5>
<Level6>02AQ006309</Level6>
<Level7>02AQ006309</Level7>
<Level8>02AQ006309</Level8>
</Hierarchy>
<Hierarchy>
<Material>335165140780</Material>
<Level1>02</Level1>
<Level2>02AQ</Level2>
<Level3>02AQ006</Level3>
<Level4>02AQ006309</Level4>
<Level5>02AQ006309</Level5>
<Level6>02AQ006309</Level6>
<Level7>02AQ006309</Level7>
<Level8>02AQ006310</Level8>
</Hierarchy>
<Texts>
<ProductHierarchy>02AQ006310</ProductHierarchy>
<Language>A</Language>
<Description>CREAM</Description>
</Texts>
<Texts>
<ProductHierarchy>02AQ006309</ProductHierarchy>
<Language>B</Language>
<Description>CREAM</Description>
</Texts>
as per the requirement, xsl should check the matched value of GSKProductHierarchy/Hierarchy/Level8 in the GSKProductHierarchy/Texts/ProductHierarchy elements...and its should result as below flat file.
335165140779|02|02AQ|02AQ006|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006309|A|CREAM|
335165140780|02|02AQ|02AQ006|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006310|02AQ006310|B|CREAM|
Right now I have the below xslt,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:set="http://exslt.org/sets" xmlns:str="http://exslt.org/strings" xmlns:java="http://xml.apache.org/xslt/java" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="exsl set str java saxon">
<xsl:output method="text" indent="yes"/>
<xsl:variable name="VarPipe" select="'|'"/>
<xsl:variable name="VarBreak" select="'
'"/>
<xsl:template match="/">
<xsl:for-each select="GSKProductHierarchy/Hierarchy">
<xsl:variable name="currentIndex" select="position()"/>
<xsl:variable name="Level8" select="Level8"/>
<xsl:variable name="ProductHierarchy" select="../Texts[$currentIndex]/ProductHierarchy"/>
<xsl:if test="$Level8=$ProductHierarchy">
<xsl:value-of select="Material"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level1"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level2"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level3"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level4"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level5"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level6"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level7"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="Level8"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="../Texts[$currentIndex]/ProductHierarchy"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="../Texts[$currentIndex]/Language"/>
<xsl:value-of select="$VarPipe"/>
<xsl:value-of select="../Texts[$currentIndex]/Description"/>
<xsl:value-of select="$VarPipe"/>
<xsl:if test="not(position() = last())">
<xsl:value-of select="$VarBreak"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
can anyone please suggest what function should i need to use to get the desired result.
Regards,
Giri