Jump to content

XSLT Tables


kvnmck18
 Share

Recommended Posts

I'm trying to make a table with 9 columns and "x" amount of rows. With what I have below this repeats one image repeat 9 times per row, I want the first then the next position then next.I tried using a this key:

<xsl:key name="image" match="item/image" use="url"/>and for the "for-each" I used:<xsl:for-each select="item/image[count(. | key('image', url)[1]) = 1]">

(this did not work)Here's my XSLT:

<xsl:template match="channel"><div id="show_image_holder"><div id="show_thumb_holder"><table cellpadding="0" cellspacing="0"><xsl:for-each select="item/image">	<tr>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>		<td class="image_td">			<img src="{url}" title="{description}" class="show_thumb_image" /> 		</td>	</tr></xsl:for-each></table></div></div></xsl:template>

Hope someone can help~Thanks!

Link to comment
Share on other sites

I'm trying something like this:

<xsl:param name="columns" select="10" /><xsl:template match="channel">	<div id="show_image_holder">		<center>			<img src="images/shows/DSC04805.JPG" class="show_large_image" /><br />		</center>	<div id="show_thumb_holder">		<table cellpadding="0" cellspacing="0">			<xsl:apply-templates select="item/image[(position() mod $columns) = 1]" /> 		</table>		</div> 	</div></xsl:template><xsl:template match="item/image"> 			<tr>				<xsl:for-each select=". | following-sibling::product[position() < $columns]"> 					<td class="image_td">						<img src="{url}" title="{description}" class="show_thumb_image" /> 					</td>				</xsl:for-each>			</tr></xsl:template>

It's still not working...

Link to comment
Share on other sites

I'm using this:

<xsl:template match="channel">	<div id="show_image_holder">			<div id="show_thumb_holder">	<center>		<table cellpadding="0" cellspacing="2">			<xsl:for-each select="item/image"> 				<td class="image_td">					<a href="#">						<img src="{url}" title="{description}" class="show_thumb_image" /> 					</a>				</td>					<xsl:if test="position() mod 8 = 0">						<tr />					</xsl:if>			</xsl:for-each>		</table>	</center>		</div> 	</div></xsl:template>

There are still problems...like repeats, it's weird.Why does this not work properly?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...