[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Programming without Assignment Statements


Subject: Re: [xsl] Programming without Assignment Statements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 5 Jan 2001 14:12:52 GMT


> The following seems verbose, inefficient and impractical:

Actually it only seems that way, it is none of them:-)
Mainly it looks verbose because of the XML syntax, but
that's just something to live with.

On the other hand why set a variable to 1 or 0 and then keep testing for
it, when you can put the values you want there in the first place.

Instead of testing $zerobased all the time you could go
<xsl:variable name="x">
  <base>0</base>
  <contant>3.14159</contstant>
</xsl:variable>

or

<xsl:variable name="x">
  <base>1</base>
  <contant>2.171828</contstant>
</xsl:variable>


Then instead of

   <xsl:variable name="y">
      <xsl:choose>
         <xsl:when test="$zeroBased"> 3.14159 </xsl:when>
         <xsl:otherwise> 2.71828 </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>

you can just do $x/constant (in XSLT1.1 or use node-set() or document()
workarounds in XSLT 1.0)

It depends on the context, whether you know these dependent values at
the time you are making the choice of setting zero or one based.

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
Keywords