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

Re: XSLT Problem

Subject: Re: XSLT Problem
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 20 Jun 2001 13:36:47 -0700 (PDT)
xslt every other row
Hi Alex,

> I've got result table where I can not color every other row because as I
> understand the system :
> 1. retrieves rows and sorts them by appropriate keys;
>    for example :
>      1-st row   (value of C-field is '  ') - black;
>      2-nd row (value of C-field is '11') - gray;
>      3-rd row  (value of C-field is '  ') - black;
>      4-th row   (value of C-field is '22') - gray;
>      5-th row   (value of C-field is '  ') - black;
>      6-th row   (value of C-field is '  ') - gray;
> 
> 2. and only then excludes 2-nd and 4-th rows( where field-C not = '  ')
> 
> So instead of sequence :
> 
> 1-st row (value of C-field is '  ') - black;
> 3-rd row (value of C-field is '  ') - gray;
> 5-th row (value of C-field is '  ') - black;
> 6-th row (value of C-field is '  ') - gray
> 
> I've got :
> 
> 1-st row (value of C-field is '  ') - black;
> 3-rd row (value of C-field is '  ') - black;
> 5-th row (value of C-field is '  ') - black;
> 6-th row (value of C-field is '  ') - gray
> 
> Or other words does XSLT give us the posibility to use something like "where" in
>  DB2 ?
> And if it does - how to use it within <xsl:for-each> or <xsl:apply-templates
> select="..."> BEFORE SORTING ?

Yes, there is such possibility -- a "predicate" can be placed at the end of every
location step.

In your case you'll have:


  <xsl:for-each select="Record01[field-C = '  ']">
      <!-- All contents as in your code, but remove the xsl:if -->
  </xsl:for-each>

Hope this helped,

Cheers,
Dimitre Novatchev.



Alex Genis wrote:

Hi ! Could you please help ?
My task is : to create HTML report from XML document and to color every other
row  for the result HTML table.
Everything is already done but I still have one problem:

If I use

  <xsl:for-each select="Record01">
   <xsl:sort select="field-A"/>
   <xsl:sort select="field-B"/>

     <xsl:if test="field-C = '  '" >
        <TR>
          <xsl:choose>
           <xsl:when test="position() mod 2 = 0">
             <TD   ...   class="C1">
                                       <xsl:value-of select="field-A"/>
             </TD>
             <TD   ...   class="C1">
                                       <xsl:value-of select="field-B"/>
             </TD>
             <TD   ...   class="C1">
                                       <xsl:value-of select="field-C"/>
             </TD>
           </xsl:when>
           <xsl:otherwise>
             <TD   ...   class="C2">
                                       <xsl:value-of select="field-A"/>
             </TD>
             <TD   ...   class="C2">
                                       <xsl:value-of select="field-B"/>
             </TD>
             <TD   ...   class="C2">
                                       <xsl:value-of select="field-C"/>
             </TD>
           </xsl:otherwise>
        </xsl:choose>
      </TR>
   </xsl:if>

</xsl:for-each>

I've got result table where I can not color every other row because as I
understand the system :
1. retrieves rows and sorts them by appropriate keys;
   for example :
     1-st row   (value of C-field is '  ') - black;
     2-nd row (value of C-field is '11') - gray;
     3-rd row  (value of C-field is '  ') - black;
     4-th row   (value of C-field is '22') - gray;
     5-th row   (value of C-field is '  ') - black;
     6-th row   (value of C-field is '  ') - gray;

2. and only then excludes 2-nd and 4-th rows( where field-C not = '  ')

So instead of sequence :

1-st row (value of C-field is '  ') - black;
3-rd row (value of C-field is '  ') - gray;
5-th row (value of C-field is '  ') - black;
6-th row (value of C-field is '  ') - gray

I've got :

1-st row (value of C-field is '  ') - black;
3-rd row (value of C-field is '  ') - black;
5-th row (value of C-field is '  ') - black;
6-th row (value of C-field is '  ') - gray

Or other words does XSLT give us the posibility to use something like "where" in
 DB2 ?
And if it does - how to use it within <xsl:for-each> or <xsl:apply-templates
select="..."> BEFORE SORTING ?

How this problem can be solved ?
Thanks a lot. Alex Genis.














__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

 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.