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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:04:21+00:00 2026-05-28T17:04:21+00:00

I have a variable $colors that is a string <xsl:variable name=colors select=’red,green,blue,’ /> I

  • 0

I have a variable $colors that is a string

<xsl:variable name="colors" select="'red,green,blue,'" />

I need a new variable, $colorElements that is a node-set

<color>red</color>
<color>green</color>
<color>blue</color>

(Is that right? Can a node-set have no root?)

$colorElements will never be output directly. I just need it as, effectively, a list variable.

XSLT 1.0 with no extensions other than node-set().

  • 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-28T17:04:22+00:00Added an answer on May 28, 2026 at 5:04 pm

    Use:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:variable name="colors" select="'red,green,blue,'" />
    
      <xsl:template match="/">
    
        <xsl:variable name="colorElements">
          <xsl:call-template name="split">
            <xsl:with-param name="pText" select="$colors"/>
          </xsl:call-template>
        </xsl:variable>
    
        <xsl:for-each select="msxsl:node-set($colorElements)">
          <xsl:copy-of select="color"/>
        </xsl:for-each>
    
      </xsl:template>
    
      <xsl:template name="split">
        <xsl:param name="pText"/>
    
        <xsl:variable name="separator">,</xsl:variable>
    
        <xsl:choose>
          <xsl:when test="string-length($pText) = 0"/>
          <xsl:when test="contains($pText, $separator)">
            <color>
              <xsl:value-of select="substring-before($pText, $separator)"/>
            </color>
            <xsl:call-template name="split">
              <xsl:with-param name="pText" select="substring-after($pText, $separator)"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <color>
              <xsl:value-of select="$pText"/>
            </color>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 string variables name, quest, favorite_color, speed that might be empty. I
I have some colors that seem to come from a Delphi TColor variable (e.g
I have a string variable that contains the following html data: <p> <em><strong>This is
If I have variable of type IEnumerable<List<string>> is there a LINQ statement or lambda
I have a variable that is built in loop. Something like: $str = ;
I have a variable that contains a 4 byte, network-order IPv4 address (this was
I have an array within an array that contains settings. I need to figure
I have a CSV string that is embedded within an XML document, which is
Possible Duplicate: Avoiding repeated constants in CSS We have some theme colors that are
I have got below string values in a variable. var mystring = '{img_src:/english/images/spa.jpg, img_title:Enjoy

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.