xsl-list
[Top] [All Lists]

Re: [xsl] For-each-group groups elements before the first group-starting-with element

2010-05-11 21:14:52
Thanks to all for the help.

Peter

On Tue, May 11, 2010 at 6:51 AM, Mukul Gandhi 
<gandhi(_dot_)mukul(_at_)gmail(_dot_)com> wrote:
Thanks, David.

As per your suggestion, the following change in the stylesheet I
posted, fixes the problem you've mentioned:

<xsl:for-each-group select="body/*" group-starting-with="h1">
   <xsl:if test="self::h1">
       <section>
           <xsl:apply-templates select="current-group()"/>
        </section>
   </xsl:if>
</xsl:for-each-group>

On Tue, May 11, 2010 at 1:54 PM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
On 11/05/2010 05:10, Mukul Gandhi wrote:

   <xsl:for-each-group select="body/*" group-starting-with="h1">
               <xsl:if test="position()&gt; 1">

That's not safe because if the first element _is_ an h1 you'll miss the
first headed group. As Michael showed you need to test the element node in
teh first group, either as Michael showed with apply templates, or
<xsl:when test="self::h1">.....
<xsl:otherwise>....

David



--
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--