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 January 25th, 2005, 07:23 PM
Authorized User
 
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying leading whitespace

Greetings,

I am trying to output an HTML document where leading spaces are significant. There are <Para> tags that have a "FirstLineIndent" attribute that can vary enough to not code individually for them.

The following code loops correctly, but I cannot get IE to recognize the leading spaces.

    <xsl:template match="Para">
        <p/>
        <xsl:choose> . . . there are other tests here

            <xsl:when test="@FirstLineIndent=*">

                <xsl:variable name="firstlineindent" select="@FirstLineIndent"/>
                <xsl:call-template name="for-loop">
                    <xsl:with-param name="count" select="1" />
                    <xsl:with-param name="indent" select="$firstlineindent" />
                </xsl:call-template>
                <xsl:value-of select="." />
            </xsl:when>

            <xsl:otherwise>
                <xsl:value-of select="." />
            </xsl:otherwise>
        </xsl:choose>
      </xsl:template>

      <xsl:template name="for-loop">
        <xsl:param name="count" />
        <xsl:param name="indent" />
        <xsl:if test="$count &lt;= $indent">
            <xsl:text>#xa0;</xsl:text>
            <xsl:call-template name="for-loop">
                <xsl:with-param name="count" select="$count + 1" />
                <xsl:with-param name="indent" select="$indent" />
            </xsl:call-template>
        </xsl:if>
      </xsl:template>

So the problem appears to be with the &xa0; character. I must code for IE parser, as that is what the clients are using.

I have tried all variations (or at least a lot) on different whitespace characters. Also have tried the disable output escaping directive, and an attempt at character maps.

Any thoughts on how to get these leading spaces to appear, ie. not have each paragraph show as left flush?

Thanks,
Dan

 
Old January 26th, 2005, 05:25 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I've had no problem with this character. It won't necessarily output it as an entity, it will just be the non breaking space. As this forum can corrupt these in posting the actual value should be:
Code:
ampersand hash x a 0 semi-colon
or
Code:
& # x a 0 ;
--

Joe (Microsoft MVP - XML)
 
Old January 26th, 2005, 10:39 AM
Authorized User
 
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Joe. I noticed that I had left off the & above in my posting, but it is indeed in my code. Still no go.

It was working when I manually inserted the spaces, as in:

            <xsl:when test="@FirstLineIndent='7'">
                <xsl:text>#xa0;#xa0;#xa0;#xa0;#xa0;#xa0;#xa0;</xsl:text>
                <xsl:value-of select="." />
            </xsl:when>

But since there are many possible values to indent, I went with the for-loop. That was when things went awry.

Is there any preference as to outputting the whitespace in a

<xsl:text>#xa0;</xsl:text>

block, or via a

<xsl:value-of select="#xa0;" />

statement? In my case neither is working at the moment, but for future reference on my part.

Thanks again for the reply,
Dan






Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I keep leading and trailing whitespaces? 2BOrNot2B XSLT 2 October 31st, 2008 11:35 AM
Removing leading zeros from a string value vikkiefd XSLT 2 June 12th, 2008 03:30 AM
Remove Leading and Trailing Zeros lene_wee SQL Server 2000 3 April 1st, 2008 08:23 AM
Leading and Kerning of Text vijay.bhaskar General .NET 0 September 26th, 2007 12:06 AM
losing the leading zero in binary values giles BOOK: Beginning Java 2, JDK 5 Edition 2 September 22nd, 2005 11:41 AM





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