Re: How do I use non-literals in <xsl:if statements

Subject: Re: How do I use non-literals in <xsl:if statements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Oct 1999 16:39:33 +0100 (BST)
> but my XSL processor must not support them (i.e they're always empty
> after assignment).  I'm using the LotusXSL processor. 

lotus xsl supports variables. probably you are looking at the value of
the variable outside the scope where it is bound.

A common mistake is

<xsl:if test="something">
  <xsl:variable name="x" select="something_else"/>
<xsl:if>
    ...$x ...
which doesn't work as the scope of the binding of $x ends at the
element containing the binding, ie the </xsl:if> here.


	<file previous_date="03/13/99">
		<file_date>04/03/99</file_date>
	</file>


you don't say which node you try to evaluate this on:
  <xsl:if test="file_date[not(. = @previous_date)]"> do something </xsl:if>

If you are on the file node then the string value of `.' will include
that white space, in which case you might want to use normalize-space(.)
but safer would be normalize-space(file_date)= @previous_date
(normalize-space() may be called normalize() if your xsl processor is
older than a couple of weeks or so)

If you are on the file_date  node, the nyou want
        normalize-space(.)=normalize-space(../@previous_date)
The normalize-space() can be omitted if you know there is never any
white space in these strings.


David


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


Current Thread