[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XSL to HTML table problem


Subject: [xsl] XSL to HTML table problem
From: arcjah@xxxxxxxx
Date: Wed, 29 Jan 2003 11:32:48 -0500

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



Current Thread
Keywords