dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: xsl:for-each

  1. #1
    Join Date
    Jul 2003
    Location
    Berlin
    Posts
    40

    xsl:for-each

    Hi Pros,

    just starting xml. I'm stuck in one of my first simple codes. I need to use two xsl:for-each one within the other. I think it should work although it's not valid. I can't see why it would not show the 'theme's value! It generates the tables but leaves them empty. Are there any restrictions or rules to meet concerning two xsl:for-each?
    Here are the codes:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet href="math1.xsl" type="text/xsl"?>
    <library>
    <book>
    <theme>A</theme>
    <theme>B</theme>
    <theme>C</theme>
    </book>
    <book>
    <theme>D</theme>
    <theme>F</theme>
    </book>
    </library>
    -----------------------
    math1.xsl

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xslutput method="html"/>
    <xsl:template match="library">
    <html>
    <head>
    <title>library</title>
    </head>
    <body>
    <table border="1">
    <tr>
    <td>library</td>
    </tr>
    <tr>
    <td>
    <xsl:for-each select="book">
    <table border="2" bgcolor="blue">
    <xsl:for-each select="theme">
    <tr>
    <td>
    <xsl:value-of select="theme"/>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:for-each>
    </td>
    </tr>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

  2. #2
    Join Date
    Jul 2003
    Location
    Berlin
    Posts
    40

    simplyfied

    now I finally stripped it to the bones---negative

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xslutput method="html"/>
    <xsl:template match="library">
    <html>
    <body>
    <xsl:for-each select="book">
    <xsl:for-each select="theme">
    <xsl:value-of select="theme"/>blabla<br/>
    </xsl:for-each>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    I can see the correct number of blabla's but NO theme's value

  3. #3
    Join Date
    Jul 2003
    Location
    Berlin
    Posts
    40

    sorry for bothering you

    simple mistake...I found it:

    <xsl:value of select="."/>

    Thanks anyway


  4. #4
    Join Date
    Jul 2003
    Location
    Berlin
    Posts
    40

    ---

    <xsl:value-of select="."/>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles