[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSL to HTML table problem
Ross Ken wrote: > I always avoid for-each and value-of using apply-templates > instead. WHEN the required output changes, that makes it easier > to extend the stylesheet. True, but your reformulation below does not actually address his *stated* problem. > <xsl:apply-templates select="Dictionary/WordDefinition"> > <xsl:sort select="Word"/> > </xsl:apply-templates> > > <xsl:template match="Dictionary/WordDefinition"> > <tr bgcolor="#99CCFF"><td><xsl:value-of select="Word"/></td><td><br/></td> > <xsl:apply-templates select="Definition" /> > </tr> > </xsl:template> > > <xsl:template match="Definition"> > <td><br/></td><td bgcolor="#99CCAA"><xsl:apply-templates/></td> > </xsl:template> When writing my earlier response, I thought about reformulating his "master control template" along these lines myself, but I decided in the end just to address the stated problem of reformatting the definitions within the table. But since you have already done the restructuring :)... How about this somewhat similar code to solve the stated problem? <!-- following replaces James' outer "for-each" --> <xsl:apply-templates select="Dictionary/WordDefinition"> <xsl:sort select="Word"/> </xsl:apply-templates> <!-- preceding replaces James' outer "for-each" --> <xsl:template match="WordDefinition"> <xsl:apply-templates select="Definition"/> </xsl:template> <xsl:template match="Definition[1]"> <tr bgcolor="#99CCFF"> <td><xsl:apply-templates select="../Word"/></td> <td><xsl:apply-templates/></td> </tr> </xsl:template> <xsl:template match="Definition"> <tr bgcolor="#99CCAA"> <td><br/></td> <td><xsl:apply-templates/></td> </tr> </xsl:template> -- Roger Glover glover_roger@xxxxxxxxx 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
|