|
Subject: Re: [xsl] attribute management From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 21 Nov 2002 16:33:14 +0000 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] attribute management, bix xslt | Thread | Re: [xsl] attribute management, David Carlisle |
| [xsl] printing Quote in XSL, Mani Malarvannan | Date | Re: [xsl] attribute management, David Carlisle |
| Month |