[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] How to return a result for just the first group


Subject: [xsl] How to return a result for just the first group
From: Kevin Rodgers <kevin.rodgers@xxxxxxx>
Date: Mon, 24 Jan 2005 17:20:06 -0700

I've got XML like this:

<title_list>
<title type="TITLE" language="de">Gummi- und Kunststoffschlaeuche und -schlauchleitungen mit Drahteinlage; Hydraulik-Impulspruefung mit wechselnder Biegung (ISO 6802:1991)</title>
<title type="SUBTITLE" language="de">Deutsche Fassung EN 26802:1993</title>
<title type="TITLE" language="en">Rubber and plastics hose and hose assemblies with wire reinforcements; hydraulic impulse test with flexing (ISO 6802:1991)</title></title>
<title type="SUBTITLE" language="en">german version EN 26802:1993</title>
</title_list>

What I want to do is generate text by concatenating the title and
subtitle of the first language:

Gummi- und Kunststoffschlaeuche und -schlauchleitungen mit Drahteinlage; Hydraulik-Impulspruefung mit wechselnder Biegung (ISO 6802:1991)
Deutsche Fassung EN 26802:1993

That is easy enough to do when the title and subtitle pairs are already
grouped by language as above:

<xsl:value-of select="concat(title_list/title[@type='TITLE'][1],
                             $separator,
                             title_list/title[@type='SUBTITLE'][1])"/>

But if the order were to change, that wouldn't work:

<title_list>
<title type="TITLE" language="de">Gummi- und Kunststoffschlaeuche und -schlauchleitungen mit Drahteinlage; Hydraulik-Impulspruefung mit wechselnder Biegung (ISO 6802:1991)</title>
<title type="TITLE" language="en">Rubber and plastics hose and hose assemblies with wire reinforcements; hydraulic impulse test with flexing (ISO 6802:1991)</title></title>
<title type="SUBTITLE" language="en">german version EN 26802:1993</title>
</title_list>
<title type="SUBTITLE" language="de">Deutsche Fassung EN 26802:1993</title>

To get that same result, I think I need to use for-each-group:

<xsl:for-each-group select="mb3e:title_list/mb3e:title" group-by="@language">
  <xsl:value-of select="concat(current-group()[@type='TITLE']",
                               $separator,
                               current-group()[@type='EXT']")/>
</xsl:for-each-group>

But I don't know how to restrict it so that value-of is only applied to
the first group...

Thanks,
-- 
Kevin


Current Thread
Keywords
xml