[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

grouping every three nodes?

Subject: grouping every three nodes?
From: Seth Ladd <shl6472@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Feb 2000 19:42:28 -0500 (EST)
xsl if xsl value of
Hello,

I've searched the FAQ and tutorials, and I can't seem to find an answer to
this problem.  Actually, I don't think it's possible, but I was hoping
someone could lend some advise.

demo xml file:
<group>
 <item></item>
 <item></item>
 <item></item>
 <item></item>
 <item></item>
</group>

I would love to be able to do this in XSL:

<xsl:template match="group">
	"grab every three item tags and send to named template"
</xsl:template>

<xsl:template name="group-of-three">
 <td>
  <ul>
  <xsl:for-each select="item">
   <li><xsl:value-of select="."/></li>
  </xsl:for-each>
  </ul>
 </td>
</xsl:template>

I'm not sure how to grab every three nodes from a nodeset.  I'm trying to
build a table for every three items in a list.  because of the fact that
XSL outputs trees, I'm having a hard time.  The following would work,
except it's not valid XML

<!-- won't work -->
<xsl:template match="group">
 <table>
  <tr>
   <xsl:for-each select="item">
    <xsl:if test="(position() mod 3) = 0">
     <td>
     <ul>
    </xsl:if
    <xsl:value-of select="."/>
    <xsl:if test="(position() mod 4) = 0">
     </ul>
     </td>
    </xsl:if>
   </xsl:for-each>
  </tr>
 </table>
</xsl:template>

Is there anything that will help me break up a nodeset into a group of
three?  I've solved my problem by using the hack disable-output-encoding,
but I'd like to stay away from that.

Thanks for any help or pointers you can give me,
Seth


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.