🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.xml
Article #10287

Re: XSLT - grupowanie następujących po sobie elementów na podstawie atrybutu

#10287
From: Borys Pogoreło
Date: Sun, 02 Nov 2014 18:44
38 lines
1767 bytes
Dnia Sun, 2 Nov 2014 19:03:10 +0100, Borys Pogoreło napisał(a):

> Póki co (chyba) udało mi się uzyskać ten efekt następującym łamańcem, ale
> czy da się to zrobić jakoś prościej?

... i sam sobie odpowiem: da się. I po co ja tak kombinowałem.

Dla potomnych:

<xsl:template match="object[@template = 'a']">

  <xsl:if test="position() = 1 or preceding-sibling::object[1]/@template !=
'a'">

  <wrapper>
    <xsl:apply-templates select="." mode="content"/>
  </wrapper>

  </xsl:if>

</xsl:template>

<xsl:template match="object[@template = 'a']" mode="content">

  <xsl:variable name="next" select="following-sibling::object[@template =
'a' and position() = 1]"/>

  <!-- formatowanie -->

  <xsl:if test="$next">
    <xsl:apply-templates select="$next" mode="content"/>
  </xsl:if>

</xsl:template>

-- 
Borys Pogoreło
borys(#)leszno,edu,pl
Technical Details
Message-ID: <19owf3dftilij$.1genwngnr9krr$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.promontel.net.pl!not-for-mail
References: <91ts3jt22p6a.xognombdq08n$.dlg@40tude.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.promontel.net.pl!not-for-mail
From: Borys Pogoreło <borys@pl.edu.leszno>
Newsgroups: pl.comp.xml
Subject: Re: XSLT - grupowanie następujących po sobie
 elementów na podstawie atrybutu
Date: Sun, 2 Nov 2014 19:44:23 +0100
Organization: snafu
Lines: 38
Message-ID: <19owf3dftilij$.1genwngnr9krr$.dlg@40tude.net>
References: <91ts3jt22p6a.xognombdq08n$.dlg@40tude.net>
NNTP-Posting-Host: bdl244.neoplus.adsl.tpnet.pl
Mime-Version: 1.0
X-Trace: thunar.promontel.net.pl 1414953853 2601 83.27.253.244 (2 Nov 2014 18:44:13 GMT)
X-Complaints-To: abuse@promontel.net.pl
NNTP-Posting-Date: Sun, 2 Nov 2014 18:44:13 +0000 (UTC)
User-Agent: 40tude_Dialog/2.0.14.1pl
X-fnord: obey.
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit