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 8100177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:40:39+00:00 2026-06-05T22:40:39+00:00

I have a variable from which I need to dynamically generate nodes <xsl:template match=banner_discount_1

  • 0

I have a variable from which I need to dynamically generate nodes

<xsl:template match="banner_discount_1 | banner_discount_2 | banner_discount_3"> 
    <xsl:variable name="link">banner_discount_<xsl:value-of select="substring-after(name(.) ,'banner_discount_')" />_link</xsl:variable>

    <xsl:value-of select="$link" />
</xsl:template>

<xsl:value-of> selects the string, but I want to be able to select the node which name matches the name of a variable.
In my case the node looks something like this:

<banner_discount_1_link />
<banner_discount_2_link />
...

Here is the xml I’m using

<banner_discount_1> 12 </banner_discount_1>
<banner_discount_2> 21 </banner_discount_2>
<banner_discount_3> 32 </banner_discount_3>

<banner_discount_1_link> link1 </banner_discount_1_link>
<banner_discount_2_link> link2 </banner_discount_2_link>
<banner_discount_3_link> link3 </banner_discount_3_link> 
  • 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-06-05T22:40:40+00:00Added an answer on June 5, 2026 at 10:40 pm

    @MartinHonnen is on the right track, but you need to set the selection context as well.

    Since you’re in a template that’s selecting the banner_discount_ nodes, that is your context. From your XML sample, it looks like the nodes you want to select are siblings, so this should work:

    <xsl:value-of select="../*[local-name() = $link]"/>
    

    It is preferable to target the nodes directly, but if they could be anywhere in the document, then you may resort to

    <xsl:value-of select="//*[local-name() = $link]"/>
    

    This is a last resort because it is potentially O(n) with respect to the number of nodes in the document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable which I get from database I want to output this
I have a variable which contains 3 tag names which are separated from each
I read file from user using FileReference. I have a variable which I want
I have a DLL from which I need to P/Invoke the following C method:
If I have a variable from which multiple threads read and only one thread
I have a .jsp page that passes the variable from the servlet. Lets assume
How can return a variable from a thead (I have the threads handle too).
I have 2 php files. I am unable to get B's global variable from
I have a variable that contains an array from form data, seen below: $option1
I have a variable like Doctor and Surgical I take this value from Mysql

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.