Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old August 11th, 2008, 05:27 AM
Authorized User
Join Date: Jun 2006
Location: , , .
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts
Default extra space???

Hi guys..

Does anyone know why the following code adds an extra space..

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template name="pound">
        <xsl:text disable-output-escaping="yes">&amp;</xsl:text>pound;
    <xsl:template match="/root">
    <p><xsl:call-template name="pound" /><xsl:value-of select="/root/dataItem[name='test']/price" /></p>
this is the outcome.. £ 100

here is the simple XML...



Reply With Quote
  #2 (permalink)  
Old August 11th, 2008, 05:35 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,133
Thanks: 1
Thanked 189 Times in 188 Posts

XSLT treats whitespace as significant when it appears in a text node which contains none-whitespace characters.

So basically the character return after the "pound;" is considered significant. You can fix this by simply moving the end tag for the xsl:template to straight after the text:

<xsl:template name="pound">
    <xsl:text disable-output-escaping="yes">&amp;</xsl:text>pound;</xsl:template>

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old August 11th, 2008, 05:55 AM
Authorized User
Join Date: Jun 2006
Location: , , .
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts

excellent (and simple) fix..



Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
nested <div> creates extra space sstuber BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 May 2nd, 2008 09:56 AM
CMS extra features outofwork BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 August 26th, 2006 03:29 AM
Stripping out extra space around an italic word simone_s XSLT 2 April 25th, 2006 03:50 AM
How to eliminate all the extra zero? kuku SQL Server 2000 3 June 29th, 2005 09:47 PM
Extra Processor ryant SQL Server 2000 2 October 9th, 2003 08:55 AM

All times are GMT -4. The time now is 01:32 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.