Re: [xsl] strangeness with <xsl:variable>

Subject: Re: [xsl] strangeness with <xsl:variable>
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Dec 2000 21:29:32 GMT


> 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


Current Thread