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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:17:38+00:00 2026-05-11T11:17:38+00:00

Can someone please tell me how to print out a variable in my XSL

  • 0

Can someone please tell me how to print out a variable in my XSL transform? Seems like an easy enough thing to do but I just can’t seem to do it. Here’s the code I have:

<?xml version='1.0' encoding='UTF-8' ?> <xsl:stylesheet version='1.0'   xmlns:fn='http://www.w3.org/2005/02/xpath-functions' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>    <xsl:template name='ControlledListStructure'>     <xsl:param name='xmlElem' />     <xsl:param name='dataName' />      <xsl:element name='{$xmlElem}'>       1: <xsl:text>{$xmlElem}</xsl:text>.       2: {$xmlElem}.     </xsl:element>   </xsl:template>  </xsl:stylesheet> 

If I called this template with a value for xmlElem of ‘Wibble’ (a string – not a node), I would get the following output:

<Wibble>       1: {$xmlElem}.       2: {$xmlElem}. </Wibble> 

So my parameter is coming over properly, I just can’t access it properly. Can someone tell me how I can get $xmlElem to print out properly so that I see:

<Wibble>       1: Wibble.       2: Wibble. </Wibble> 

Thanks for any input.

  • 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. 2026-05-11T11:17:39+00:00Added an answer on May 11, 2026 at 11:17 am

    All answers are missing something important: read further:

    Can someone please tell me how to print out a variable in my XSL transform? Seems like an easy enough thing to do but I just can’t seem to do it.

    In XSLT 1.0 there are two main ways of producing the contents of an <xsl:variable>, depending on whether it contains a scalar value (string, number or boolean), or has a structured value — a node-set (one or more nodes from xml document(s) ):

    1. <xsl:value-of select='$yourscalarVariableName'/> Use this to produce a scalar value. Actually produces a text node, containing this scalar value.

    2. <xsl:copy-of select='$yourStructuredVariableName'/> Use this to produce a copy of all nodes contained in the variable.

    It is very important to know that if an xsl:variable contains a list of nodes and the <xsl:value-of ...> instruction is used, only the string value of the first node will be produced. This is a frequently committed error and a FAQ.

    There is a third way: if the <xsl:variable> should be used in producing an attribute:

      <someLiteralResultElement someAttribute='{$theVariable}'/> 

    The XPath expression in the curly braces (called AVT — attribute-value-template) is evaluated and the result is put into the attribute value.

    In XSLT 2.0, the <xsl:value-of .../> instruction , when run not in compatibility mode, produces a list of text nodes — one for each node contained in the xsl:variable. When run in compatibility mode (has the attribute version='1.0' specified), the <xsl:value-of> instruction behaves in the same way as it does in XSLT 1.0.

    In Xslt 2.0 <xsl:copy-of> behaves in the same way as in XSLT 1.0. However it is recommended to use the new <xsl:sequence> instruction, because the former produces a new copy of every node, while <xsl:sequence> does not produce new copies of nodes.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Leap seconds are the reason for this: A leap second… May 11, 2026 at 1:59 pm
  • added an answer PHP does not support named parameters for functions per se.… May 11, 2026 at 1:59 pm
  • added an answer There's no way to do this out of the box.… May 11, 2026 at 1:59 pm

Related Questions

Could someone please tell me which objects types can be tested using Regular Expressions
Can someone please point me to the easiest way to have a timer in
Can someone please point me to articles or books that discusses different programming paradigm
Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how
Can someone please let me know how to get the different segments of the
I am running into this issue of releasing an already released object but can't
The .NET Setup project seems to have a lot of options, but I don't
I am trying to get a java.net.URI object from a String . The string
I am getting the contents of a file in an IStream object. I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.