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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:43:26+00:00 2026-05-27T03:43:26+00:00

I have <xsl:for-each select=ancestor-or-self::*> <xsl:variable name=expression select=name() ></xsl:variable> </xsl:for-each> below I have href and

  • 0

I have

<xsl:for-each select="ancestor-or-self::*">
  <xsl:variable name="expression" select="name()" ></xsl:variable>
</xsl:for-each>

below I have href and i want to set the value this expression variable in href #######

<a href="/myplan?expression={$expression}" class="deleteIcon">Delete</a>

I also tried with :

  <a href="concat('/myplan?expression={',$expression)}" class="deleteIcon">Delete</a>

None of them worked.

Can Anybody help me out how to do that?

Basically my task is to find the expression for current node and send the expression for the same in href?

Adding More Info :

<br/><xsl:for-each select="ancestor-or-self::*">
               <xsl:variable name="expression" select="name()" />
            </xsl:for-each>
        <b><a href="{concat('/admin/eapp/deleteQuestions?expression=',$expression)}"></a>Click Me</b>

when above xsl code is transformed it is giving below error:

 Variable or parameter 'expression' is undefined.
  • 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-27T03:43:27+00:00Added an answer on May 27, 2026 at 3:43 am

    Very simply, variables are scoped in XSL and exist only within the containing tag. Thus the variable named expression exists only within the for-each block. Also, variables can only be set once. Attempting to set a variable value a second time has no effect.

    Therfore you have to declare the variable at or above the level where you want to use it, and put all the code to generate the value inside the variable declaration. If you can use XSLT2, the following will do what you want:

    string-join(for $n in ancestor-or-self::* return name($n), '/')
    

    I know it can also be done in XSLT 1 with a recursive template, but I don’t have an example handy.

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

Sidebar

Related Questions

I have this simple code: <xsl:for-each select=GroupsServed> <xsl:value-of select=./>,<br/> </xsl:for-each></font> I'm trying to add
I have this XSLT to create rows according to position in for-each: <xsl:for-each select=Campaign>
Here's my template: <xsl:template name=rec> <xsl:for-each select=*> <div class={local-name()}> <xsl:for-each select=@*> <xsl:attribute name=data-{local-name()}> <xsl:value-of
I have nested xsl:for loops: <xsl:for-each select=/Root/A> <xsl:for-each select=/Root/B> <!-- Code --> </xsl:for> </xsl:for>
I have a loop in xsl and depending upon the attribute value, i want
At some point in an XSLT program, I have the following: <xsl:for-each select=tags/tag> <xsl:apply-templates
How do I save the iterations that have occurred in an xsl:for-each? (variables in
I have a series of XSL 2.0 stylesheets that feed into each other, i.e.
I have a template: <xsl:template match=paragraph> ... </xsl:template> I call it: <xsl:apply-templates select=paragraph/> For
I don't really know XSL but I need to fix this code, I have

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.