I try to understand the grouping functions in XSLT 2.0. My source document is
<root>
<entry level="a" name="aaa"/>
<entry level="a" name="bbb"/>
<entry level="b" name="ccc"/>
<entry level="c" name="ddd"/>
<entry level="a" name="eee"/>
<entry level="a" name="fff"/>
<entry level="b" name="ggg"/>
</root>
and the result should be something like
<section name="aaa"/>
<section name="bbb">
<section name="ccc">
<section name="ddd" />
</section>
</section>
<section name="eee"/>
<section name="fff">
<section name="ggg" />
</section>
That is: if there is a following entry with a deeper level (b is deeper than a,...) the next section should be child of the current, if it is the same level, it should be the next sibling.
I've tried with xsl:group-by select="entry" group-by="@level"
which gives me a sensible grouping, but I don't know how to open the section to go down, if there is a down.
There is another similar question which states that "In XSLT 2.0 it would be rather easy with the new grouping functions." - it might be easy but I don't get it.
Here is an example:
Should work with any levels from 'a' to 'z'.
Saxon 9.4, when running above against
outputs