Subject: RE: [xsl] XSL to HTML table problem From: "Roger Glover" <glover_roger@xxxxxxxxx> Date: Wed, 29 Jan 2003 21:09:34 -0600 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL to HTML table problem, Ross Ken | Thread | RE: [xsl] <xsl:sort> and <xsl:copy-, Stanger, Jan |
Re: [xsl] yet another XPath questio, S Woodside | Date | [xsl] generic xsl to transfrom xml , juliwati wijanto |
Month |