Hi Mukul, I'm not a developer on the XalanJ project, so if I'm out of line here, I apologize in advance and please let me know.
I'm quite sure the output should be as stated by the XSLT 3.0 spec. The spec defines how to act in the case of multiple keys within a single xpath context, being that the context should occur for every key. In fact, the function creates a 'group' for every occurrence of a given key-element within the current context. The groups are then formed by the given xpath in which a key occurs. If this would not be the case, the spec should be altered and state what the output should be in case of multiple keys within a single xpath context (for example, the first occurrence of a key will be used). Kind regards, Dennis On Mon, 8 May 2023 at 18:28, Mukul Gandhi <muk...@apache.org> wrote: > Hi all, > I've been developing XSLT 3.0's for-each-group element's > implementation, on xalan-java repo's branch xalan-j_xslt3.0. > > With the current xsl:for-each-group's implementation that's available > on the above mentioned XalanJ repos's branch, I've a doubt with > following XSLT transformation example (which is mentioned within XSLT > 3.0 spec, within section "14.4 Examples of Grouping"), > > XML input document, > > <titles> > <title>A Beginner's Guide to <ix>Java</ix></title> > <title>Learning <ix>XML</ix></title> > <title>Using <ix>XML</ix> with <ix>Java</ix></title> > </titles> > > Desired XSLT transformation output, > > <h2>Java</h2> > <p>A Beginner's Guide to Java</p> > <p>Using XML with Java</p> > <h2>XML</h2> > <p>Learning XML</p> > <p>Using XML with Java</p> > > The XSLT 3.0 spec says that, following is a solution to this XSLT > transformation problem, > > <xsl:template match="titles"> > <xsl:for-each-group select="title" group-by="ix"> > <h2><xsl:value-of select="current-grouping-key()"/></h2> > <xsl:for-each select="current-group()"> > <p><xsl:value-of select="."/></p> > </xsl:for-each> > </xsl:for-each-group> > </xsl:template> > > With the above mentioned XSLT stylesheet, the XalanJ's implementation > produces following XML transformation result, > > <h2>Java</h2> > <p>A Beginner's Guide to Java</p> > <h2>XML</h2> > <p>Learning XML</p> > <p>Using XML with Java</p> > > As we can see, XalanJ's XSLT transformation result, doesn't have two > XML elements within the first group (whose grouping key is "Java"), > but only one. According to XSLT 3.0 spec, one of the items of original > XML elements list is assigned to two groups, whereas, XalanJ assigns > this XML element to only one of the group. > > Is for this, XSLT 3.0 spec's example's desired XSLT transformation > output correct, or XalanJ's (repos xalan-java and its branch > xalan-j_xslt3.0) XSLT transformation output correct? > > Any thoughts, shall be nice to know. > > > -- > Regards, > Mukul Gandhi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org > For additional commands, e-mail: dev-h...@xalan.apache.org > > -- Dennis van der Laan