xslt 1.0 - Unable to Successfully Pass Parameters to xsl:call-template -
i have generic template i've designed 2 params title
, category
.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format"> <xsl:param name="category" /> <xsl:param name="title" /> <xsl:template name="test-group"> <fo:block> <xsl:value=of select="$title" /> </fo:block> <fo:block> <xsl:value-of select="$category" /> </fo:block> </xsl:template> </xsl:stylesheet>
in parent template have following:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format"> <xsl:include href="templates/generic_template.xsl" /> ... <xsl:call-template name="test-group"> <xsl:with-param name="category" select="'animals'" /> <xsl:with-param name="title" select="'dogs'" /> </xsl:call-template> ... </xsl:stylesheet>
however, when transform completes title , category blank. i'm using fop 2.0 i'm not sure if known shortcoming.
when defining xsl:template
takes parameters, parameter names used within xsl:template
should declared using xls:param
elements nested within.
<xsl:template name="test-group"> <xsl:param name="category" /> <xsl:param name="title" /> ... </xsl:template>
the parameters being attached xsl:template
, not xsl:stylesheet
. similar when calling template xsl:call-template
, except specifying values instead using xsl:with-param
.
Comments
Post a Comment