[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] whitespace handling in manpages stylesheet
>> The function prototype looks almost right but there are still some >> extra spaces left hanging around. I think because the normalise_space >> doesn't act on the <function>, which is a child of the <funcdef>. I'm >> now wondering how to get at the content of the function element in the >> function template. I tried: >[...] >> But rcontent doesn't seem to contain anything as a result, since the >> function disappears from the output. > >Could you post a snippet of DocBook that shows the problem up? Here's an example: ----------------------------------------------------------------- <refentry id="RE_funcname"> <refmeta> <refentrytitle>funcname</refentrytitle> <manvolnum>3S</manvolnum> </refmeta> <refnamediv> <refname>funcname</refname> <refpurpose>something abstract</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>int <function> funcname </function> </funcdef> <paramdef>thing *<parameter>self</parameter> </paramdef> <paramdef> enum myType <parameter> type </parameter> </paramdef> <paramdef> int <parameter> index </parameter> </paramdef> <paramdef> int * <parameter> next_index </parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> </refentry> ----------------------------------------------------------------- I think the problem comes down to the substitution of spaces with escaped spaces being done before the normalize-space function is called. So the spaces and newlines all get left in. I managed to apply the normalise space to the <function>s and <parameters>s by doing the normalize-space in the template which converts to bold/italic. For example: ---------------------------------------------------------------- <!-- Remove trailing whitespace and double spaces before making bold --> <xsl:template mode="bold" match="*"> <xsl:variable name="rcontent"> <xsl:apply-templates/> </xsl:variable> <xsl:variable name="content"> <xsl:value-of select="normalize-space($rcontent)"/> </xsl:variable> <xsl:text>\fB</xsl:text> <xsl:value-of select="$content"/> <xsl:text>\fR</xsl:text> </xsl:template> --------------------------------------------------------------- Perhaps this is wrong, but it was the easiest place to do it and it doesn't seem to produce too many side-effects. By the way, I also came accross this problem in tables while using the table.xsl at: http://sourceforge.net/tracker/index.php?func=detail&aid=619532&group_id=21935&atid=516914 Applying the following diff avoids the problem. The para template containing the table also has to be told not to remove the formatting. (This diff also wraps all row entries after the first as text blocks which avoids line overflows. But that may only work for the specific tables that I have in my document. My ignorance of XSL is surpassed only by my ignorance of troff, so I don't know how to make this better.) ---------------------------------------------------------------- 3a4,36 > > <xsl:template match="para"> > <xsl:text> .PP </xsl:text> > <xsl:for-each select="node()"> > <xsl:choose> > <xsl:when test="self::informaltable|self::screen|self::programlisting|self::itemizedlist|self::orderedlist|self::variablelist"> > <xsl:text> </xsl:text> > <xsl:apply-templates select="."/> > </xsl:when> > <xsl:when test="self::text()"> > <xsl:if test="starts-with(translate(.,' ',' '), ' ') and > preceding-sibling::node()[name(.)!='']"> > <xsl:text> </xsl:text> > </xsl:if> > <xsl:variable name="content"> > <xsl:apply-templates select="."/> > </xsl:variable> > <xsl:value-of select="normalize-space($content)"/> > <xsl:if test="translate(substring(., string-length(.), 1),' ',' ') = ' ' and following-sibling::node()[name(.)!='']"> > <xsl:text> </xsl:text> > </xsl:if> > </xsl:when> > <xsl:otherwise> > <xsl:variable name="content"> > <xsl:apply-templates select="."/> > </xsl:variable> > <xsl:value-of select="normalize-space($content)"/> > </xsl:otherwise> > </xsl:choose> > </xsl:for-each> > <xsl:text> </xsl:text> > </xsl:template> > 79c112 < <xsl:text>	</xsl:text> --- > <xsl:text>	T{
</xsl:text> 82c115,122 < <xsl:apply-templates/> --- > <xsl:variable name="content"> > <xsl:apply-templates/> > </xsl:variable> > <xsl:value-of select="normalize-space($content)"/> > > <xsl:if test="position() > 1"> > <xsl:text>
T}</xsl:text> > </xsl:if> ---------------------------------------------------------------- Brian McGurk
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]