This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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>&#10;.PP&#10;</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>&#10;</xsl:text>
>           <xsl:apply-templates select="."/>
>         </xsl:when>
>         <xsl:when test="self::text()">
>           <xsl:if test="starts-with(translate(.,'&#10;',' '), ' ') 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),'&#10;',' ') = ' ' 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>&#10;</xsl:text>
>   </xsl:template>
> 
79c112
<       <xsl:text>&#x09;</xsl:text>
---
>       <xsl:text>&#x09;T{&#x0a;</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() &gt; 1">
>       <xsl:text>&#x0a;T}</xsl:text>
>     </xsl:if>
----------------------------------------------------------------

Brian McGurk

To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]