I’d tackle it like this:
In a template that matches *[w:p], do an adjacent grouping of * with the
key exists(w:pPr/w:listPr/w:ilvl/@w:val).
Then choose: when not(current-grouping-key()), pass the group unchanged.
If current-grouping-key(), call a template or a function that you’ll
call recursively later on.
As xsl:param $elements, it takes the current-group().
First it calculates a variable $min as the min() of
$elements/w:pPr/w:listPr/w:ilvl/@w:val (you might need to cast them as
xs:double before applying min()).
Then it opens a list element. Within it, it groups the $elements,
group-starting-with="*[number(w:pPr/w:listPr/w:ilvl/@w:val) = $min]".
Then a fringe case can happen: the first list items w:ilvl/@w:val is
larger than $min. This means that the list starts with a 2nd-level 'a.'
instead of a first-level '1.'. You can decide to handle this case, or
you may just flag this as an input error.
In the normal case that each group indeed starts with the same level,
create an li element, put the current-group()'s number and first and
content in.
If there are more elements in the current-group(), call the template or
the function on them, with elements = current-group()[position gt 1].
I hope it performs as expected and I didn’t put a mistake in. Writing
and testing the actual XSLT code would probably have taken less time,
but maybe it’s better for didactic reasons if you figure out the actual
code yourself.
Gerrit
On 27.09.2013 08:43, Joga Singh Rawat wrote:
2.o
-----Original Message-----
From: Imsieke, Gerrit, le-tex [mailto:gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de]
Sent: Friday, September 27, 2013 12:08 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] List grouping
XSLT 1.0 or 2.0?
On 27.09.2013 07:11, Joga Singh Rawat wrote:
Dear List,
Anyone who can provide the idea to handle below list in worldml
<w:p><w:pPr><w:listPr><w:ilvl w:val="0"/><wx:t
wx:val="1."/></w:listPr></w:pPr><w:r><w:t>First
level</w:t></w:r></w:p> <w:p><w:pPr><w:listPr><w:ilvl w:val="1"/><wx:t
wx:val="a."/></w:listPr></w:pPr><w:r><w:t>Second
level</w:t></w:t></w:r></w:p>
<w:p><w:pPr><w:listPr><w:ilvl w:val="0"/><wx:t
wx:val="2."/></w:listPr></w:pPr><w:r><w:t>First
level</w:t></w:r></w:p> <w:p><w:pPr><w:listPr><w:ilvl w:val="0"/><wx:t
wx:val="3."/></w:listPr></w:pPr><w:r><w:t>First lvel</w:t></w:r></w:p>
Should be
<list>
<li><num>1.</num><p>First level<p>
<list>
<li><num>a.</num><p>Second level<p></li> </list></li>
<li><num>2.</num><p>First level<p></li> <li><num>3.</num><p>First
level<p></li> </list>
Thanks
.JSR
--~------------------------------------------------------------------
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>
--~--
--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~------------------------------------------------------------------
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>
--~--