need an xslt for a collection control that produces the below:

<ul>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

</ul>

<ul>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

<li>{quicklink}</li>

</ul>

The key here is to have a count on the items. After the 7th item, it needs to start a new list.

Can anybody help with these one..please and Thanks in advance

It would be helpful if we knew what your input XML document looked like :P Please post a sample of input document (USE CODEBOXES) so we can use it to get your output. Is this XSLT 1.0 ? What processor are you running this on?

<fo:basic-link 
 external-destination="url('http://www.whatever.com')"
 color="blue" text-decoration="underline">
  Webucator
</fo:basic-link>

at as many as you like.

you can put these in tables if you like, they will still be recognized.

as for the after 7 newlist im not sure yet, but you problaly get there using a delimiter and the newlist functions, maybe on a substring?.

Henk.

Edited 6 Years Ago by minamo99: n/a

Well you haven't been very descriptive in your problem at all. So I have no idea if this will help you, or even it it produces what you want. But this is all the help I can give, it should provide you a method/idea to get what you want.

This is a classic grouping issue, which is especially cumbersome in XSLT 1.0. (If you need more information just do a Google search for 'grouping xslt 1.0' and you'll find lots of examples)

My transformation works on via a recursive call template. The idea is that it gathers up all the fo:basic-link element nodes in the input document and passes them into a call template. Inside this call-template, it takes the first 7 element nodes and outputs them inside a <ul> element node. Then it increases the position to the next group of 7, and calls itself. Once it gets to the last group of 7 items or less, it finishes the recursion and doesn't call itself again. Here's all the documents I used to test, the XSLT and the output.

Input Document (since you didn't provide one)

<links xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:basic-link external-destination="url('http://www.whatever1.com')">Webucator1</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever2.com')">Webucator2</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever3.com')">Webucator3</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever4.com')">Webucator4</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever5.com')">Webucator5</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever6.com')">Webucator6</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever7.com')">Webucator7</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever8.com')">Webucator8</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever9.com')">Webucator9</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever10.com')">Webucator10</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever11.com')">Webucator11</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever12.com')">Webucator12</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever13.com')">Webucator13</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever14.com')">Webucator14</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever15.com')">Webucator15</fo:basic-link>
	<fo:basic-link external-destination="url('http://www.whatever16.com')">Webucator16</fo:basic-link>
</links>

XSLT 1.0

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output indent="yes"/>

	<xsl:template match="/">
		<html>
			<body>
				<xsl:call-template name="getLinks">
					<xsl:with-param name="setNode" select="/descendant::fo:basic-link"/>
				</xsl:call-template>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="getLinks">
		<xsl:param name="setNode"/>
		<xsl:param name="setPosition" select="1"/>

		<xsl:variable name="setMax" select="count($setNode)"/>

		<xsl:choose>
			<xsl:when test="$setNode">
				<xsl:choose>
					<xsl:when test="(($setMax - $setPosition) &lt;= 0)">
						<ul>
							<xsl:apply-templates select="$setNode[$setPosition]"/>
							<xsl:apply-templates select="$setNode[$setPosition+1]"/>
							<xsl:apply-templates select="$setNode[$setPosition+2]"/>
							<xsl:apply-templates select="$setNode[$setPosition+3]"/>
							<xsl:apply-templates select="$setNode[$setPosition+4]"/>
							<xsl:apply-templates select="$setNode[$setPosition+5]"/>
							<xsl:apply-templates select="$setNode[$setPosition+6]"/>
						</ul>
					</xsl:when>
					<xsl:otherwise>
						<ul>
							<xsl:apply-templates select="$setNode[$setPosition]"/>
							<xsl:apply-templates select="$setNode[$setPosition+1]"/>
							<xsl:apply-templates select="$setNode[$setPosition+2]"/>
							<xsl:apply-templates select="$setNode[$setPosition+3]"/>
							<xsl:apply-templates select="$setNode[$setPosition+4]"/>
							<xsl:apply-templates select="$setNode[$setPosition+5]"/>
							<xsl:apply-templates select="$setNode[$setPosition+6]"/>
						</ul>
						<xsl:call-template name="getLinks">
							<xsl:with-param name="setNode" select="$setNode"/>
							<xsl:with-param name="setPosition" select="$setPosition+7"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="fo:basic-link">
		<li>
			<xsl:value-of select="@external-destination"/>
		</li>
	</xsl:template>
</xsl:stylesheet>

Output Document

<html xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <body>
    <ul>
      <li>url('http://www.whatever1.com')</li>
      <li>url('http://www.whatever2.com')</li>
      <li>url('http://www.whatever3.com')</li>
      <li>url('http://www.whatever4.com')</li>
      <li>url('http://www.whatever5.com')</li>
      <li>url('http://www.whatever6.com')</li>
      <li>url('http://www.whatever7.com')</li>
    </ul>
    <ul>
      <li>url('http://www.whatever8.com')</li>
      <li>url('http://www.whatever9.com')</li>
      <li>url('http://www.whatever10.com')</li>
      <li>url('http://www.whatever11.com')</li>
      <li>url('http://www.whatever12.com')</li>
      <li>url('http://www.whatever13.com')</li>
      <li>url('http://www.whatever14.com')</li>
    </ul>
    <ul>
      <li>url('http://www.whatever15.com')</li>
      <li>url('http://www.whatever16.com')</li>
    </ul>
    <ul></ul>
  </body>
</html>
This article has been dead for over six months. Start a new discussion instead.