Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 861925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:03:27+00:00 2026-05-15T09:03:27+00:00

Sorry about the title — wasn’t sure how to word it. Basically I have

  • 0

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]) &gt; 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()”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:03:28+00:00Added an answer on May 15, 2026 at 9:03 am

    It’s a lot simpler than you think:

    <xsl:template match="/">
      <popular>
        <xsl:copy-of select="/countries/country[@handle=$popular/country/@handle]"/>
      </popular>
    </xsl:template>
    

    Edit

    The above was simply showing what was wrong with the OP’s original XPath query. Here’s a full working example:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:param name="popular"/>
    
      <xsl:template match="/">
          <xsl:apply-templates select="/countries">
            <xsl:with-param name="popular" select="$popular"/>
          </xsl:apply-templates>
      </xsl:template>
    
      <xsl:template match="/countries">
        <xsl:param name="popular"/>
        <countries>
          <xsl:apply-templates select="country[@handle=$popular/country/@handle]"/>
        </countries>
      </xsl:template>
    
      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template> 
    
    </xsl:stylesheet>
    

    …and a program to call it:

    static void Main(string[] arguments)
    {
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load("xsltfile1.xslt");
    
        XmlDocument d = new XmlDocument();
        d.LoadXml(@"
    <popular>
      <country handle='india'/>
      <country handle='xxx'/>
    </popular>");
    
        XsltArgumentList args = new XsltArgumentList();
        args.AddParam("popular", "", d.DocumentElement);
        xslt.Transform("xmlfile1.xml", args, Console.Out);
        Console.ReadKey();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the title, I'm not exactly sure how to explain this with a
I'm sorry about the title I'm just not sure how to describe this one.
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry if this sounds like a really stupid question, but I need to make
Sorry about the poor title ;) I'm trying to recreate a matlab plot I've
I really didnt know what to put to the title so sorry about that.
Sorry for the vague thread title; hard to succinctly describe my question. I have
Sorry to interrupt all of you. I have a question about session. In my
Sorry about the vague subject but I couldn't think what to put. Here's my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.