building an XSLT string (variable) in a foreach loop

Viewed 24401

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.

3 Answers
Related