BSalunke
BSalunke

Reputation: 11727

How to call template with parameter(with default vvalue) in xsl file?

In following template call

  <xsl:call-template name="My_Class">
    <xsl:with-param name="className" select="getClassName()"/>
    <xsl:with-param name="baseClassName" select="??????"/>
  </xsl:call-template>

i have to call My_Class template with value of second parameter i.e. baseClass as user defined. i.e. suppose i want call this template by passing value of second argument(shown as ???? in above code) as "balaji". Any suggestion on above? Thanks in advance.

Upvotes: 0

Views: 3472

Answers (1)

Tim C
Tim C

Reputation: 70618

If you want to pass a parameter as a fixed, you can just do something like this:

<xsl:call-template name="My_Class">
    <xsl:with-param name="className" select="getClassName()"/>
    <xsl:with-param name="baseClassName" select="'balaji'"/>
</xsl:call-template> 

Alternatively, you could specify the value as a default value in the template itself

<xsl:call-template name="My_Class">
    <xsl:with-param name="className" select="getClassName()"/>
</xsl:call-template> 

<xsl:template name="My_Class">
   <xsl:param name="className" />
   <xsl:param name="baseClassName" select="'Balaji'" />
   <xsl:value-of select="$baseClassName" />
</xsl:template>

Is this what you are were looking for?

Upvotes: 5

Related Questions