[Home] [By Thread] [By Date] [Recent Entries]
Yves,
While you can't restrict preceding-sibling to look only at members of the current group, you might be able to get somewhere with either of these approaches: * The XPath 2.0 "intersect" operator can return those members common to two sequences of nodes, so (preceding-sibling::node() intersect current-group()) will return just those members of the current group that are on the preceding-sibling axis relative to the context. * If, rather than using grouping constructs to select from the nodes in the source, you processed them into temporary trees, you could construct those trees exactly the way you wanted, including nesting elements in such a way that preceding-sibling would be useful. Such as: <xsl:variable name="intermediate">
<xsl:for-each-group select="*" group-by=".">
<group>
<xsl:copy-of select="current-group()"/>
</group>
</xsl:for-each-group>
<xsl:variable><xsl:for-each select="$intermediate/group"> ... inside each group element, members of the group appear as siblings ... </xsl:for-each> But I'm not sure either of these are actually necessary here. You have only presented your problem in fragmentary form, so it's hard to say; but to get the result you say you want, I'd do something much simpler: <xsl:template match="/"> <xsl:for-each-group select="root/*" group-starting-with="A|B|C"> <xsl:apply-templates select="current-group()[1]" mode="groups_at_root_level"> <xsl:with-param name="this-group" select="current-group()[position() gt 1]"/> </xsl:apply-templates> </xsl:for-each-group> </xsl:template> <xsl:template match="B" mode="groups_at_root_level">
<xsl:param name="this-group" select="()"/>
<B_new>
<xsl:apply-templates select="$this-group"/>
</B_new>
</xsl:template> <xsl:template match="sub">
<sub_new>
<xsl:apply-templates/>
</sub_new>
</xsl:template>I hope that helps, Wendell At 01:18 PM 4/27/2007, you wrote: Relying heavily on xsl:for-each-group in the context of rather complicated transformations, I have run into this situation (and am stuck there...): When specifying, in group-starting-with, the pattern that may start some specific group, I would like to take into account the number of items available for grouping. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|

Cart



