Skip to content

Instantly share code, notes, and snippets.

@yasirjanjua
Forked from greystate/airports.xslt
Created June 1, 2022 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasirjanjua/91ef553722a35574202e8c0f86901787 to your computer and use it in GitHub Desktop.
Save yasirjanjua/91ef553722a35574202e8c0f86901787 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