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

Re: Something similar to managing behavior with a var

Subject: Re: Something similar to managing behavior with a variable
From: "Luke Shannon" <lshannon@xxxxxxxxxxxxxxx>
Date: Tue, 5 Apr 2005 14:47:47 -0400
luke shannon toronto
Thank you Michael. Option D seems to make the most sense to me.

----- Original Message ----- 
From: "Michael Kay" <mike@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, April 05, 2005 2:36 PM
Subject: RE:  Something similar to managing behavior with a variable


>
> Here are some of the design patterns you might consider:
>
> (a) computing the column number based on the counting selected nodes in
the
> source tree (using count() or xsl:number)
>
> (b) computing the number based on the position of the node in the current
> node list (the position() function)
>
> (c) "iterating" over the nodes by head-tail recursion, maintaining a
counter
> as you do so (by passing a parameter on the recursive call)
>
> (d) a two-phase transformation in which you generate the output nodes as a
> plain sequence in the first pass and then number them or group them (or
> colour them) in a second pass.
>
> Michael Kay
> http://www.saxonica.com/
>
>
>
> > -----Original Message-----
> > From: Luke Shannon [mailto:lshannon@xxxxxxxxxxxxxxx]
> > Sent: 05 April 2005 18:57
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Something similar to managing behavior with a variable
> >
> > Hello;
> >
> > I'm creating a UI that writes rows of data. The background of
> > the row needs
> > to changes every second row. I was doing it like this:
> >
> > <tr align="left" valign="middle" class="grey1ColumnText">
> > <xsl:choose>
> > <xsl:when test='number($position) mod 2 != 0'>
> > <xsl:attribute name="class">grey1ColumnText</xsl:attribute>
> > </xsl:when>
> > <xsl:otherwise>
> > <xsl:attribute name="class">grey2ColumnText</xsl:attribute>
> > </xsl:otherwise>
> > </xsl:choose>
> > </tr>
> >
> > My problem now is now have a condition that determines when a
> > row is to be
> > written. So, in a collection of 5 items maybe only 1 and 4
> > get written. I
> > still need a way to figure out how to alternate the
> > background for the rows
> > that actually get written. Position no longer does the trick.
> >
> > I thought I could keep the previous background in a variable
> > like below:
> >
> > <tr align="left" valign="middle" class="grey1ColumnText">
> > <xsl:choose>
> > <xsl:when test="$resultBK = 'grey1ColumnText'">
> > <xsl:attribute name="class">grey2ColumnText</xsl:attribute>
> > <xsl:variable name="resultBK" select="string('grey2ColumnText')"/>
> > </xsl:when>
> > <xsl:otherwise>
> > <xsl:attribute name="class">grey1ColumnText</xsl:attribute>
> > <xsl:variable name="resultBK" select="string('grey1ColumnText')"/>
> > </xsl:otherwise>
> > </xsl:choose>
> > </tr>
> >
> > But I have just found out you can't change the contents of a
> > global variable
> > (resultBK) after it has been defined. How can I handle this?
> >
> > Thanks,
> >
> > Luke
> >
> > Luke Shannon | Software Developer
> > FutureBrand Toronto
> >
> > 207 Queen's Quay, Suite 400
> > Toronto, ON, M5J 1A7
> > 416 642 7935 (office)

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.