Re: [xsl] TOC indents in XHTML?

Subject: Re: [xsl] TOC indents in XHTML?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 27 Nov 2001 14:52:07 GMT
] Currently, I have a template for the indents that looks like this:
]   <xsl:template name="toc-indent">
]     <xsl:variable name="level" select="count(ancestor::part)"/>
]     <xsl:choose>
]       <xsl:when test="$level=0"><xsl:text
] disable-output-escaping="yes"></xsl:text></xsl:when>
]       <xsl:when test="$level=1"><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
]       <xsl:when test="$level=2"><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:
] text></xsl:when>
]       <xsl:when test="$level=3"><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
] bsp;&amp;nbsp;</xsl:text></xsl:when>
]       <xsl:when test="$level=4"><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
] bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
]       <xsl:when test="$level=5"><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
] bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
]       <xsl:otherwise><xsl:text
] disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
] bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:other
] wise>
]     </xsl:choose>
]   </xsl:template>
] It works, but it's not smart and far from beautiful. There is a better way
] to do it, isn't it? :-)

it would probably be better not to use non breaking space and just
indent with nested lists and css styling, but if you want to use nbsp

looking at the faq or archives for this list will show that
]  <xsl:text disable-output-escaping="yes">&amp;nbsp;
is not the recommended way of getting a non breaking space.
just <xsl:text>&#160;</xsl:text>
is all you need.

you just want one of those for each ancestor part element, so that's

<xsl:template name="toc-indent">
  <xsl:for-each select="ancestor::part">&#160;</xsl:for-each>


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:

Current Thread