Re: [xsl] xsl for-each and preceding-sibling

Subject: Re: [xsl] xsl for-each and preceding-sibling
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 16 Jan 2013 13:46:37 +0100
Raimund Kammering wrote:

     <statistics val="warn">
       <text>something happened</text>
     <statistics val="info">
       <text>went better</text>
     <statistics val="error">
       <text>big trouble</text>

But the problem I get with the 'summary' I want to produce using the statistics.xsl stylesheet, which looks like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="";>

<xsl:template match="entry/statistics">

<xsl:for-each select=".">

That for-each select="." does not achieve anything.

<xsl:variable name="end"><xsl:value-of select="preceding-sibling::statistics[1]/time"/></xsl:variable>

The "statistics" element does not have preceding sibling elements of the same name, I think you want
<xsl:variable name="end"

<xsl:variable name="start"><xsl:value-of select="time"/></xsl:variable>

         <xsl:variable name="start" select="time"/>
is shorter, easier and more efficient.

Current Thread