[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Displaying every 2 element values in 1 row

Subject: Re: Displaying every 2 element values in 1 row
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 25 Apr 2000 23:36:46 -0600 (MDT)
xsl display 23 rows
> with a more complicated example this gets wacked. [...]
> I basic[al]ly want this output:
> <tr><td>DEPARTMENT 1</td>DEPARTMENT 2</td></tr>
> <tr><td>DEPARTMENT 3</td>DEPARTMENT 4</td></tr>
> 
> so this would be the <td> part:
> <xsl:template match="department">

The stuff for each 'department' and 'person' element looks fine to me.

> this is slightly over-slimplified, but it shows the problem I am having

Actually I don't think it shows the problem :)

> of that I am not trying to call a <xsl:value-of> as the contents of the
> tiling, but calling an <xsl:apply-templates>. the "following-sibling"
> returns a node-set

There was no following-sibling in your example, but I don't see why it
would be an issue, regardless. This example is only slightly modified:

<xsl:template match="company">
  <table>
    <xsl:for-each select="department[position() mod 2 = 1]">
      <tr>
        <xsl:apply-templates select="."/>
        <xsl:choose>
          <xsl:when test="following-sibling::department">
            <xsl:apply-templates select="following-sibling::department"/>
          </xsl:when>
          <xsl:otherwise>
            <td>&#160;</td>
          </xsl:otherwise>
        </xsl:choose>
      </tr>
    </xsl:for-each>
  </table>
</xsl:template>

It assumes you have the templates that match 'department' elements as you
gave in your example. In your example, you don't need to use
following-sibling:: to look at the next n 'person' elements; you're
already using xsl:apply-templates with select="person" to process all of
them using the template that you made to match 'person' elements.

   - Mike
___________________________________________________________
Mike J. Brown, software engineer, Webb Interactive Services
XML/XSL stuff: http://www.skew.org/    http://www.webb.net/


 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.