xsl-list
[Top] [All Lists]

Re: [xsl] different evaluations on sibling elements ...

2013-08-27 11:37:52
Yes, sorry, a mistake I often make: within the function, all the relative path 
expressions should start with $entry. So

<xsl:variable name="this" select="dateTime($entry/isodate, $entry/time)"/>
<xsl:variable name="next" 
select="dateTime($entry/following-sibling::entry/isodate, 
$entryfollowing-sibling::entry/time)"/>

Michael Kay
Saxonica


On 27 Aug 2013, at 17:26, Raimund Kammering wrote:

Wow I really missed a lot - would have made my live much easier if I would 
have started right away using the XSLT 2.0!

Okay I got the concept and the <xsl:for-each-group … group-by=""> seams to be 
the key to an easy solution - Thanks!
But unfortunately I still don't get it working! Here are some of my 
findings/questions:

There is one misplaced bracket: 
<xsl:value-of select="current-grouping-key(), ': ', 
format-number(sum(current-group()/f:duration-in-hours(.), '0.00'))"/>
should be:
<xsl:value-of select="current-grouping-key(), ': ', 
format-number(sum(current-group()/f:duration-in-hours(.)), '0.00')"/>

The following is not working:
<xsl:variable name="this" select="dateTime(/isodate, time)"/>
I guess this should be:
<xsl:variable name="this" select="dateTime(entry/isodate, entry/time)"/>

But even though I'm getting an exception saying:

"XPDY0002: Axis step child::element('':entry) cannot be used here: the 
context item is undefined"

Okay I also found some discussions concerning functions and undefined context 
item. But what I understood from these was just that one must add an 
parameter and call the function passing the node to process, but this is 
exactly as you (Michael) proposed!?

Raimund Kammering

On 27.08.2013, at 11:52, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

Ignoring all your existing logic, I think the summary can be done something 
like this:

<xsl:for-each-group select="//entry" group-by="statistics_category">
<xsl:value-of select="current-grouping-key(), ': ', 
format-number(sum(current-group()/f:duration-in-hours(.), '0.00'))"/>
</xsl:for-each-group>

<xsl:function name="f:duration-in-hours" as="xs:double" >
<xsl:param name="entry" as="element(entry)"/>
<!-- TODO: add logic for the case where there's no following-siblng -->
<xsl:variable name="this" select="dateTime(/isodate, time)"/>
<xsl:variable name="next" select="dateTime(following-sibling::entry/isodate, 
following-sibling::entry/time)"/>
<xsl:sequence select="($next - $this) div xs:duration('PT1H')"/>
</xsl:function>

Michael Kay
Saxonica

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--