Re: [xsl] Table of contents - for-each question

Subject: Re: [xsl] Table of contents - for-each question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 24 Jan 2006 17:21:16 GMT
Please don't take things off list (see the xsl-list guidelines).
As I suspected your c03 elements are children of the c02 elements (so
not children of the current node at the point of the for-each.

You could use something like //*[self::c02 or self::c03]
                                [head or @level="subseries" or @level="series"]

But if your table of content nesting mirrors the nesting of your input
elements the normal thing to do is not try to work out indents and such
up front, but just simply use apply-templates to walk down the tree,
making a table of contents as you go, something like

<xsl:template match ="*[self::c02 or self::c03]
                                [head or @level="subseries" or
                                @level="series"]" mode="toc">
<div class="toc">
  <a href="#{generate-id()}">....</a>
  <xsl:if test="*[self::c02 or self::c03]
                                [head or @level="subseries" or
                                @level="series"]">
   <div class="toc">
   <xsl:apply-templates select="*[self::c02 or self::c03]
                                [head or @level="subseries" or
                                @level="series"]"/>
   </div>
  </xsl:if>
</div>



together with some css for class toc that indents. This way, if the
current node has any subsections you styart up a child div in the output
(which will then increase the total indent) and process each of those
children.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread