Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 8th, 2005, 04:33 PM
Registered User
Join Date: May 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating table from cards

I have an XML file that contains a root element and a many "card" elements. For simplicity, we can assume that a card contains a single line of text. I need help with creating an XSLT stylesheet that will sandwich the cards (to be called "cells" when transformed) in groups of 3 within a "row" element, and groups of 3 row elements within a table element. So I want to achieve something like:
       <cell>Sentence 1.</cell>
       <cell>Sentence 2.</cell>
       <cell>Sentence 3.</cell>
        <cell>Sentence 9.</cell>
        <cell>Sentence 10.</cell>

Suggestions? Thanks for your help.

Old June 9th, 2005, 08:31 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

for-each card[position() mod 9 = 1]
    for-each (.|following-sibling[position()<9])[position() mod 3 = 1]
        for-each (.|following-sibling[position()<3])
             value-of .

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating table ph0neman Classic ASP Basics 3 January 22nd, 2008 05:06 PM
Wrox Greeting Cards rai.ashis BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 December 17th, 2007 03:25 AM
Creating table with existing table without value kumar_kumar Oracle 1 January 4th, 2005 07:12 AM
Creating a new table from a dataset... vb_developer SQL Server ASP 4 September 21st, 2004 07:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.