here is my below xml under that table due based on CTD_CTD_PKG_ID(some time under table CTD_CTD_PKG_ID id was same means we need take data from both tables ) this pack id we need to generate a text file with the help of xsl style sheet but how to write logic code in xslt
for some fields data were same for that type of records for me dont want to repeat once again only once i need but how to control if i am getting two records of CTD_LANG_ID needed to display once but i have written xslt i was thinking it was not correct we will fail when we are have xml with one more table with different package id(CTD_CTD_PKG_ID) at that time lang id may be different than E but this xslt were showing E it self …
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table>
<RECORD_TYPE_CODE>CTD</RECORD_TYPE_CODE>
<MSG_TYPE_CODE>O102</MSG_TYPE_CODE>
<CTD_SEQ_NUM>089938</CTD_SEQ_NUM>
<CTD_CTD_PKG_ID>345</CTD_CTD_PKG_ID>
<CTD_LANG_ID>E</CTD_LANG_ID>
</Table>
<Table>
<RECORD_TYPE_CODE>ITD</RECORD_TYPE_CODE>
<MSG_TYPE_CODE>O103</MSG_TYPE_CODE>
<CTD_SEQ_NUM>089939</CTD_SEQ_NUM>
<CTD_CTD_PKG_ID>345</CTD_CTD_PKG_ID>
<CTD_LANG_ID>E</CTD_LANG_ID>
</Table>
</NewDataSet>
I HAVE A WRITTEN MY OWN XSLT LOGIC BUT IT DOESN’T WORK
<?xml version="1.0" encoding="utf-8"?>
<xsl:output method="text" indent="no" omit-xml-declaration="yes" />
<xsl:param name="PackageId" />
<xsl:template match="/">
<xsl:apply-templates select="NewDataSet/Table[CTD_CTD_PKG_ID ='345']"/>
</xsl:template>
<xsl:template match="NewDataSet/Table[CTD_CTD_PKG_ID ='345']">
<xsl:value-of select= "concat(':25:',./TRAN_TYPE_CODE)"/>,<xsl:text/>
<xsl:if test ="./RECORD_TYPE_CODE" >
<xsl:if test=" position() > 1"></xsl:if>
<xsl:text/><xsl:value-of select= "concat(':20:',./RECORD_TYPE_CODE)"/>,<xsl:text/>
</xsl:if>
<xsl:if test ="./MSG_TYPE_CODE" >
<xsl:if test=" position() > 1"></xsl:if>
<xsl:text/><xsl:value-of select= "concat(':21:',./MSG_TYPE_CODE)"/>,<xsl:text/>
</xsl:if>
<xsl:if test ="./CTD_SEQ_NUM" >
<xsl:if test=" position() > 1"></xsl:if>
<xsl:text/><xsl:value-of select= "concat(':22:',./CTD_SEQ_NUM)"/>,<xsl:text/>
</xsl:if>
</xsl:template>
Execpected output
:25:E,:20:CTD,:21:O102N,:22:089938,:20:ITD,:21:O103N,:22:089939,
Here is a sample stylesheet: