xsl-list
[Top] [All Lists]

RE: Flow data in table

2003-11-12 04:10:59
-----Original Message-----
From: Andrew Glass

I am trying to flow a set of data through a table by rows and
columns. I am having trouble working out how to trigger a new row.

Hi,

Check http://www.dpawson.co.uk/xsl/sect2/N7450.html#d8136e352

to find out how to process every five elements as a group, then, create a
template for the data elements that generates a <td/>, and use a modified
version of the <xsl:for-each > example on the page...

draft

<xsl:template match="modified">
  <xsl:for-each select="data[position() mod 5 = 1]">
    <tr>
      <xsl:apply-templates select=". | following-sibling::data[position()
&lt; 5]" />
    </tr>
  </xsl:for-each>
</xsl:template>

<xsl:template match="data">
  <td width="20%">
    <i>&#xA0;
      <xsl:value-of select="rm"/>
    </i>&#xA0;
    <span style="font-size: 22pt">
      <font face="Schoyen01"><xsl:value-of select="kh"/></font>
    </span>
  </td>
</xsl:template>

Thanks Andreas,

I've had a go at implementing your suggestion, but without success. The problem 
seems to be that your suggestion requires nesting xsl:template instructions 
since this segment needs to sit within html and that within the primary 
xsl:template. Apparently template instructions can be nested,
http://www.biglist.com/lists/xsl-list/archives/200105/msg00766.html
But my experiments along these lines have not worked.
I also tried leaving out the template instructions, and addressing the select 
instructions in full, but this didn't work either.

So is it possible to nest templates?

Cheers,

Andrew Glass

My xsl now looks like this:

<xsl:template match="/bamiyan">

<html>
    <head>
        <title>Bamiyan Scribes</title>
    </head>
    <body>
        <div align="center">
        <h3>Syllables with Modified Vowels</h3>
        <table width="60%" border="1">
                <xsl:template match="/scribe[1]/modified">
                <xsl:for-each select="data[position() mod 5 = 1]">
                <tr>
                <xsl:apply-templates select=". | 
following-sibling::data[position() &lt; 5]" />
                </tr>
                </xsl:for-each>
                </xsl:template>

                <xsl:template match="/scribe[1]/modified/data">
                <td width="20%">
                <i>&#xA0;<xsl:value-of select="rm"/></i>&#xA0;
                <span style="font-size: 22pt"><font 
face="Schoyen01"><xsl:value-of select="kh"/></font></span>
                </td>
                </xsl:template>
        </table>
        </div>
    </body>
</html>
</xsl:template>





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



<Prev in Thread] Current Thread [Next in Thread>