i wanted to apply transformation on output of one template in xslt is there is any way i can pass output of one xslt template as param to another template
main template
<xsl:template name="maintemplate">
<xsl:with-param name="Outputsecondtemplate" select=$sencondtemplate/>
<xsl:value-of select="translate($Outputsecondtemplate,' -:','')" />
</xsl:template>
feeder template
<xsl:template name="sencondtemplate">
<xsl:param name="context"/>
<xsl:param name="attrib"/>
<xsl:param name="case"/>
<xsl:value-of select='$context/value[@attribute=$attrib and @case=$case]' />
</xsl:template>
CodePudding user response:
is there is any way i can pass output of one xslt template as param to another template
You can do:
<xsl:call-template name="maintemplate">
<xsl:with-param name="Outputsecondtemplate">
<xsl:call-template name="secondtemplate">
<xsl:with-param name="context" select="some-context"/>
<xsl:with-param name="attrib" select="some-attrib"/>
<xsl:with-param name="case" select="some-case"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
though it is not clear from what context you're doing this.
You can also call the sub-template from the main template, e.g.:
<xsl:template name="maintemplate">
<!-- ... -->
<xsl:variable name="Outputsecondtemplate">
<xsl:call-template name="secondtemplate">
<xsl:with-param name="context" select="some-context"/>
<xsl:with-param name="attrib" select="some-attrib"/>
<xsl:with-param name="case" select="some-case"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="translate($Outputsecondtemplate,' -:','')" />
</xsl:template>