[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Luke,
The easiest way to fix this, if it's possible, is to construct your condition such that it occurs in the 'select' expression that chooses the nodes to process, rather than selecting a larger set and then using an explicit conditional to filter them.
That is, instead of:
do
Then your code relying on position() will work again.
Note, this isn't always possible -- your problem may require heavier lifting. Post again with more info (including the logic of the condition) if this doesn't work for you.
At 01:57 PM 4/5/2005, you wrote:
Re: [xsl] Something similar to managing behavior with a variable
Subject: Re: [xsl] Something similar to managing behavior with a variable From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 05 Apr 2005 13:54:24 -0400 |
Luke,
The easiest way to fix this, if it's possible, is to construct your condition such that it occurs in the 'select' expression that chooses the nodes to process, rather than selecting a larger set and then using an explicit conditional to filter them.
That is, instead of:
<xsl:for-each select="$nodes"> <xsl:if test="$condition"> ... </xsl:if> ... </xsl:for-each>
do
<xsl:for-each select="$nodes[$condition]"> ... </xsl:for-each>
Then your code relying on position() will work again.
Note, this isn't always possible -- your problem may require heavier lifting. Post again with more info (including the logic of the condition) if this doesn't work for you.
Cheers, Wendell
At 01:57 PM 4/5/2005, you wrote:
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)
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Something similar to managing, Luke Shannon | Thread | Re: [xsl] Something similar to mana, Luke Shannon |
RE: [xsl] math return result probl, Michael Kay | Date | [xsl] Something similar to managing, Luke Shannon |
Month |
Keywords