Re: [xsl] Problem with Output special char in HTML attribute

Subject: Re: [xsl] Problem with Output special char in HTML attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 8 Dec 2004 14:28:06 GMT
  <xsl:variable name="tabindex" select="number(0)"/>

the number() isn't needed there you can use


<xsl:variable name="tabindex" select="0"/>


  i would want to increment it. 

Why?
Why would you want to do something that the syntax of the language
doesn't allow? The fact that XSLT is a side effect language is
(provably) not a restriction. Any algorithm that may be encoded in a
procedural language is encodable in a declarative one, and often in a
more natural way. So if you said what you were trying to do (rather than
how you were trying to do it) someone would show you how to do it in
XSLT.

  I have read the xsl:variable tag spec
  and it works like a constant in other programming language, or rather
  given a value it is not possible to modify it.

variables in XSLT act the same way as variables in other declarative
languages, and in mathematics. In the 60's and 70's when computers were
not really powerful enough to compile more natural programming idioms,
languages such as FORTRAN and Algol were developed where the programmer
had to think like a machine not like a human and the behaviour of
variables allowed things like x = x+ 1 because "variables" didn't
correspond to the usual mathematical notion of a variable but rather to
some named storage location in a machine. This was a rather odd concept,
but people got used to it in the end...


  I could use this workaround:

  <xsl:variable name="tabindex"><xsl:value-of
  select="$tabindex+1"/></xsl:variable>
  <xsl:value-of select="$tabindex"/> 

No, you couldn't do that as 
if $tabindex is in scope then the 
 <xsl:variable name="tabindex">
would generate an error as you are trying to redefine the variable
and 
if $tabindex is not in scope
<xsl:value-of  select="$tabindex+1"/>
would generate an error as it references an undefined variable.


  but i want to increment my variable more than one time,

You can't do that, you can't increment a variable ever, not even once.


  More there are scoping variable problems to consider too.

What problems?


  Please help me,

If you describe the transformation that you are trying to do, someone
will help...

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread