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

Re: attribute management

Subject: Re: attribute management
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 21 Nov 2002 16:33:14 +0000
background xsl
Hi Brian,

> I've run into some difficulty attempting to define an attribute.
> Essentially, I'm getting excess spaces, and I'd really like them
> removed while keeping the formatting the same for readability. Below
> is a sample xml and xslt.
>
> XSLT:
>
>   <xsl:template name="uri">
>     <xsl:attribute name="background">
>       <xsl:choose>
[snip]
>       </xsl:choose>/
>
>       <xsl:choose>
[snip]
>       </xsl:choose>.
>
>       <xsl:choose>
[snip]
>       </xsl:choose>
>     </xsl:attribute>
>   </xsl:template>

In the above XSLT, you're inserting a bunch of whitespace after the /
and the . in your attribute value. Presumably this is the whitespace
that you want to get rid of?

In XSLT, any text that contains any non-whitespace character is added
to the result. In the above, you're not only adding the /, you're also
adding the line breaks after it and the indentation prior to the next
<xsl:choose>. To limit the whitespace that you add, you should wrap
the non-whitespace characters within <xsl:text> elements:

  <xsl:template name="uri">
    <xsl:attribute name="background">
      <xsl:choose>
        ...
      </xsl:choose>
      <xsl:text>/</xsl:text>
      <xsl:choose>
        ...
      </xsl:choose>
      <xsl:text>.</xsl:text>
      <xsl:choose>
        ...
      </xsl:choose>
    </xsl:attribute>
  </xsl:template>

The <xsl:text> elements separate the characters you're interested in
from the (ignorable) whitespace that follows them. The whitespace-only
text nodes get ignored.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.