xsl-list
[Top] [All Lists]

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

2013-01-16 06:46:48
Raimund Kammering wrote:

<list>
   <entry>
     <statistics val="warn">
       <time>19:15:57</time>
       <text>something happened</text>
     </statistics>
   </entry>
   <entry>
     <statistics val="info">
       <time>19:10:50</time>
       <text>went better</text>
     </statistics>
   </entry>
   <entry>
     <statistics val="error">
       <time>15:00:00</time>
       <text>big trouble</text>
     </statistics>
   </entry>
</list>

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="http://www.w3.org/1999/XSL/Transform";>

   <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"
            select="../preceding-sibling::entry[1]/statistics/time"/>

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


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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>