xsl-list
[Top] [All Lists]

RE: Converting xml data to html using xsl/xslt

2004-02-11 17:21:29

Your template is matching the <slide> element. You have two 
slide elements in the slideshow, so you are getting two full 
copies of the html from your template. You probably want to 
start your match closer to the root


I find that when rendering an entire HTML page from XML source that matching
the root is the easiest and less prone to getting lost within the XML :)
 

<xsl:template match="/">
  <table>
    <tr><th>data1</th><th>data2</th></tr>
    <xsl:for-each select="slideshow/slide">
      <tr>
        <td><xsl:value-of select="data1"/></td>
        <td><xsl:value-of select="data2"/></td>
      </tr>
    </xsl:for-each>
  </table>
<xsl:template>


But either should work fine.





Here is a start for the xsl...

<xsl:template match="/slideshow">
  <table>
    <tr><th>data1</th><th>data2</th></tr>
    <xsl:for-each select="slide">
      <tr>
        <td><xsl:value-of select="data1"/></td>
        <td><xsl:value-of select="data2"/></td>
      </tr>
    </xsl:for-each>
  </table>
<xsl:template>

Hope this helps,
Josh



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