Skip to content

Instantly share code, notes, and snippets.

@greystate
Created July 30, 2014 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save greystate/69639edd5107cbbe43c6 to your computer and use it in GitHub Desktop.
Save greystate/69639edd5107cbbe43c6 to your computer and use it in GitHub Desktop.
Using with-param with apply-templates
<!-- Start -->
<xsl:apply-templates select="airports/airport">
<xsl:with-param name="position" select="'start'" />
</xsl:apply-templates>
<!-- End -->
<xsl:apply-templates select="airports/airport">
<xsl:with-param name="position" select="'end'" />
</xsl:apply-templates>
<xsl:template match="airports/airport">
<xsl:param name="position" />
<option value="{@iata}" data-alternative-spellings="{.},{@iata}">
<xsl:if test="(@iata = 'LGW' and $position = 'start') or (@iata = 'LAX' and $position = 'end')">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@iata"/> - <xsl:value-of select="." />
</option>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment