I call a template like this:
<xsl:call-template name="trip_form">
<xsl:with-param name="header" select="'Spara din resa'" />
<xsl:with-param name="size" select="'savetrip'" />
</xsl:call-template>
The templte looks like this:
<xsl:template name="trip_form">
<xsl:param name="type" />
<xsl:param name="size" />
<xsl:param name="header" />
<xsl:if test="type = ''">
<xsl:if test="/root/meta/url_params/has_car = 1">
<xsl:with-param name="'type'" select="'driver'" />
</xsl:if>
<xsl:if test="/root/meta/url_params/has_car = 0">
<xsl:variable name="'type'" select="'passenger'" />
</xsl:if>
</xsl:if>
etc…
When I specify the $type variable whilst calling the template, I want to use that value, but when I don’t I want to check the Url_params/has_car node and set the variable accordingly, how do I do this?
You can’t update the value of a parameter or variable after it has been initially set. However, what you could do, is create a new variable, and set that according to whether the original parameter $type has been set or not.
Try something like this. This creates a new variable, $newtype, which you can then use in your template. If $type is set, then $newtype will equal $type, otherwise it will look at the Url_params/has_car elements