[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] RE: loop elements based on attribute
Subject: Re: [xsl] RE: loop elements based on attribute From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Sat, 16 Aug 2008 21:32:50 +0530 |
Thanks, Martin for a very clear explanation. Now I am more clear about, group-adjacent attribute of for-each-group. On Sat, Aug 16, 2008 at 7:40 PM, Martin Honnen <Martin.Honnen@xxxxxx> wrote: > Mukul Gandhi wrote: > >> <xsl:for-each-group select="*" group-adjacent="self::Pkt"> > >> produces following error [1], >> >> Error on line 8 of test.xsl: >> XTTE1100: An empty sequence is not allowed as the @group-adjacent >> attribute of >> xsl:for-each-group in built-in template rule > > >> 1) Why do we get error [1] in the 1st case ? > > Well the error message explains that, an empty sequence is not allowed as > the grouping key for group-adjacent and your expression self::Pkt evaluates > to an empty sequence for the 'A' and 'B' elements in the input XML. > >> 2) In the second case, why putting the expression in 'boolean' >> function works, while without boolean, we get an error ? > > Now, using group-adjacent="boolean(self:Pkt)" the grouping key for the 'Pkt' > elements is the boolean value true and for the other elements (i.e. the 'A' > and 'B' elements) it is the boolean value false (as boolean(self:Pkt) is > boolean() applied to an empty sequence which yields false). > > >> And, why do >> >> we get 4 groups, and not 2 ? > > See the definition for group-adjacent: > > "the items in the population are examined, in population order. If an item > has the same value for the grouping key as its preceding item within the > population (in population order), then it is assigned to the same group as > its preceding item; otherwise a new group is created and the item becomes > its first member" > > So the 'A' element which has the grouping key false becomes a member of the > first group, then the 'Pkt' element following that becomes a member of the > second group, all 'Pkt' elements following that also become a member of the > second group, then the 'B' and 'A' element become a member of the third > group, and finally the 'Pkt' elements become members of the fourth group. > > If you only want to group the 'Pkt' elements then you could use e.g. > <xsl:if test="current-grouping-key()"> > <List> > <xsl:copy-of select="current-group()"/> > </List> > </xsl:if> > as only for the 'Pkt' elements the group-adjacent="boolean(self::Pkt)" gives > true. > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/ -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] RE: loop elements based o, Martin Honnen | Thread | [xsl] RE: loop elements based on at, Kjellaug Johansen |
Re: [xsl] RE: loop elements based o, Martin Honnen | Date | RE: [xsl] Getting node w/ lowest at, Bordeman, Chris |
Month |