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

  • Home
  • SEARCH
  • 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 9288353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:53:44+00:00 2026-06-18T19:53:44+00:00

When I have these two variables <xsl:variable name=a select=’Total’ /> <xsl:variable name=b select=’500′ />

  • 0

When I have these two variables

<xsl:variable name="a" select="'Total'" />
<xsl:variable name="b" select="'500'" />

I would like create a node with the name of variable ‘a’ and its content from variable ‘b’.
I have to use xsltproc with XSLT 1.0 and a couple of EXSLT extensions (node-set amongst them) so I have kind of achieved part of it:

<xsl:template match="/">
  <xsl:variable name="x" >
    &lt;<xsl:value-of  select="$a" />&gt;
        <xsl:value-of  select="$b" />
    &lt;/<xsl:value-of  select="$a" />&gt;
  </xsl:variable>
  <xsl:value-of disable-output-escaping="yes" select="$x" />
</xsl:template>

indeed puts out this (I don’t care about whitespace for the moment):

<?xml version="1.0"?>

    <Total>
        500
    </Total>

But: I want to use variable ‘x’ as a node set in order to further manipulate it (of course my real life example is more complex). What I did was transform it into a node-set (using exslt.org/common), that seems to work but accessing the contents does not.

  <xsl:variable name="nodes" select="common:node-set($x)" />
  <xsl:value-of select="$nodes/Total" />

leads to nothing. I would have expected ‘500‘ since $nodes/Total should be a valid XPATH 1.0 expression. Obviously I’m missing something. I guess the point is that the dynamic creation of the node name with &lt;...&gt; does not really create a node but just some textual output so how can I achieve a true node creation here?

  • 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-18T19:53:46+00:00Added an answer on June 18, 2026 at 7:53 pm

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:variable name="a" select="'Total'" />
     <xsl:variable name="b" select="'500'" />
    
    
     <xsl:template match="/*">
      <xsl:variable name="rtfX">
        <xsl:element name="{$a}">
          <xsl:value-of select="$b"/>
        </xsl:element>
      </xsl:variable>
    
      <xsl:value-of select="ext:node-set($rtfX)/Total"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on any XML document (not used), produces the wanted, correct result:

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

Sidebar

Related Questions

I have these two arrays: <xsl:variable name=array1 select=umbraco.library:Split($currentPage/websiteThemes, ',')//value/> <xsl:variable name=array2 select=umbraco.library:Split($currentPage/websiteThemes2, ',')//value/> I
I have two variables which are comma separated lists. I would like to join
Let's say I have these two variables $number = 1; $word = one; and
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
I have two tables (using table variables for illustration. You can run these directly
I have these two tables people ============ id, name and answer_sheets ============ id, person_id,
I have two variables with putdate and puttime(format is HHMMSSTH). These two variables are
Say I have these two variables: size_t value; size_t size; And I want to
I have a makefile, with two variables like this OS = foo.o bar.o baz.o
I have these two variables being set in the controller. How do I cache

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.