[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to prevent spaces in the output

Subject: Re: How to prevent spaces in the output
From: Mansour <mansour77@xxxxxxxxx>
Date: Fri, 25 Jan 2008 00:03:37 -0400
Re:  How to prevent spaces in the output
That did the trick. Thank you.
I did not now that <xsl:text> will clear the spaces around it.
Thanks a lot.


Abel Braaksma wrote:
Hi Mansour,

This is a FAQ. Use xsl:text when you want to output text. The reason that you see whitespace is because around the "=" sign, there's significant whitespace because you created mixed content. Using xsl:text you avoid this:

<xsl:text>=</xsl:text>

Of course, alternatively you can also remove the significant whitespace.

On a side note: your xsl:for-each is not necessary. If it is the only instruction in your template, you can remove it completely (it is redundant) while changing the template match to this:

<xsl:template match="something/@*">
  <formatting....

If you left out some code and you do more in the template, you can also split it:

<xsl:template match="something">
    <xsl:apply-templates select="@*" />
    ... other things on "something"
</xsl:template>

<xsl:template match="something/@*">
    <formatting...
</xsl:template>


HTH, Cheers, -- Abel Braaksma


Mansour wrote:
Hello every one:
I am facing some difficulties with the spaces in the resulting output. For example:


<xsl:template match="something" >
<xsl:for-each select="@*">
                       <formatting:ATTRIBUTENAME>
                           <xsl:value-of select="concat(' ',name(.))" />
                       </formatting:ATTRIBUTENAME>
                       =
                       <formatting:ATTRIBUTEVALUE>
                           <xsl:value-of
                               select="concat('&quot;',.,'&quot;')" />
                       </formatting:ATTRIBUTEVALUE>
                   </xsl:for-each>
</xsl:template>


the output is : <formatting:ATTRIBUTENAME> attri </formatting:ATTRIBUTENAME> = <formatting:ATTRIBUTEVALUE> "value" </formatting:ATTRIBUTEVALUE>


Then when I convert it to html, there are spaces like this: attri = "value"


How do I avoid this ??

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.