[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Newbie Question: Building Variables Based on Multiple El

Subject: Re: Newbie Question: Building Variables Based on Multiple Elements
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Mon, 31 Jan 2000 23:16:55 -0500
xsl for each variable build
jeffrod@xxxxxxxxxx wrote:
> Is there a way for me to build upon a variable string based on
> multiple elements of the same name?

Sure.  An xsl:variable can be assigned the result of a 'select' or can
be used as a container for template instantiation.  In the latter case,
you can roam around, generating any kind of output you want, and instead
of going directly into the result tree ("output") it goes into the
variable, which is then of type Result Tree Fragment (RTF).  An RTF can
be used like a string, which is adequate for your purposes.

So, you can just do the following:


<xsl:stylesheet version="1.0" 

<xsl:variable name="elements">
  <xsl:text>Value of $elements: </xsl:text>
  <xsl:for-each select="/test/elem">
    <xsl:value-of select="."/>
    <xsl:if test="position() &lt; last()">
      <xsl:text> </xsl:text>

<xsl:template match="/">
  <xsl:value-of select="$elements"/>



Note that the elements don't have to have the same name here; you could
use the results of any 'select' that is legal within xsl:for-each.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.