|
Subject: Re: [xsl] 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 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Find the next item in a s, Michael Kay mike@xxx | Thread | Re: [xsl] Find the next item in a s, Michael Kay mike@xxx |
| Re: [xsl] Find the next item in a s, Michael Kay mike@xxx | Date | Re: [xsl] Find the next item in a s, Michael Kay mike@xxx |
| Month |