xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krobe...@mmm.com
Subject Re: test attribute null evaluation doesn't work
Date Wed, 07 May 2003 15:36:56 GMT

Thanks for your help. I used the work around. I think the workaround is
more intuitive; but I had to declare the variables before the if condition,
since the scope of the variable seemed to be limited to the if block.

  <xsl:variable name="StartTime"/>
  <xsl:variable name="EndTime"/>
  <xsl:if test="$TimeOption='SlidingTimes' or $TimeOption='SpecificTimes'">
    <xsl:variable name="StartTime" select="substring-before($TimeValues,
';')"/>
  </xsl:if>
  <xsl:if test="$TimeOption='SlidingTimes' or $TimeOption='SpecificTimes'">
    <xsl:variable name="EndTime" select="substring-after($TimeValues,
';')"/>
  </xsl:if>


                                                                                         
                                       
                      david_marston@us.i                                                 
                                       
                      bm.com                   To:       xalan-j-users@xml.apache.org    
                                       
                                               cc:       kroberts@mmm.com                
                                       
                      05/06/2003 12:22         Subject:  Re: test attribute null evaluation
doesn't work                         
                      PM                                                                 
                                       
                                                                                         
                                       
                                                                                         
                                       




>This code evaluates to true when StartTime is not set.
>   <xsl:when test="$StartTime">
>I want it to evaluate to false. It worked fine in xalan-1.

And the variable was set by....
<xsl:variable name="StartTime">
    <xsl:if test="...">
      <xsl:value-of select="substring-before($TimeValues, ';')"/>
    </xsl:if>
</xsl:variable>

This probably represents a required tightening-up between 1.x and 2.x.
As you've structured it, $StartTime contains a result tree fragment
(RTF), which you should read about in a good XSLT book. The RTF is
never totally empty.

Fortunately, your case has the easy workaround of just inverting the
structure:
<xsl:if test="...">
   <xsl:variable name="StartTime" select="..."/>
</xsl:if>
For more complicated situations, you could have a flag value that is
outside the range of valid times, or you could have a second boolean
variable $StartTimeSet to use in the xsl:when.
.................David Marston





Mime
View raw message