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

RE: [xsl] Nested List


Subject: RE: [xsl] Nested List
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 8 Jan 2007 23:44:39 -0000

Your current test

<xsl:when test="parent::orderedlist/orderedlist">

tests whether the listitem that's the current node has a parent which is an
orderlist and which also has a child that is an orderedlist. This is true of
the listitems in any list that has a sublist, which is the opposite of what
you want. 

I suspect you were thinking of

<xsl:when test="parent::orderedlist/parent::orderedlist">

which would do what you want, I think. Though I would be tempted to replace
the whole xsl:choose with

<xsl:apply-templates select="." mode="number"/>

and then

<xsl:template match="orderedlist/listitem" mode="number" priority="2">
  <xsl:number format="1."/> 
</xsl:template> 

<xsl:template match="orderedlist/orderedlist/listitem" mode="number"
priority="3">
  <xsl:number format="A."/> 
</xsl:template>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: siarom egrub [mailto:egrubs@xxxxxxxxx] 
> Sent: 08 January 2007 23:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Nested List
> 
> Hi all,
> 
> I am trying to get a nested list to display correctly.
> I came up with two different ideas, however, neither work 
> correctly. The snippet for the simpler idea is below with 
> explanations. In the other idea I was using for-each loops in 
> the ordered list template.
> 
> Could someone please tell me what I am doing wrong here?
> 
> Thanks in advance for your help!!
> 
> Regards,
> S. Egrub
> 
> <!--EXPECTED OUTPUT-->
>   1. The following... 
>   2. Interference ...follows.
>       A. Prepare ...
>       B. Combine ...
> If ...follows.
>       A. Prepare a ...
>       B. Combine ...
>       C. Centrifuge...
>   3. Phosphorous... 
>   
> <!--CURRENT OUPPUT-->
>   A. The following... 
>   B. Interference ...follows.
>       1. Prepare ...
>       2. Combine ...
> If ...follows.
>       1. Prepare a ...
>       2. Combine ...
>       3. Centrifuge...
>   C. Phosphorous... 
> 
>      
> <!-- XML -->
> 
> <orderedlist>
>     <--THIS LIST ITEM SHOULD BE NUMBER 1.-->
>     <listitem><para>The following... </para>
>     </listitem>
>     <--NUMBER 2.-->
>     <listitem><para>Interference
> ...follows.</para></listitem>
>     <orderedlist>
>     <--THIS LIST ITEM SHOULD BE LETTER A.(start of new 
> ordered list)-->
>        <listitem><para>Prepare ...</para></listitem>
>     <--LETTER B.-->
>        <listitem><para>Combine ...</para></listitem>
>     </orderedlist> 
>     <para>If ...follows.</para>
>     <orderedlist>
>     <--THIS LIST ITEM SHOULD BE LETTER A.(start of new 
> ordered list)-->
>       <listitem><para>Prepare a ...</para></listitem>
>     <--LETTER B.-->      
>       <listitem><para>Combine ...</para></listitem>
>     <--LETTER C.-->      
>       <listitem><para>Centrifuge...</para></listitem>
>     </orderedlist>
> <--NUMBER 3-->    
>    <listitem><para>Phosphorous...</para></listitem>
>  </orderedlist>
>  
> <!-- XSL SNIPPET -->
>  <!--======+Ordered list Template (numbered list)+======--> 
> <xsl:template match="orderedlist">
>   <fo:block>
>     <fo:list-block
> provisional-distance-between-starts="4mm"
> font-size="8pt" text-align="justify">
>  	<xsl:apply-templates/>
>     </fo:list-block>
>   </fo:block>
> </xsl:template>
>  	
>  	
> <!--======+List item Template (items within ordered 
> list)+======--> <xsl:template match="listitem">
>    <fo:list-item start-indent=".2mm">
>       <fo:list-item-label>
>  	 <xsl:choose>
>  	   <xsl:when test="parent::orderedlist/orderedlist">
>               <xsl:number format="A." count="listitem"
> from="orderedlist"/>
>  	   </xsl:when>
>  	   <xsl:otherwise>
>  	      <xsl:number format="1."/>
>  	   </xsl:otherwise>
>  	 </xsl:choose>
>       </fo:list-item-label>
>       <fo:list-item-body start-indent="1.5em"
> line-height=".01pt">
>  	  <xsl:apply-templates/>
>       </fo:list-item-body>
>    </fo:list-item>
> </xsl:template>
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection 
> around http://mail.yahoo.com 


Current Thread
Keywords