[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Find the next item in a sequence

Subject: Re: Find the next item in a sequence
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 May 2020 18:11:59 -0000
Re:  Find the next item in a sequence
Yes, that did work. One curiosity: I have to set a variable for the next
index ($next-index) instead of using position()+1 directly. Why can't I use
position()+1 directly? Thank you very much.

...

            <xsl:variable name="next-index" select="position()+1"/>

            <xsl:choose>

                <xsl:when test="$line-length +
string-length($words[$next-index]) gt $break-count">

...

 

Full template:

 

<xsl:template name="line">

        <xsl:param name="input"/>

        <xsl:param name="break-count" as="xs:integer"/>

        <xsl:variable name="words" select="tokenize($input)"/>

        <xsl:iterate select="$words">

            <xsl:param name="line-length" select="0"/>

            <xsl:param name="break-count" select="$break-count"/>

            <xsl:variable name="next-index" select="position()+1"/>

            <xsl:choose>

                <xsl:when test="$line-length +
string-length($words[$next-index]) gt $break-count">

                    <xsl:value-of select="concat(.,if(position()!=last())
then ' ' else '')"/>

                    <break/>

                    <xsl:next-iteration>

                        <xsl:with-param name="line-length"
select="string-length(.) + 1"/>

                        <xsl:with-param name="break-count"
select="$break-count - 4"/>

                    </xsl:next-iteration>

                </xsl:when>

                <xsl:otherwise>

                    <xsl:value-of select="concat(.,if(position()!=last())
then ' ' else '')"/>

                    <xsl:next-iteration>

                        <xsl:with-param name="line-length"
select="$line-length + string-length(.) + 1"/>

                        <xsl:with-param name="break-count"
select="$break-count"/>

                    </xsl:next-iteration>

                </xsl:otherwise>

            </xsl:choose>

        </xsl:iterate>

    </xsl:template>) 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.