xsl-list
[Top] [All Lists]

[xsl] Mutability of variables

2010-09-22 07:47:35
Hi,

I realize XSLT variables are immutable. However, I have a requirement
to split a piece of text into multiple lines based on a pre-defined
length respecting word boundaries. This means if the last word on a
line doesn't fit into the current line, the whole word needs to be
moved into a new line. I am using XSLT 2.0 with Saxon 9.* HE.

My initial thinking was to do something like below, without using recursion

  <xsl:function name="gpg:split-name-1">
        <xsl:param name="line" />
        <xsl:for-each select="tokenize(normalize-space($line), ' ')">
            // Keep track of the current length and introduce a break
and reset the length when the length exceeds the max line length
        </xsl:for-each>
  </xsl:function>

However, since the variables are immutable, I am unable to keep track
of the current length. Is there a way to do this using standard XSLT
2.0 constructs and not using recursion?

Kind regards
Meeraj

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>