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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:56:24+00:00 2026-06-09T16:56:24+00:00

The problem I’m facing seems simple, but being a novice in everything XSL –

  • 0

The problem I’m facing seems simple, but being a novice in everything XSL – I’m yet to find a proper solution. What I want to do is build a string by concatenating the results of a foreach element loop, that I can later on use as a value for an attribute of a HTML element.

Given:

<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
    <cd>
        <country>UK</country>
        <company>CBS Records</company>
    </cd>
    <cd>
        <country>USA</country>
        <company>RCA</company>
    </cd>
    <cd>
        <country>UK</country>
        <company>Virgin records</company>
    </cd>
</catalog>

Desired output: CBS;RCA;Virgin records

I need a valid portion of XSLT code that would perform this transformation in a way described above. I believe I need an xsl-variable that would hold the result of concatenating <company> and a separator character ;. How can this be done? Thank you.

  • 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-09T16:56:26+00:00Added an answer on June 9, 2026 at 4:56 pm

    I don’t believe you can use XSL variables to concatenate, because once a variable value is set, it can’t be changed. Instead, I think you want something like:

    <xsl:for-each select="catalog/cd">
        <xsl:choose>
            <xsl:when test="position() = 1">
                <xsl:value-of select="country"/>
            </xsl:when>
            <xsl:otherwise>
                ;<xsl:value-of select="country"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>
    

    Does that make sense to you?

    Edit: Just realized I may have misread how you were intending to use the variable. The snippet I posted above can be wrapped in a variable element for later use, if that’s what you meant:

    <xsl:variable name="VariableName">
        <xsl:for-each select="catalog/cd">
            <xsl:choose>
                <xsl:when test="position() = 1">
                    <xsl:value-of select="country"/>
                </xsl:when>
                <xsl:otherwise>
                    ;<xsl:value-of select="country"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
    </xsl:variable>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have a table that prints out vertical but I would like it
Problem: I can set the exposureMode property of AVCaptureDevice, but it does not stay
?Problem is pretty simple, I extend Button to create ImageButton, and I extend ButtonSkin
Problem: Find people whose birthdays are tomorrow (table a), who havent got a record
Problem, simple and annoying. Im just trying to print a list of names, collected
Problem: Trying to create a Mix that is applied to the AVPlayerItem, but it
Problem: When adding list item the Value field is being set to the Text
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: Given a list of strings, find the substring which, if subtracted from the
PRoblem: i'm trying to create (just for fun) a simple poker card (with a

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.