Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 31st, 2008, 11:21 AM
Authorized User
Join Date: Oct 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I keep leading and trailing whitespaces?


I have the following XML element:


There are 2 linefeeds before and 2 linefeeds after.


When I run the XML through my XSLT, I get the following resultant XML:

<NewText>There are 2 linefeeds before and 2 linefeeds after.</NewText>

Here is my XSLT template:

<xsl:template match="Text">
     <xsl:value-of select="."/>

How do I keep the leading and trailing whitespaces in the final result using XSLT 1.0?
Old October 31st, 2008, 11:28 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

What XSLT processor are you using?

And what output method are you using?

On the surface, this behaviour looks incorrect. But it might be explained if we know more detail about what you are doing.

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Old October 31st, 2008, 11:35 AM
Authorized User
Join Date: Oct 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts

I'm using Xalan as XSLT processor.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Leading and Trailing Zeros lene_wee SQL Server 2000 3 April 1st, 2008 08:23 AM
Printing leading and trailing blank spaces chakravarthy_vr Reporting Services 0 May 5th, 2006 01:06 AM
Preserved leading and tailing whitespaces problem ivan603 XML 0 February 7th, 2006 10:18 PM
checking for any whitespaces furia_cross Javascript How-To 1 September 7th, 2005 05:58 PM
Where are my whitespaces going? dimondwoof XSLT 3 July 17th, 2003 08:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.