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

Re: whitespace problem when formating to plain-text

Subject: Re: whitespace problem when formating to plain-text
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Thu, 01 Nov 2001 09:28:00 GMT
unsorted list remove whitespace
Kevin wrote:

>
>
>John,
>
>The normalize function will remove leading and trailing whitespace. It is
>hard to read your xml but you may have to force spaces where needed using
>something like <xsl:text>&#x20</xsl:text>.
>
BTW there isn't any special magic to using the character entity: you
can just as well write <xsl:text> </xsl:text>.  Its a matter of which
you think is clearer, and if the difference is worth the extra typing
(the best form of documentation is a comment of course).

I have done this kind of thing, and found that blindly adding spaces
around either the text elements or the <link> elements ends up giving
you spaces you do not want (typically at the beginning and end of
sentences or where there is other puctuation).
One way to normalize the space at the ends of the text rather than
losing it is to:
  add a character (x say) at the beginning and end of the string
  use normalize-space on it
  use substring to remove the first and last character from the result
  (i.e. the x's you added to begin with)
Then if the text starts/ends with white space the result will get one
space.

You will need to use temporary variables to do this, unless you don't
mind repeating the normalize - this is because the substring call
needs to know the length of the normalised string.

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 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.