[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: TOC despair

Subject: RE: TOC despair
From: "John Meyer" <jmeyer@xxxxxxxxxxx>
Date: Wed, 3 Dec 2003 19:13:32 -0500
peter binkley
Hmm, I don't think that will quite work, because the extra newline needs
to occur after the very last child section occurring in document-order
(ie, the most deeply nested one). I think you're best bet would be

<xsl:if test=". = ancestor::chapter[1]//section[position()=last()]">
	<br/>
</xsl:if>

This wont necessarily give you the best performance, but should do the
trick for the general case.

If you need better performance, and I cringe whenever I see the ancestor
axis followed by // operator like this, I would use apply-templates to
each section. You can then recursively pass a parameter indicating
whether the section is the last child. This also lets you specify
indenting patterns with a bit more precision.

John Meyer
Senior Software Engineer
Clinician Support Technology
1 Wells Avenue, Suite 201
Newton, MA 02459
www.cstlink.com

-----Original Message-----
From: Binkley, Peter [mailto:Peter.Binkley@xxxxxxxxxxx] 
Sent: Wednesday, December 03, 2003 6:50 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  TOC despair

How about test="position() = last()" in the "section" template? You
might
also need to test whether the parent is a chapter instead of another
section.

Peter


> -----Original Message-----
> From: Gustaf Liljegren [mailto:gustaf.liljegren@xxxxxxxxxxxx] 
> Sent: Wednesday, December 03, 2003 4:43 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  TOC despair
> 
> 
> This shouldn't be hard, but I can't get it right. I'll try to 
> give enough info. The XML structure looks something like this:
> 
> <book>
>   <chapter>
>     <section>
>       <section/>
>     </section>
>   </chapter>
> </book>
> 
> One section may contain other sections an so on. The problem 
> is in the TOC generation, where I want a little space after 
> each chapter, like so:
> 
> Chapter 1: Elephants....................2  <-- chapter
> African Elephants.......................2  <-- chapter/section
>   Serengeti.............................3  <-- 
> chapter/section/section Indian 
> Elephants........................4  <-- chapter/section
>                                            <-- space here, 
> please Chapter 2: Tigers.......................5
> 
> How do I say in XPath "the last section in this chapter"? 
> Here's my try, that won't work:
> 
> <xsl:template match="section" mode="toc">
>   ...
>   <xsl:if test="count(following::section) = 0">
>     <xsl:attribute name="margin-bottom">1em</xsl:attribute>
>   </xsl:if>
>   ...
> </xsl:template>
> 
> Thanks,
> 
> Gustaf
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.