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: additional line(s) in <screen> and <synopsis>


On Fri, 2003-01-17 at 23:18, Olivier Chapuis wrote:
> Hello,
> 
> I use xsltproc/saxon, docbook-xsl-1.58.1 and PassiveTex/FOP for ps/pdf
> output (I am new to docbook; I try to see if it is a good idea to use
> "docbook" for our doc in the place of man page for our project. At
> present time I am disappointed by the "print" output, but I like the
> html one. But this is not the subject of this mail).
> 
<snip>

> Can I fix that pbs by "fo style-sheet customization" or/and by
> changing a magic line in PassiveTex source? I.e., where is the
> bug?
> 
> Thanks, Olivier
> 

I'm using the following templates in my customization layer for this
issue:

<!-- normalized screens -->

<xsl:template match="screen/text()">
  <xsl:variable name="before" select="preceding-sibling::node()"/>
  <xsl:variable name="after" select="following-sibling::node()"/>

  <xsl:variable name="conts" select="."/>

  <xsl:variable name="contsl">
    <xsl:choose>
      <xsl:when test="count($before) = 0">
	<xsl:call-template name="remove-lf-left">
          <xsl:with-param name="astr" select="$conts"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$conts"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="contslr">
    <xsl:choose>
      <xsl:when test="count($after) = 0">
        <xsl:call-template name="remove-ws-right">
          <xsl:with-param name="astr" select="$contsl"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$contsl"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="$contslr"/>

</xsl:template>


<!-- eats linefeeds from the left -->
<xsl:template name="remove-lf-left">
  <xsl:param name="astr"/>

  <xsl:choose>
    <xsl:when test="starts-with($astr,'&#xA;') or 
                    starts-with($astr,'&#xD;')">
      <xsl:call-template name="remove-lf-left">
        <xsl:with-param name="astr" select="substring($astr, 2)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$astr"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- eats whitespace from the right -->
<xsl:template name="remove-ws-right">
  <xsl:param name="astr"/>

  <xsl:variable name="last-char">
    <xsl:value-of select="substring($astr, string-length($astr), 1)"/>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="($last-char = '&#xA;') or
                    ($last-char = '&#xD;') or 
                    ($last-char = '&#x20;') or 
                    ($last-char = '&#x9;')">
      <xsl:call-template name="remove-ws-right">
        <xsl:with-param name="astr" 
          select="substring($astr, 1, string-length($astr) - 1)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$astr"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>




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