Search

Hello Ninjas,

I have been trying to figure out if this is possible.

<tr>
<td></td>
<xsl:for-each select="data/sponsorship-packages/entry">
<td><xsl:value-of select="branding-on-lunch-menus"/></td>
<td><xsl:value-of select="some-other-node-i-may-not-know-the-name-of"/></td>
</xsl:for-each>
</tr>

In the above xslt transform I'm having to manually insert the node name to grab it's value.. But the number of nodes is likely to change and I want the output to be a little more dynamic.

Is there a way to itterate over a series of Entry nodes and render each node result from all entries on one table row?

Bascially making the xsl:value-of statements dynamic.. is this a job for a variable?

You mean like...

<tr>
    <td></td>
    <xsl:for-each select="data/sponsorship-packages/entry">
        <xsl:for-each select="*">
            <td><xsl:value-of select="."/></td>
        </xsl:for-each>
    </xsl:for-each>
</tr>

Sort of.. I need the entries going down rather than accross though.. will have a play with the td/tr ordering. Thanks.

use child::node() perhaps? That will select all direct children of entry without traversing deeper.

Why do tables have to be so awkward... This is how I want to present my data:

<tr>
        <xsl:for-each select="data/sponsorship-packages/entry">
        <td width="10%">
            <xsl:for-each select="*">
                <p style="border:1px solid #000;">     <xsl:value-of select="."/></p>
            </xsl:for-each>
        </td>
        </xsl:for-each>
    </tr>

But it seems nested TR's in TD's isn't validating. I've replaced the row with a P tag to explain where I'd like the split... Any pointers?

I'm after this layout.. where each row of data is a node from each entry:

    <table border="1">
    <tr>
    <th>Package Contents</th>
    <th>Package1</th>
    <th>Package2</th>
    <th>Package3</th>
  </tr>
  <tr>
    <td>Logo in booklet</td>
    <td>No</td>
    <td>Yes</td>
    <td>No</td>
  </tr>
  <tr>
    <td>Logo n banner</td>
    <td>yes</td>
    <td>yes</td>
    <td>yes</td>
  </tr>
Attachments:
table-layout.gif

Andy, I don't get what you're trying to achieve here.

Sort of.. I need the entries going down rather than accross though

Tables work in rows though, not columns. If you want lists, you should be using lists.

...or floating divs with regular block elements inside.

Cheers gents.. i've re-thought the data source now.

John, the table in rows thing is understood, I guess I am wanting to render each entry node value in a row instead of the actual entry.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details