It would be quite tricky to write yourself, because it's a function that depends on an aspect of the run-time context that doesn't currently exist: it means adding new information to the context, which is something that I think needs Saxon source code change.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Paulo F. Sarli
Sent: 23 June 2006 15:31
To: Mailing list for SAXON XSLT queries
Subject: Re: [saxon] current-group-matches() function

OK Michael, I understand the whole "spec" thing. Even if it stands in the way of my (current) wish, I do believe that specs are a good thing. Just out of curiosity, would it be to hard to write such an extension function myself? If it were possible to do it, what pointers could you give me so as to help start this (mostly study) project? Would a java class/method be the best way to do it? Thanks ...

Paulo

On 6/23/06, Michael Kay <mike@saxonica.com> wrote:
Thanks. As I say, it's hard to argue that the function wouldn't occasionally be useful. But it's not going to get added to the W3C spec at this stage in the process. And my experience with vendor extension functions is that it's not worth introducing an extension function without a very strong justification - most users prefer to avoid extension functions, and those that don't sometimes regret it when they want to make their code portable.
 
Michael Kay
Saxonica


Sent: 22 June 2006 13:28
To: Mailing list for SAXON XSLT queries
Subject: Re: [saxon] current-group-matches() function

Hi Andrew:
Ive found out, the hard way, that current-group-key() works only for group-by and group-adjacent, not for group-starting-with and group-ending-with.

Hi Michael:
Yes, youre right on target, thats exactly what I meant. Why do I long for such a function(ality)?

1) I tend to use rather complex grouping patterns, and oftentimes I nest "group-ending-with" within "group-starting-with" constructs, so this would help me cut down the verbosity and consequently programming errors as well

2) I have the impression (might be wrong of course) that such a function would make my stylesheets run faster, in my case maybe a lot faster due to reason in item 1 (above)

3) I gather that this "status or information" about the current group is already available as the groups are being built, so, why not make it into a function, available in the stylesheet itself?

4) Grouping within XSLT seems to be such a complete solution, with so many facilities and even niceties, that I just cant help but feel that this function should be there already, it sure does seems logical to me. Take for instance, the current-grouping-key() function mentioned by Andrew (first part of this reply). When you "group-by" or "group-adjacent" the current-grouping-key() function just begs to exist. When you "group-starting-with" and "group-ending-with", since you already know what the "grouping-key" is, the function that begs to exist is a function that tells me if the current-group matches (or not) the grouping criteria.

Mike, IMHO, those are good enough arguments. I do appreciate, of course, your insights, so Im looking forward to your reply...

Paulo

On 6/22/06, andrew welch <andrew.j.welch@gmail.com> wrote:
On 6/22/06, Michael Kay <mike@saxonica.com> wrote:
>
>
> Presumably you mean you want to know if the current item matches the
> group-starting-with pattern? As in
>
> <xsl:for-each-group select="*" group-starting-with="H2">
>   <xsl:if test="self::H2">...
>
> I tend to use the above style (repeating the test) if it's a simple pattern,
> or I might use
>
> <xsl:if test="position()=1">...
>
> They're not quite the same thing, of course, in that the first item in the
> first group doesn't necessarily match the pattern.
>
> I'd say my view on this is: you have a point, but it would need a strong
> argument to justify adding an extra function to the spec or an extension
> function to Saxon.

What does current-grouping-key() return in this case?  I would've
thought you could do something like:

test=". is current-grouping-key()"

...if current-grouping-key() magically returned a node in this case.

Just a thought.

All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
saxon-help mailing list
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
A coisa certa dita na hora errada
pior do que
a coisa errada dita na hora certa...

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


_______________________________________________
saxon-help mailing list
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help





--
A coisa certa dita na hora errada
pior do que
a coisa errada dita na hora certa...