[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL to HTML table problem

Subject: RE: XSL to HTML table problem
From: "Roger Glover" <glover_roger@xxxxxxxxx>
Date: Wed, 29 Jan 2003 21:09:34 -0600
html table templates
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.