Hi Michael,

Two things:
One: Are you allowed to use "let" (in XPath3) inside an XSLT pattern predicate? Unfortunately, I have not been able to find much information on the limitations of "let" when used in XSLT3.

Two: I noticed something odd about my earlier test case.

The source file is:
<Employees>
    <Employee name="Bob" Bday="1976-10-10"/>
    <Employee name="Sal" Bday="1976-10-10"/>
    <Employee name="Steve" Bday="1976-10-11"/>
</Employees>

The original XSLT I used was:

    <xsl:for-each-group select="Employees/Employee" group-starting-with="Employee[xs:date(@Bday) gt xs:date(preceding-sibling::Employee/@Bday)]">
            <xsl:copy-of select="."/>
        </xsl:for-each-group>

I expected this to make two groups, one with Bob and Sal, the other with Steve. Instead, it just made one group with all three (meaning that there were no matches to the group-starting-with pattern"

I noticed that there is no filter on the "preceding-sibling::Employee" step, so when evaluating the third node this leads to xs:date being sent a sequence of two items.

When I corrected this code to:

    <xsl:for-each-group select="Employees/Employee" group-starting-with="Employee[xs:date(@Bday) gt xs:date(preceding-sibling::Employee[1]/@Bday)]">
            <xsl:copy-of select="."/>
        </xsl:for-each-group>

It worked as expected, giving two groups.

I would have expected an error when xs:date was fed a sequence of two dates, instead "xs:date('1976-10-11') gt xs:date('1976-10-10','1976-10-10')"  evaluated to "no match".

-David
 

On Thu, May 17, 2012 at 11:46 PM, Michael Kay <mike@saxonica.com> wrote:


On 17/05/2012 21:39, David Rudel wrote:
> Michael,Hi
> Just a head's up that it appears no error is triggered in some cases
> where an illegal axis is used inside a pattern.
>
> I was trying to use <xsl:for-each-group> today and forgot that only
> child and attribute axes are allowed in patterns.

There's no such restriction. You can do anything you like (well, almost)
inside a predicate of a pattern. The restriction you are thinking of
applies outside the predicates.
> When I ran the following script, no error was reported.
>
> <xsl:template match="/">
> <xsl:for-each-group select="Employees/Employee"
> group-starting-with="Employee[xs:date(@Bday) gt
> xs:date(preceding-sibling::Employee/@Bday)]">
> <xsl:copy-of select="."/>
> </xsl:for-each-group>
>
> </xsl:template>
>
> Instead, the processor appears to just refuse to find any matches, so
> only one group is ever formed, even if there are nodes that would
> logically match the pattern in question.
>
I'm afraid I can't tell you why it's not working without seeing the data.

Michael Kay
Saxonica

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.