Hi
I am having trouble with the below xml to csv conversion. I
am having trouble to pass a parameter defined in one template
into a second template.
I am not able to print out Date defined in folioSummary. My xml
is -
<folio _Id="64" foliodate="2005-06-30" >
<folioSummary>
<Date>2004-06-30</Date>
<PreviousfolioDate>2005-05-31</PreviousfolioDate>
</folioSummary>
<Holding>
<HoldingDetail>
<CUSIP>368710406</CUSIP>
<Weighting>8.63488</Weighting>
</HoldingDetail>
<HoldingDetail>
<CUSIP>38259P508</CUSIP>
<Weighting>6.8968</Weighting>
</HoldingDetail>
</Holding>
</folio>
and my xsl is -
<?xml version="1.0"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="reqdate" select="''" />
<xsl:template match="folio">
<xsl:param name="id" select="@_Id" />
<xsl:param name="date" select="@foliodate" />
<xsl:apply-templates select="folioSummary" >
<xsl:with-param name="reqdate_1" select="$reqdate" />
</xsl:apply-templates>
<xsl:apply-templates select="Holding" >
<xsl:with-param name="passid" select="$id" />
<xsl:with-param name="passdate" select="$date" />
<xsl:with-param name="reqdate_2" select="$reqdate" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="folioSummary">
<xsl:param name="reqdate_1" select="Date"/>
</xsl:template>
<xsl:template match="Holding">
<xsl:param name="passid"/>
<xsl:param name="passdate"/>
<xsl:param name="reqdate_2"/>
<xsl:apply-templates select="HoldingDetail">
<xsl:with-param name="passida" select="$passid" />
<xsl:with-param name="passdatea" select="$passdate" />
<xsl:with-param name="reqdate_3" select="reqdate_2"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="HoldingDetail">
<xsl:param name="passida"/>
<xsl:param name="passdatea"/>
<xsl:param name="reqdate_3"/>
<xsl:value-of select="$passida"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="CUSIP"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$passdatea"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$reqdate_3"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="Weighting"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
The output is -
C:\Tools\xml2csv>java org.apache.xalan.xslt.Process -in t1.xml
-xsl t1.xsl
64,368710406,2005-06-30,,8.63488
64,38259P508,2005-06-30,,6.8968
and the desired output is
64,368710406,2005-06-30,2004-06-30,8.63488
64,38259P508,2005-06-30,2004-06-30,6.8968
Is there a way to get the folioSummary Date to print when I
am printing other details inside Holding?
Thanks in advance
Srinivas