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

Re: Node set

Subject: Re: Node set
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 7 Feb 2001 09:20:54 +0000
Re:  Node set
Hi Yue,

> If I have the order in XML  file like:
> title1,title2,title3,title4,title5
>
> The order we should display MAY be:
> title1,title3,title2(on the left column)
> title5,title4(on the right column)
> again, any title element may not be in the XML file, means if I don't find
> title3, I should display:
> title1,title2(on the left column)
> title5,title4(on the right column)

>From this description, you could use:

  <table>
     <xsl:variable name="top-row"
                   select="count(title1 | title2 | title3)" />
     <xsl:variable name="bottom-row"
                   select="count(title4 | title5)" />
     <xsl:if test="$top-row">
        <tr>
           <xsl:apply-templates select="title1" />
           <xsl:apply-templates select="title3" />
           <xsl:apply-templates select="title2" />
           <xsl:if test="$bottom-row &gt; $top-row">
              <td />
           </xsl:if>
        </tr>
     </xsl:if>
     <xsl:if test="title4 or title5">
        <tr>
           <xsl:apply-templates select="title5" />
           <xsl:apply-templates select="title4" />
           <xsl:if test="$top-row &gt; $bottom-row">
              <td />
              <xsl:if test="$top-row - $bottom-row = 2">
                 <td />
              </xsl:if>
           </xsl:if>
        </tr>
     </xsl:if>
  </table>

With the following template giving the cells for each title (it will
only be processed if there *is* such a title):
  
<xsl:template match="title1 | title2 | title3 | title4 | title5">
   <td><xsl:value-of select="." /></td>
</xsl:template>

Of course, you may not have covered all possible scenarios in your
description.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread
  • Re: Node set, (continued)
    • Jeni Tennison - Mon, 5 Feb 2001 13:50:45 -0500 (EST)
      • YueMa - Mon, 5 Feb 2001 15:57:30 -0500 (EST)
        • Jeni Tennison - Tue, 6 Feb 2001 05:14:12 -0500 (EST)
        • YueMa - Tue, 6 Feb 2001 15:25:59 -0500 (EST)
        • Jeni Tennison - Wed, 7 Feb 2001 05:10:13 -0500 (EST) <=

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.