xsl-list
[Top] [All Lists]

Re: [xsl] Nested for-each-group and current-group()

2020-05-11 10:43:30
Hi Martin,

That was the issue. Thank you very much. I had to modify things to get the
list nesting correct as well. Here is the finished template:

<xsl:template match="/root">
        <root>
            <xsl:for-each-group select="*" group-adjacent="if(self::topic)
then 1 else 0">
                <xsl:choose>
                    <xsl:when test="current-grouping-key()=1">
                        <ol>
                            <xsl:for-each select="current-group()">
                                <li>
                                    <xsl:for-each-group select="*"
group-adjacent="if(self::subtopic) then 1 else 0">
                                        <xsl:choose>
                                            <xsl:when
test="current-grouping-key()=1">
                                                <ul>
                                                    <xsl:for-each
select="current-group()">
                                                        <li>
 
<xsl:apply-templates/>
                                                        </li>
                                                    </xsl:for-each>
                                                </ul>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:apply-templates
select="current-group()"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:for-each-group>
                                </li>
                            </xsl:for-each>
                        </ol>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates select="current-group()"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each-group> 
        </root>
    </xsl:template>

Rick
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>