Re: [xsl] RE: loop elements based on attribute

Subject: Re: [xsl] RE: loop elements based on attribute
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 15 Aug 2008 17:15:59 +0200
Kjellaug Johansen wrote:

In an xslt-file I use templates for each match on different elements.
When I reach a Pkt-element I call the template "pktTemplate". How can I
get the right result? I'm almost there...but the problem is that the
first Pkt-element that matches (where the template-call is done) is
never listed in the result. But the siblings are listed at the right
way.

<xsl:template name="pktTemplate">
<xsl:if test="not(preceding-sibling::*[1][self::Pkt])"> <List> <xsl:for-each-group
select="following-sibling::Pkt
[preceding-sibling::*[1][self::Pkt]][generate-
id(preceding-sibling::Pkt[not(preceding-
sibling::*[1][self::Pkt])][1])= generate-
id(current())]" group-starting-with="Pkt[not(@type =
'uavs')]">

Well you only process the following siblings above. So perhaps you want <xsl:for-each-group select=". | following-sibling::Pkt [preceding-sibling::*[1][self::Pkt]][generate- id(preceding-sibling::Pkt[not(preceding- sibling::*[1][self::Pkt])][1])= generate- id(current())]" group-starting-with="Pkt[not(@type = 'uavs')]">

That is just a guess however.


--


	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread