Thanks to Jeni Tennison, Michael Kay, Dimitre
Novatchev and all others who helped me understand XSL
better wrt to a solution to this problem. I have
ordered Michael Kay's and Jeni Tennison's book to get
me up to speed with XSLT.
--- Jeni Tennison <jeni(_at_)jenitennison(_dot_)com> wrote:
"Imrran Wahid" <devguy2003(_at_)yahoo(_dot_)com> wrote in
Pardon me for asking what may be a simple
but I am not very well versed in xsl. How do I
translate the count to number of spaces( )?
The simplest (to understand) way is to have an
containing a sufficiently long string of spaces.
Then take the exact
number of spaces using the substring() function.
Another way (when one doesn't know the maximum
possible number of
spaces that will be needed) is to use a recursive
named template --
e.g. one from exslt, or this one:
Or use the "iter" template from the FXSL library.
The last solution is the most generic and can be
used to implement
any iteration of the type "Do something N times".
Just to add to Dimitre's suggestion: since Imrran is
ancestors to work out how many non-breaking spaces
to add, it would be
a good idea to use one of the above methods to
create an $indent
number of spaces (e.g. in an $indent-spaces global
variable), and then
use xsl:for-each to iterate over the ancestors to
multiply that number
of non-breaking spaces:
<xsl:value-of select="$indent-spaces" />
Another method that I use when formatting a tree is
to pass down the
previous indent as a parameter from parent to child,
adding an indent
on each step. Something like:
<xsl:param name="indent" />
Again, the $indent-spaces that you add to the indent
at each level may
need to be constructed dynamically from a number
using one of
Dimitre's suggestions above.
XSL-List info and archive:
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list