xsl-list
[Top] [All Lists]

Re: [xsl] Looping through multiple elements

2008-03-18 08:28:33
On 18/03/2008, Jones Mark Mr (ITCS) 
<Mark(_dot_)Jones(_at_)uea(_dot_)ac(_dot_)uk> wrote:
 example, there are also these fields (dc:creator, dc:creator1,
 dc:creator2, dc:creator3). I need to make the xml output for this
 generate the xml below (the names are just examples)

 <component name="value" group="creators">Smith, Jones, Black,
 White</component>

In 1.0 you can do:

<xsl:for-each select="dc:creator | dc:creator1 | dc:creator2 | dc:creator3">
  <xsl:value-of select="."/>
  <xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>

In 2.0 it's easier:

string-join((dc:creator, dc:creator1, dc:creator2, dc:creator3), ', ')


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>