Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 August 6th, 2006, 11:57 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Row replication in Tables

Hi,

I wanted to generate a table with a new row (tr) replicated every 4 or so elements (td's). I have found a good example using a calendar month as a data source, and would like the same design principle in my XSLT.

i.e. for:
Code:
<Month>
<day date="1"/>
<day date="2"/>
<day date="3"/>
<day date="4"/>
<day date="5"/>
<day date="6"/>
<day date="7"/>
<day date="8"/>
<day date="9"/>
</Month>
The template applied is:
Code:
    <xsl:template match="day[position() mod 4 = 1]">
    <tr>
        <xsl:for-each select=". | following-sibling::day[position() &lt; 4]">
            <td><xsl:value-of select="@date"/></td>
        </xsl:for-each>
    </tr>
    </xsl:template>

    <xsl:template match="day"/>


The only problem in my application is that I want to fetch the datasource from a http: XML document (i.e. via localhost). Is it possible to do this in the code example above?

I cannot reference the $variable in the <xsl:template match=""> tag, but normally use a variable to assign the external XML datasource to be used.

Any help would be greatly appreciated, thanks

Jon

 
Old August 7th, 2006, 11:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your template rules look fine, you just need to apply them at some point in your code using an instruction such as

<xsl:apply-templates select="document('lookup.xml')/dates/date"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
[Word] 2003 VBA - Absolute Row/Col in Tables with geoboater Word VBA 0 August 16th, 2007 07:22 PM
XSLT Table Row with repetitive first cell the cause XSLT 5 July 3rd, 2007 01:29 PM
regarding tables creation in xslt barsha XSLT 0 September 28th, 2005 07:50 AM
XSLT and tables surgeon XSLT 1 July 3rd, 2005 03:36 AM
xslt looping with tables... lukemedway_uk XSLT 16 December 24th, 2003 12:24 PM





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