homepage Welcome to WebmasterWorld Guest from 54.205.99.71
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Format xsl results into 4-across rows?
donok




msg:3965188
 7:41 am on Aug 4, 2009 (gmt 0)

Sorry - a bit lost - REALLY new to xml and its friends...

I have an xsl file that is returning xml results formatted into a 220px wide rectangle. I want them to display 4-across and then start a new row.

This has to be simple, right? Do I do this in the php page, or the xsl page, or css...?

thanks for any help,

Don

 

httpwebwitch




msg:3965352
 2:27 pm on Aug 4, 2009 (gmt 0)

I'd do it in the XSL.

Here's a template that works by finding every 4th node, using position() and mod
Then it constructs a variable containing nodes from positions n, n+1, n+2, n+3
Then it loops through these and displays a <td> for each.

I hope it works. It might need a little debugging.
Cheers

<xsl:template name="twocolumns">
<xsl:for-each select="people[position() mod 4 = 1]">
<tr>
<xsl:variable name="others" select="following-sibling::option[position() &lt; 4]" />
<xsl:for-each select=".$others">
<td>
<xsl:value-of select="person' />
</td>
<xsl:if test="not($others)">
<td></td>
</xsl:if>
</xsl:if>
</tr>
</xsl:for-each>
</xsl:template>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved