|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








