Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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
  #1 (permalink)  
Old February 17th, 2009, 03:03 PM
Authorized User
 
Join Date: Jan 2008
Location: Austin, TX, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dved Send a message via Yahoo to dved
Default How to remove extra space from PSV

I m trying to return a psv file ...and so my output is "text" in this case.

Here is my code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:strip-space elements="*"/>
<xsl:template match="paymentHistoryList">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="paymentHistoryList">
<xsl:for-each select="paymentHistoryInfo[1]//*">
<xsl:value-of select="local-name()"/>|
</xsl:for-each>
&NL;
<xsl:for-each select="paymentHistoryInfo//*">
<xsl:value-of select="current()/text()"/>|
</xsl:for-each>
&NL;
</xsl:template>

</xsl:stylesheet>

it outputs additional new lines like under:

invoiceDate|
invoiceNumber|
previousBalance|
paymentsRecieved|
balanceForward|
currentCharges|
totalBalance|

200803|
1404813176|
135.04|
135.04|
0.0|
69.38|
69.38|
200209|
384519202|
0.0|
0.0|
0.0|
97.71|
97.71|


I want it like:
invoiceDate|invoiceNumber|previousBalance|payments Recieved|balanceForward|currentCharges|totalBalanc e|
1404813176|135.04|135.04|0.0| 69.38|...


can you help ??
__________________
Thanks
Dved
  #2 (permalink)  
Old February 17th, 2009, 06:19 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The pipe character in the stylesheet is followed by a newline, so both have been copied to the output.

It's best to use <xsl:text>|</xsl:text> to output literal text, it gives you much better control over whitespace. That also applies to

<xsl:text>&NL;</xsl:text>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
  #3 (permalink)  
Old February 18th, 2009, 10:52 AM
Authorized User
 
Join Date: Jan 2008
Location: Austin, TX, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dved Send a message via Yahoo to dved
Default

Thanks..that worked for me..

Quote:
Originally Posted by mhkay View Post
The pipe character in the stylesheet is followed by a newline, so both have been copied to the output.

It's best to use <xsl:text>|</xsl:text> to output literal text, it gives you much better control over whitespace. That also applies to

<xsl:text>&NL;</xsl:text>
__________________
Thanks
Dved


Similar Threads
Thread Thread Starter Forum Replies Last Post
extra space??? crazeydazey XSLT 2 August 11th, 2008 05:55 AM
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
remove commas and space in a string kumiko Classic ASP Basics 1 January 10th, 2008 11:42 PM
Stripping out extra space around an italic word simone_s XSLT 2 April 25th, 2006 03:50 AM
Remove Space from table records mateenmohd SQL Server 2000 1 July 20th, 2003 06:55 AM





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