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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:32:02+00:00 2026-05-22T11:32:02+00:00

I have declared a variable in my XSLT as given below : <xsl:variable name=inline-array>

  • 0

I have declared a variable in my XSLT as given below :

    <xsl:variable name="inline-array">
    <Item>A</Item>
    <Item>B</Item>
    <Item>C</Item>
</xsl:variable>

I am accessing this variable as given below :

<xsl:param name="array"
    select="document('')/*/xsl:variable[@name='inline-array']/*" />
<xsl:value-of select="$array[1]" />

This is working fine as long as my inline array has static contents. But my requirement is to dynamically assign values in the XSLT to the tag “Item” ie. Something like :

<xsl:variable name="inline-array">
    <Item>$item1</Item>
    <Item>$item2</Item>
    <Item>$item3</Item>
</xsl:variable>

But, I tried all possible options without any luck. Any suggestions will be greatly appreciated. Any other options to fulfill my requirement is also welcome. Thanks.

  • 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-22T11:32:02+00:00Added an answer on May 22, 2026 at 11:32 am

    One way to achieve this is to make use of an extension function, namely the node-set function, which returns a set of nodes from a result tree fragment.

    First you would need to define the namespace for the extension functions like so

    <xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    

    In this case, I am using the Microsoft extension functions, but others are available depending on which platform you are using. (http://exslt.org/common is another common one for non-Microsoft platforms).

    Next, you define your “array” parameter (or variable, you wanted), like so.

    <xsl:param name="array" select="msxsl:node-set($inline-array)"/>
    

    Finally, you can then access this array like so

    <xsl:value-of select="$array/Item[1]"/>
    

    Putting this altogether in a simple example gives you this

    <xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    
       <xsl:output method="text" />
    
       <xsl:variable name="inline-array">
          <Item>
             <xsl:value-of select="$Item1"/>
          </Item>
          <Item>
             <xsl:value-of select="$Item2"/>
          </Item>
          <Item>
             <xsl:value-of select="$Item3"/>
          </Item>
       </xsl:variable>
    
       <xsl:param name="Item1">1</xsl:param>
       <xsl:param name="Item2">2</xsl:param>
       <xsl:param name="Item3">3</xsl:param>
       <xsl:param name="array" select="msxsl:node-set($inline-array)"/>
    
       <xsl:template match="/">
          <xsl:value-of select="$array/Item[1]"/>
       </xsl:template>
    
    </xsl:stylesheet>
    

    When run, this simply outputs the following result:

    1

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

Sidebar

Related Questions

I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I have a variable declared in one jsp page. This variable is an array.
I have declared one variable in xslt, assigned some value to it but while
I have a variable in my xsl that may or may not be declared.
i have declared a variable in the class 'Main' with name 'context2'. But i
In the unit below I have a variable declared in the IMPLEMENTATION section -
I have string variable declared globally.I have to append a substring to this string
I have declared a variable @date SELECT @date = CASE WHEN MAX(dt) IS NULL
I have declared a variable in my .xsl file. Now I want to update
I'm working on XSLT 1.0 version I have declared an int variable that 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.