I have another approach working as well
<!-- Splits a line to multiple lines of 35 characters up to a
maximum three lines -->
<xsl:for-each select="0 to 3">
<xsl:if test="substring($line, . * 35 + 1, 35)">
<xsl:value-of select="substring($line, . * 35 + 1, 35)" />
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
Ta
Meeraj
On Mon, Sep 6, 2010 at 10:01 AM, Meeraj Kunnumpurath <
mkunnumpurath@...> wrote:
> Thanks Michael, that is quite concise.
>
> Sent from my iPhone
>
> On 5 Sep 2010, at 22:22, Michael Kay <mike@...> wrote:
>
> An alternative approach you might like to consider is along the lines of:
>
> <xsl:for-each-group select="string-to-codepoints($line)"
> group-adjacent="position() idiv $line-size">
> <line><xsl:value-of
> select="codepoints-to-string(current-group())"/></line>
> </xsl:for-each>
>
> Michael Kay
> Saxonica
>
> On 05/09/2010 3:35 PM, Meeraj Kunnumpurath wrote:
>
> Hi,
>
> I have written one myself, assuming there is not one available in the core
> functions.
>
> <xsl:function name="gpg:split">
> <xsl:param name="line" />
> <xsl:param name="line-size" />
> <xsl:param name="current-line" />
> <xsl:param name="max-lines" />
> <xsl:if test="string-length($line) <= $line-size and
> $current-line < $max-lines">
> <xsl:value-of select="$line" />
> <xsl:text> </xsl:text>
> </xsl:if>
> <xsl:if test="string-length($line) > $line-size and $current-line
> < $max-lines">
> <xsl:value-of select="substring($line, 0, $line-size + 1)" />
> <xsl:text> </xsl:text>
> <xsl:value-of select="gpg:split(substring($line, $line-size +
> 1, string-length($line)), $line-size, $current-line + 1, $max-lines)" />
> </xsl:if>
> </xsl:function>
>
> Thanks
> Meeraj
>
> On Sun, Sep 5, 2010 at 3:24 PM, Florent Georges < <lists@...>
> lists@...> wrote:
>
>> Meeraj Kunnumpurath wrote:
>>
>> Hi,
>>
>> > Is there an extension function to split a line based on number
>> > of characters up to a specified number of lines?
>>
>> Why do you want an extension function for that?
>>
>> Regards,
>>
>> --
>> Florent Georges
>> <http://fgeorges.org/>http://fgeorges.org/
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net Dev2Dev email is sponsored by:
>>
>> Show off your parallel programming skills.
>> Enter the Intel(R) Threading Challenge 2010.
>> <http://p.sf.net/sfu/intel-thread-sfd>
>> http://p.sf.net/sfu/intel-thread-sfd
>> _______________________________________________
>> saxon-help mailing list archived at <http://saxon.markmail.org/>
>> http://saxon.markmail.org/
>> <saxon-help@...
>> <https://lists.sourceforge.net/lists/listinfo/saxon-help>
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010. <http://p.sf.net/sfu/intel-thread-sfd>http://p.sf.net/sfu/intel-thread-sfd
>
>
> _______________________________________________
> saxon-help mailing list archived at <http://saxon.markmail.org/>http://saxon.markmail.org/ <saxon-help@... <https://lists.sourceforge.net/lists/listinfo/saxon-help>https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
>
> _______________________________________________
> saxon-help mailing list archived at <http://saxon.markmail.org/>
> http://saxon.markmail.org/
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
|