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

Re: losing significant whitespace with normalize-space

Subject: Re: losing significant whitespace with normalize-space
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 16 Jul 2002 12:39:15 -0700 (PDT)
xaudit
--- "Bradford, Denis" <denisb at rational dot com> wrote:

 
> Generating text output (an apropos file) from a docbook reference
> manual,
> I'm not able to preserve whitespace around the inline <command>
> elements in
> the <refpurpose> element below. 
> 
> Code snippet:
> 
> <refentry>
> <refnamediv>
> <refname>
> <indexterm><primary>configuration records</primary></indexterm>
> catcr
> </refname>
> <refpurpose>Displays configuration record 
> created by <command>xmake</command>, <command>ymake</command>
> , or <command>xaudit</command> 
> </refpurpose>
> 
> The desired output is a single line, like this:
> 
> catcr                     Displays configuration record created by
> xmake,
> ymake, or xaudit
> 
> What I'm getting is this: 
> 
> catcr                     Displays configuration record created
> byxmake,ymake, orxaudit
> 
> 
> Using normalize-space is the only way I've found to eliminate the
> newlines,
> but then I lose the whitespace around the command elements is
> stripped.
> The
> preserve-space (and strip-space) functions don't seem to have any
> effect,
> presumably because refpurpose is not a text-only element. Here's the
> current
> state of the stylesheet - can anybody suggest what I'm doing wrong?
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                 version="1.0">
> <xsl:output method="text" 
>             indent="no"/>
> 
> <xsl:preserve-space elements="refpurpose"/>
> 
> <xsl:template match="/">
> 
>    <xsl:variable name="newline">
> <xsl:text>
> </xsl:text>
>    </xsl:variable>
>   
>    <xsl:for-each select="book/reference/refentry/refnamediv">
>       <xsl:apply-templates select="refname"/>
>       <xsl:apply-templates select="refpurpose">
> 	     <xsl:with-param name="refnameLen"
> select="string-length(refname/text())"/>
> 	     <xsl:with-param name="refnameField" select="'
> '"/>
>       </xsl:apply-templates>
>       <xsl:value-of select="$newline"/>
>    </xsl:for-each>
> </xsl:template>
> 
> <xsl:template match="refname">
>     <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="refpurpose">
>    <xsl:param name="refnameField"/>
>    <xsl:param name="refnameLen"/>
>    <xsl:value-of select="substring($refnameField,$refnameLen)"/> <!--
> Pad
> with 25 spaces minus refname -->
>    <xsl:apply-templates/> 
> </xsl:template>
> 
> <xsl:template match="*/text()">
>    <xsl:value-of select="normalize-space(.)"/>
> </xsl:template>
> 
> <xsl:template match="indexterm"></xsl:template>
> <xsl:template match="indexterm/primary"></xsl:template>
> <xsl:template match="indexterm/secondary"></xsl:template>
> <xsl:template match="indexterm/secondary"></xsl:template>
> 
> </xsl:stylesheet>

Hi Brad,

Use:

  <xsl:template match="text()">
    <xsl:value-of select="translate(., '&#xA;&#xD;', '')"/>
  </xsl:template>


Hope this helped.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

 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.