[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Breaking up is hard to do.
| | I am unable to generate a </tr><tr> in my output. | Here's a simple way to do it that works like your brain might be thinking. It depends on using the: <xsl:text disable-output-escaping="yes"> to *force* text into the result without being quoted by the processor. In this case the text you want to force into the result is: </tr><tr> at the strategic point when you hit your threshold of maximum number of columns. Given the input document of: <data> <field>1</field> <field>2</field> <field>3</field> <field>4</field> <field>5</field> <field>6</field> <field>7</field> <field>8</field> <field>9</field> <field>10</field> </data> The stylesheet below (which is parameterized to allow specifying the max number of columns for the current "run") gives output like: <html> <body> <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> <tr> <td>10</td> </tr> </table> </body> </html> ===============[ cut ]=================== <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="max" select="number(3)"/> <xsl:template match="/"> <html><body><xsl:apply-templates/></body></html> </xsl:template> <xsl:template match="data"> <table> <tr> <xsl:for-each select="field"> <td><xsl:apply-templates/></td> <xsl:if test="position() mod $max = 0 and position()!=last()"> <xsl:text disable-output-escaping="yes"><![CDATA[</tr><tr>]]></xsl:text> </xsl:if> </xsl:for-each> </tr> </table> </xsl:template> </xsl:stylesheet> _________________________________________________________ Steve Muench, Consulting Product Manager & XML Evangelist Business Components for Java Development Team XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|