[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: different evaluations on sibling elements ...

Subject: Re: different evaluations on sibling elements ...
From: Raimund Kammering <raimund.kammering@xxxxxxx>
Date: Tue, 27 Aug 2013 18:26:19 +0200
Re:  different evaluations on sibling elements ...
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@xxxxxxxxxxxx> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.