Re: [xsl] Node set

Subject: Re: [xsl] Node set
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 7 Feb 2001 09:20:54 +0000
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:

     <xsl:variable name="top-row"
                   select="count(title1 | title2 | title3)" />
     <xsl:variable name="bottom-row"
                   select="count(title4 | title5)" />
     <xsl:if test="$top-row">
           <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 test="title4 or title5">
           <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 />

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>

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

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread