Using XSLT to Find Nodes Given a Set of Parameters
Posted
by davecardwell
on Stack Overflow
See other posts from Stack Overflow
or by davecardwell
Published on 2010-06-17T16:07:10Z
Indexed on
2010/06/17
18:03 UTC
Read the original article
Hit count: 258
Sorry about the title—wasn’t sure how to word it.
Basically I have some XML like this:
<countries>
<country handle="bangladesh"/>
<country handle="india"/>
<country handle="pakistan"/>
</countries>
And some XSLT like this (which doesn’t work):
<xsl:template match="/countries">
<xsl:param name="popular"/>
<xsl:apply-templates select="country[count($popular/country[@handle = current()/@handle]) > 0]" />
</xsl:template>
<xsl:template match="/countries/country">
…
</xsl:template>
I want to pass in a list of popular destinations like this:
<popular>
<country handle="india"/>
<country handle="pakistan"/>
</popular>
…to the /countries template and have it only operate on the ones in the $popular param. At the moment this simply does nothing. Changing the selector to country[true()] operates on them all, so at least I know the basic structure is right.
Any ideas? I think I may be getting confused by what is currently “current()”.
© Stack Overflow or respective owner