<!-- Separate the links in two groups for input data and service in thumbnails view -->
<xsl:template name="separate-links">
<xsl:param name="links"/>
<xsl:param name="moreThreshold"/>
<primary>
<xsl:for-each select="$links">
<xsl:sort select="@user-selected = 'true'" order="descending"/>
<xsl:if test="position() < $moreThreshold or (count($links) = 8 and position() = $moreThreshold)">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</primary>
<xsl:if test="count($links) > $moreThreshold">
<secondary>
<xsl:for-each select="$links">
<xsl:sort select="@user-selected = 'true'" order="descending"/>
<xsl:choose>
<xsl:when test="position() >= $moreThreshold">
<xsl:copy-of select="."/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</secondary>
</xsl:if>
</xsl:template>