[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: "Ross Ken" <Ken.Ross@xxxxxxxxxxxxxx>
Date: Thu, 30 Jan 2003 08:53:32 +1000
html 99ccff
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.

   <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>

Ken Ross
Ph: +61 7 32359370
Mob: +61 (0)419 772299
Email: Ken.Ross@xxxxxxxxxxxxxx


-----Original Message-----
From: Rick Taylor [mailto:taylor@xxxxxxxx]
Sent: Thursday, 30 January 2003 2:56 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  XSL to HTML table problem


James

do the loop for the Definitions inside the <tr>
I didn't test this but it should work.

   <xsl:for-each select="Dictionary/WordDefinition">
      <xsl:sort select="Word"/>

        <tr bgcolor="#99CCFF"><td><xsl:value-of 
select="Word"/></td><td><br/></td>
           <xsl:for-each select="Definition">
            <td><br/></td><td bgcolor="#99CCAA"><xsl:value-of select="."/></td>
           </xsl:for-each>
        </tr>
  </xsl:for-each>


At 11:32 AM 1/29/03 -0500, arcjah@xxxxxxxx wrote:
>I am a novice when it comes to xsl. If I don't explain my problem clearly 
>please let me know.
>
>I have an xml document that looks like the following:
><Dictionary>
>     <WordDefinition>
>            <Word>Some Word</Word>
>            <Definition>First Definition</Definition>
>            <Definition>Second Definition</Definition>
>            <Definition>Third Definition</Definition>
>     </WordDefinition>
>     <WordDefinition>
>            <Word>Second Word</Word>
>            <Definition>First Definition</Definition>
>            <Definition>Second Definition</Definition>
>     </WordDefinition>
></Dictionary>
>
>I have an xslt document that looks like the following:
>
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet version="1.0" 
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
>xmlns:fo="http://www.w3.org/1999/XSL/Format">
>       <xsl:template match="/">
>           <html>
>              <body text="#003300" bgcolor="#99CCFF">
>                <h2 align="center">Word Definitions</h2>
>                <table border="1">
>                   <tr bgcolor="#99CCFF">
>                      <th >Word</th>
>                      <th>Definition</th>
>                   </tr>
>                   <xsl:for-each select="Dictionary/WordDefinition">
>                   <xsl:sort select="Word"/>
>                      <tr bgcolor="#99CCFF"><td><xsl:value-of 
> select="Word"/></td><td><br/></td></tr>
>                      <xsl:for-each 
> select="Definition">
>                                    <tr 
> bgcolor="#99CCAA"><td><br/></td><td><xsl:value-of select="."/></td></tr>
>                      </xsl:for-each>
>                   </xsl:for-each>
>                 </table>
>              </body>
>            </html>
>     </xsl:template>
></xsl:stylesheet>
>
>(My problem is, I want the word and first definition on the same row.)
>The above xsl transforms the xml document into a html document that has 
>the word on one row, in the first column and the defintions in the second, 
>third and forth row in the second column.
>
>Again I want to figure out how to make the word and first definition sit 
>on the same row.
>
>I've heard about indexing the elements but I've never seen any examples of 
>this.
>
>Thanks,
>James
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Rick Taylor
XML Developer
PPDM Association


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

IMPORTANT: This email (including any attachments) may contain confidential,
private or legally privileged information and may be protected by copyright. You may
only use it if you are the person(s) it was intended to be sent to and if you use it in an
authorised way. No one is allowed to use, review, alter, transmit, disclose, distribute,
print or copy this e-mail without appropriate authority.
 
If this e-mail was not intended for you and was sent to you by mistake, please
telephone or e-mail me immediately, destroy any hard copies of this e-mail and delete
it and any copies of it from your computer system. Any legal privilege and 
confidentiality attached to this e-mail is not waived or destroyed by that mistake.
 
It is your responsibility to ensure that this e-mail does not contain and is not affected
by computer viruses, defects or interference by third parties or replication problems
(including incompatibility with your computer system).




 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.