I'm new for xslt i need to transform the xml to xml with grouping
My input is here below in that i need to group introduction related information that all are have to group with box element, and i have list blocks as para with specified a attribute i have to group that as list block
<p style="Chap"></p>
<p style="ChapTitle"></p>
<p style="IntroHead">IntroHead</p>
<p style="IntroText">IntroText</p>
<p style="IntroText">IntroText</p>
<p style="IntroText">IntroText</p>
<p style="IntroLast">IntroLast</p>
<p style="Normal"></p>
<p style="Bullet">Bullet</p>
<p style="Bullet">Bullet</p>
<p style="Bullet">Bullet</p>
<p style="Bullet">Bullet</p>
<p style="Bullet">Bullet</p>
<p style="BulletLast">BulletLast</p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
My expected output is
<p style="Chap"></p>
<p style="ChapTitle"></p>
<box>
<title>IntroHead</title>
<list>
<li>IntroText</li>
<li>IntroText</li>
<li>IntroText</li>
<li>IntroLast</li>
</list>
</box>
<p style="Normal"></p>
<list style="bullet">
<li>Bullet</li>
<li>Bullet</li>
<li>Bullet</li>
<li>Bullet</li>
<li>Bullet</li>
<li>BulletLast</li>
</list>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
<p style="Normal"></p>
Use
xsl:for-each-group/@group-adjacent
to group paragraphs having the same@style
. Within the body of thexsl:for-each-group
do anxsl:choose
: ifcurrent-grouping-key()
isIntrotext
orbullet
, wrap the group in alist
element, otherwise copy it unchanged.