This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: strangeness with <xsl:variable>
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] strangeness with <xsl:variable>
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Wed, 20 Dec 2000 21:29:32 GMT
- References: <20001220194517.11887.qmail@web122.yahoomail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> And that works. This doesn't seem right, because shouldn't
> XSLT ignore the whitespace before the "chap"? Or is
> <xsl:variable> an exception to the rule?
No look again at th espec, XSL doesn't ignore white space.
It stips white space nodes, ie text nodes that only contain white
space. But if a text node contains any non white char eg "chap" then all
white space is preserved.
Since a literal newline in an attribute value would be normalised
to a space by an XML parser, your newline in the attribute value
is written out as a character reference.
> thought the natural way to do this is to use a
> <xsl:variable> within a <xsl:choose>.
The scope of a variable binding is its surrounding element, so if you do
it that way the variable goes out of scope at the </xsl:when>
so can never be used.
It's more natural the other way. You always want a variable, but the
value is conditional on the tests. It's not that depending on a
condition you may or may not want a variable.
so it's x= (if foo 3 else 5 fi)
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list