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

Re: [xsl] Grouping immediate follow sibling

Subject: Re: [xsl] Grouping immediate follow sibling
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Mon, 31 Jan 2005 16:44:46 +0100

Tempore 13:44:35, die 01/31/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Paul Clarke <pclarke@xxxxxxxxxxxxxxxx>:


I receive XML similar to that shown below:>
	<ProgAbs>More text</ProgAbs>
	<ProgAbs>Even more</ProgAbs>

Using 'following-sibling::ProgAbs' gives me all the siblings of that name,
as it should. I just need to know how to construct an expression to select
only those <ProgAbs> that follow on immendiately after the <p> element.

In an XPath one-liner, that could be something like

But because of performance reasons, a recursive approach would be better I think.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="bodyFrag">
<xsl:apply-templates select="p"/>

<xsl:template match="p">
<h1><xsl:value-of select="."/></h1>
<xsl:apply-templates select="following-sibling::*[1][self::ProgAbs]"/>

<xsl:template match="ProgAbs">
<xsl:value-of select="."/>
<xsl:apply-templates select="following-sibling::*[1][self::ProgAbs]"/>


regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Spread the wiki (http://www.wikipedia.org)

Current Thread