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 March 27th, 2012, 01:49 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Why Is a Recursive Loop Printing an Extra Space

Hello.

I'm printing a LastName which has a maximum of 18 characters.
In Position 21 (starting position 1 from first character of Lastname) I need to print an ID number.

So, if LastName is Sotherland and my ID number is 1234, on the printed line I would have (starting in position 1): Sotherland 1234 (with 10 spaces after Sotherland).

I have the following code but it's adding an extra space after the space value. I know this as I replaced the space value with R and my result was
Sotherland R R R R R R R R R R 1234.

Here's my code.
How can I get rid of the extra space each time the template is called?

Template Calling Block.
Code:
                        <fo:block>
                          <xsl:value-of select="EOB/PROVIDER/NUMBER"/>
                          <xsl:variable name="strLength" select="19 - string-length(EOB/PROVIDER/NUMBER)"/>
                          <xsl:if test="EOB/PROVIDER/EXTERNALID[.!='']">
                            <xsl:call-template name="addSpaces">
                              <xsl:with-param name="count">
                                <xsl:value-of select ="$strLength"/>
                              </xsl:with-param> 
                            </xsl:call-template>
                            <xsl:value-of select="EOB/PROVIDER/EXTERNALID"/> 
                          </xsl:if>
                        </fo:block>
Template Code
Code:
  </xsl:template>
  <xsl:template name="addSpaces">
    <xsl:param name="count"/>
      & # 1 6 0 ;
    <xsl:if test="$count>0">
      <xsl:call-template name="addSpaces">
        <xsl:with-param name="count" select="($count)-1"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
NOTE: I'm using "& # 1 6 0 ;" with spaces in between just to show you the value I'm using for a space as it shows up as a space on that line if I don't.

Thanks,
Rita
 
Old March 27th, 2012, 02:01 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Why Is a Recursive Loop Printing an Extra Space

Hmm.
I tried adding the space value to a <fo:inline> and that did the trick.
The space between the <fo:inline> actually holds "& #160;" (without the spaces between & and #).
Code:
<fo:inline> </fo:inline>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash animation created extra space on web page itHighway Flash (all versions) 0 May 22nd, 2009 05:54 AM
How to remove extra space from PSV dved XSLT 2 February 18th, 2009 10:52 AM
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
Stripping out extra space around an italic word simone_s XSLT 2 April 25th, 2006 03:50 AM





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