xml:
<mode>1</mode>
<mode>2</mode>
<mode>3</mode>
<mode>4</mode>
<mode>5</mode>
<mode>6</mode>
<mode>7</mode>
<mode>8</mode>
<mode>9</mode>
<mode>10</mode>
<mode>11</mode>
<mode>12</mode>
i need to separate it on parts (for ex. on 4):
xslt:
<xsl:variable name="vNodes" select="mode"/>
<xsl:variable name="vNumParts" select="4"/>
<xsl:variable name="vNumCols" select="ceiling(count($vNodes) div $vNumParts)"/>
<xsl:for-each select="$vNodes[position() mod $vNumCols = 1]">
<xsl:variable name="vCurPos" select="(position()-1)*$vNumCols +1"/>
<ul>
<xsl:for-each select="$vNodes[position() >= $vCurPos and not(position() > $vCurPos + $vNumCols -1)]">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</xsl:for-each>
this code is written by Dimitre Novatchev – great coder))
but for the number of nodes less then number of parts (for ex. i have 2 modes) this code does not work – it outputs nothing.
How it upgrade for that case (without choose construction)?
Although the problem is incorrectly defined if the number of nodes is smaller than the number of parts, here is a transformation that I guess produces the output the OP most probably wants (Why didn’t he just specify this behavior???):
when this transformation is applied on the following XML document (he can’t even provide a well-formed XML document!):
the output is what I guess the OP wanted…