[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]



Cheers,

Eliot

On 7/1/11 10:56 AM, "Emma Burrows" <Emma.Burrows@xxxxxxxxxxx> wrote:

> Damn, I knew I'd find the solution as soon as I sent this:
>
> <xsl:for-each-group select="node()"
>
>
group-adjacent="boolean(self::para[@style='BULLET']|self::para[@style='INDENT
'
> ]|self::para[@style='BULLINDENT']|para[@style='INDENT2'])">
>
> should of course be
>
> <xsl:for-each-group select="node()"
>
>
Group-adjacent="boolean(self::para[@style='BULLET']|self::para[@style='INDENT
'
> ]|self::para[@style='BULLINDENT']|self::para[@style='INDENT2'])">
>
> *facepalm*
>
> Having said that, suggestions on a scalable solution would be welcome before
I
> come across the dreaded <para @style='BULLINDENT2'>/<para @style='INDENT3'>
> combination. :)
>
>
> -----Original Message-----
> From: Emma Burrows [mailto:Emma.Burrows@xxxxxxxxxxx]
> Sent: 01 July 2011 16:40
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Flat bullets to nested ul
>
> I am using XSLT 2.0 with Oxygen 12 and Saxon EE. I am currently working on
a
> document that features nested bulleted lists with sub-paragraphs, but
> expressed as a flat list of paragraph elements. I am converting this to a
> DITA-compliant structure. I have had some success getting the first level
> working, and the bulleted paragraphs on the second level, but I'm just
lacking
> the extra bit to get sub-paragraphs included in the second level <li>.
>
> But let me illustrate the problem better.
>
> Here is my input:
>
> <wrapper>
>   <para style="PLAIN">Normal para not involved in the bullets at
all.</para>
>   <para style="BULLET">bullet level 1</para>
>   <para style="INDENT">para involved in level 1</para>
>   <para style="BULLINDENT">bullet level 2</para>
>   <para style="INDENT2">mixed content</para>
>   <para style="INDENT2">mixed content</para>
>   <para style="PLAIN">The list is finished</para>
> </wrapper>
>
> Here is the desired output:
>
> <p>Normal para not involved in the bullets at all.</para>
> <ul>
>   <li>bullet level 1
>     <p>para involved in level 1</para>
>    <ul>
>       <li>bullet level 2
>          <p>mixed content</p>
>          <p>mixed content</p>
>       </li>
>    </ul>
>   </li>
> </ul>
> <p>The list is finished</para>
>
> But currently, I get:
>
> <p>Normal para not involved in the bullets at all.</para>
> <ul>
>   <li>bullet level 1
>     <p>para involved in level 1</para>
>    <ul>
>       <li>bullet level 2</li>
>    </ul>
>   </li>
> </ul>
> <p>mixed content</p>
> <p>mixed content</p>
> <p>The list is finished</para>
>
> So I'm nearly there but not quite. The relevant parts of my template are as
> follows:
>
>   <xsl:template match="wrapper">
>     <xsl:for-each-group select="node()"
>
>
group-adjacent="boolean(self::para[@style='BULLET']|self::para[@style='INDENT
'
> ]|self::para[@style='BULLINDENT']|para[@style='INDENT2'])">
>       <xsl:choose>
>         <xsl:when test="current-grouping-key()">
>           <xsl:call-template name="makeList">
>             <xsl:with-param name="paralist" select="current-group()"/>
>           </xsl:call-template>
>         </xsl:when>
>         <xsl:otherwise>
>           <xsl:apply-templates select="current-group()"/>
>         </xsl:otherwise>
>       </xsl:choose>
>     </xsl:for-each-group>
>   </xsl:template>
>
>   <xsl:template name="makeList">
>     <xsl:param name="paralist"/>
>     <xsl:variable name="firstpara"
> select="($paralist/self::para[@style='BULLET'])[1]"/>
>     <xsl:apply-templates select="$paralist[not(. >> $firstpara)] except
> $firstpara"/>
>     <xsl:if test="$firstpara">
>       <ul>
>         <xsl:for-each-group select="$paralist[not($firstpara >> .)]"
>           group-starting-with="para[not($firstpara/@style ne @style)]">
>           <li>
>             <xsl:apply-templates select="current-group()[1]"/>
>             <xsl:if test="current-group()[2]">
>               <xsl:call-template name="makeSubList">
>                 <xsl:with-param name="paralist"
> select="current-group()[position()!=1]"/>
>               </xsl:call-template>
>             </xsl:if>
>           </li>
>         </xsl:for-each-group>
>       </ul>
>     </xsl:if>
>   </xsl:template>
>
>   <xsl:template name="makeSubList">
>     <xsl:param name="paralist"/>
>     <xsl:variable name="firstpara"
> select="($paralist/self::para[@style='BULLINDENT'])[1]"/>
>     <xsl:apply-templates select="$paralist[not(. >> $firstpara)] except
> $firstpara"/>
>     <xsl:if test="$firstpara">
>       <ul>
>         <xsl:for-each-group select="$paralist[not($firstpara >> .)]"
>           group-starting-with="para[not($firstpara/@style ne @style)]">
>           <li>
>             <xsl:apply-templates select="current-group()[1]"/>
>             <xsl:if test="current-group()[2]">
>               <xsl:call-template name="makeSubList">
>                 <xsl:with-param name="paralist"
> select="current-group()[position()!=1]"/>
>               </xsl:call-template>
>             </xsl:if>
>           </li>
>         </xsl:for-each-group>
>       </ul>
>     </xsl:if>
>   </xsl:template>
>
> It may be that this is completely the wrong way to go about it, so I'm open
to
> suggestions. I *think* they only have two levels of nesting but I noticed
an
> INDENT3 in their DTD so I am afraid I may need something more scalable.
>
> Thanks!
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>

--
Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 512.554.9368
www.reallysi.com
www.rsuitecms.com


Current Thread
Keywords