xsl-list
[Top] [All Lists]

RE: Indentation question

2005-09-02 04:09:53
Use the normalize-space() function.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: knocte [mailto:knocte(_at_)gmail(_dot_)com] 
Sent: 02 September 2005 10:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Indentation question

2005/9/2, Joris Gillis <roac(_at_)pandora(_dot_)be>:
Hi,

Tempore 09:06:47, die 09/02/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit knocte 
<knocte(_at_)gmail(_dot_)com>:

Sometimes when I deal with XSLT, if I use this indent method:

<xsl:output method="xml" indent="no" />

Then I obtain all the results in one line, no EOL's.

But I have found a case where this is not true, why?

Because your xslt snippet contains non-whitespace-only text 
nodes with line-breaks, which are copied in an unaffected 
matter (whitespaces preserved) to the result tree.

To avoid this, change

            <xsl:when test="LoginName">
              1
            </xsl:when>

to

<xsl:when test="LoginName">1</xsl:when>

or to

<xsl:when test="LoginName">
        <xsl:text>1</xsl:text>
</xsl:when>


regards,


Thanks Joris. I have fixed some annoying whitespaces with this advice.
But now I have another related issue:

In HTML I have the advantage of writing a paragraph using EOL's and
don't worrying about the end view of the page because EOL's will be
converted to whitespaces.

Example:

  <p>
    This is a easy-to-edit paragraph because
    I can break it into multiple lines.
  <p>

The result in the browser will not contain any line-breaks.

Now, doesn't XSLT provide a "similar" way to edit paragraphs without
sending unnecessary line-breaks to the final result?

I mean, given this:

  <xsl:when test="whatever">
    <p>
      This is my paragraph which I want to break in multiple
      lines so as to edit it later more easily.
    </p>
  </xsl:when>

If I use this, I obtain the unnecessary blank spaces which are present
between the words "multiple" and "lines". If I use <xml:text> with the
whole paragraph I will obtain the same because I still use
line-breaks:

  <xsl:when test="whatever">
    <p>
      <xsl:text>
        This is my paragraph which I want to break in multiple
        lines so as to edit it later more easily.
      </xsl:text>
    </p>
  </xsl:when>

The unique solution I have is to use <xsl:text> for EVERY LINE. This
is not very comfortable to maintain and also I have to worry about
putting a final whitespace at the end of each line (except the last
one) so as not to concatenate incorrectly:

  <xsl:when test="whatever">
    <p>
      <xsl:text>This is my paragraph which I want to break in multiple
</xsl:text>
      <xsl:text>lines so as to edit it later more easily.</xsl:text>
    </p>
  </xsl:when>

Is there any better solution out there for this issue?

  Thanks, 

    Andrew

--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>